reformat "Drive Model" in the disk info block

This commit is contained in:
nega 2019-07-10 13:00:19 -04:00
parent a0093df3e6
commit 3963401717
1 changed files with 15 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)