Merge pull request #105 from nega0/feature/seagate

[megaclisas-status] reformat "drive model" in disk info blocks
This commit is contained in:
Adam Cécile 2019-08-19 23:24:17 +02:00 committed by GitHub
commit a9a5b06bca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 30 additions and 0 deletions

View File

@ -476,6 +476,21 @@ def returnDiskInfo(output,controllerid):
elif re.match(r'Inquiry Data: .*$',line.strip()):
model = line.split(':')[1].strip()
model = re.sub(' +', ' ', model)
# re-define our "sub-code"
# our seagate drives have an ID string of
# 'Z1E19S2QST2000DM001-1CH164 CC43'
# or
# '6XW02738ST32000542AS CC32'
m = re.match(r'(\w{8})(ST\w+)(?:-(\w{6}))?(?:\s+(\w+))', model)
if m:
if m.group(3):
model = '{}-{} {} {}'.format(m.group(2), m.group(3), m.group(4), m.group(1))
else:
model = '{} {:>10} {}'.format(m.group(2), m.group(4), m.group(1))
continue
# Sub code
manuf = re.sub(' .*', '', model)
dtype = re.sub(manuf+' ', '', model)
@ -562,6 +577,21 @@ def returnUnconfDiskInfo(output,controllerid):
elif re.match(r'Inquiry Data: .*$',line.strip()):
model = line.split(':')[1].strip()
model = re.sub(' +', ' ', model)
# re-define our "sub-code"
# our seagate drives have an ID string of
# 'Z1E19S2QST2000DM001-1CH164 CC43'
# or
# '6XW02738ST32000542AS CC32'
m = re.match(r'(\w{8})(ST\w+)(?:-(\w{6}))?(?:\s+(\w+))', model)
if m:
if m.group(3):
model = '{}-{} {} {}'.format(m.group(2), m.group(3), m.group(4), m.group(1))
else:
model = '{} {:>10} {}'.format(m.group(2), m.group(4), m.group(1))
continue
manuf = re.sub(' .*', '', model)
dtype = re.sub(manuf+' ', '', model)
dtype = re.sub(' .*', '', dtype)