mirror of
https://opendev.org/x/pyghmi
synced 2025-01-28 20:07:42 +00:00
Clean up strings from FRU
Often, a vendor will pad their data fields with spaces. Compensate through use of strip. Similarly, some devices elect to use spaces rather than ascii zeroes on Lenovo devices, recognize those as not present fields as well. Change-Id: I3e1d1ffd5dae4d4febc727e7193fa6652050b267
This commit is contained in:
parent
33de9a451f
commit
f223ed7849
@ -221,7 +221,7 @@ class FRU(object):
|
||||
retinfo = retinfo.decode('utf-16le')
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
retinfo = retinfo.replace('\x00', '')
|
||||
retinfo = retinfo.replace('\x00', '').strip()
|
||||
return retinfo, newoffset
|
||||
elif currtype == 1: # BCD 'plus'
|
||||
retdata = ''
|
||||
@ -229,9 +229,11 @@ class FRU(object):
|
||||
byte = hex(byte).replace('0x', '').replace('a', ' ').replace(
|
||||
'b', '-').replace('c', '.')
|
||||
retdata += byte
|
||||
retdata = retdata.strip()
|
||||
return retdata, newoffset
|
||||
elif currtype == 2: # 6-bit ascii
|
||||
retinfo = unpack6bitascii(retinfo)
|
||||
retinfo = retinfo.strip()
|
||||
return retinfo, newoffset
|
||||
|
||||
def _parse_chassis(self):
|
||||
|
@ -32,13 +32,13 @@ class OEMHandler(generic.OEMHandler):
|
||||
# Thinkserver lays out specific interpretation of the
|
||||
# board extra fields
|
||||
_, _, wwn1, wwn2, mac1, mac2 = fru['board_extra']
|
||||
if wwn1 != '0000000000000000':
|
||||
if wwn1 not in ('0000000000000000', ''):
|
||||
fru['WWN 1'] = wwn1
|
||||
if wwn2 != '0000000000000000':
|
||||
if wwn2 not in ('0000000000000000', ''):
|
||||
fru['WWN 2'] = wwn2
|
||||
if mac1 != '00:00:00:00:00:00':
|
||||
if mac1 not in ('00:00:00:00:00:00', ''):
|
||||
fru['MAC Address 1'] = mac1
|
||||
if mac2 != '00:00:00:00:00:00':
|
||||
if mac2 not in ('00:00:00:00:00:00', ''):
|
||||
fru['MAC Address 2'] = mac2
|
||||
# The product_extra is just UUID, we have that plenty of other ways
|
||||
# So for now, leave that portion of the data alone
|
||||
|
Loading…
x
Reference in New Issue
Block a user