[Mellanox] Fix issue: read data from eeprom should trim tail \0 (#5670)
Now we are reading base mac, product name from eeprom data, and the data read from eeprom contains multiple "\0" characters at the end, need trim them to make the string clean and display correct.
This commit is contained in:
parent
207587d97c
commit
ca7a4a4e3a
@ -82,18 +82,26 @@ class Eeprom(eeprom_tlvinfo.TlvInfoDecoder):
|
|||||||
self._base_mac = self.mgmtaddrstr(eeprom)
|
self._base_mac = self.mgmtaddrstr(eeprom)
|
||||||
if self._base_mac is None:
|
if self._base_mac is None:
|
||||||
self._base_mac = "Undefined."
|
self._base_mac = "Undefined."
|
||||||
|
else:
|
||||||
|
self._base_mac = self._base_mac.strip('\0')
|
||||||
|
|
||||||
self._serial_str = self.serial_number_str(eeprom)
|
self._serial_str = self.serial_number_str(eeprom)
|
||||||
if self._serial_str is None:
|
if self._serial_str is None:
|
||||||
self._serial_str = "Undefined."
|
self._serial_str = "Undefined."
|
||||||
|
else:
|
||||||
|
self._serial_str = self._serial_str.strip('\0')
|
||||||
|
|
||||||
self._product_name = self.modelstr(eeprom)
|
self._product_name = self.modelstr(eeprom)
|
||||||
if self._product_name is None:
|
if self._product_name is None:
|
||||||
self._product_name = "Undefined."
|
self._product_name = "Undefined."
|
||||||
|
else:
|
||||||
|
self._product_name = self._product_name.strip('\0')
|
||||||
|
|
||||||
self._part_number = self.part_number_str(eeprom)
|
self._part_number = self.part_number_str(eeprom)
|
||||||
if self._part_number is None:
|
if self._part_number is None:
|
||||||
self._part_number = "Undefined."
|
self._part_number = "Undefined."
|
||||||
|
else:
|
||||||
|
self._part_number = self._part_number.strip('\0')
|
||||||
|
|
||||||
original_stdout = sys.stdout
|
original_stdout = sys.stdout
|
||||||
sys.stdout = StringIO()
|
sys.stdout = StringIO()
|
||||||
|
Loading…
Reference in New Issue
Block a user