[Nokia]: EEPROM platform API Python3 compliance changes (#6318)
- Why I did it Make EEPROM platform APIs Python3 compliant in Nokia platform. - How I did it Handle bytearray type returned by read_eeprom and read_eeprom_bytes methods. - How to verify it Boot Nokia ixs7215 and verify PMON docker running and show platform syseeprom Co-authored-by: Carl Keene <keene@nokia.com>
This commit is contained in:
parent
a64994ec29
commit
a1fe203788
@ -97,7 +97,7 @@ class Eeprom(TlvInfoDecoder):
|
|||||||
self.serial = 'NA'
|
self.serial = 'NA'
|
||||||
return
|
return
|
||||||
|
|
||||||
total_length = (ord(eeprom[9]) << 8) | ord(eeprom[10])
|
total_length = (eeprom[9] << 8) | eeprom[10]
|
||||||
tlv_index = self._TLV_INFO_HDR_LEN
|
tlv_index = self._TLV_INFO_HDR_LEN
|
||||||
tlv_end = self._TLV_INFO_HDR_LEN + total_length
|
tlv_end = self._TLV_INFO_HDR_LEN + total_length
|
||||||
|
|
||||||
@ -106,21 +106,16 @@ class Eeprom(TlvInfoDecoder):
|
|||||||
break
|
break
|
||||||
|
|
||||||
tlv = eeprom[tlv_index:tlv_index + 2
|
tlv = eeprom[tlv_index:tlv_index + 2
|
||||||
+ ord(eeprom[tlv_index + 1])]
|
+ eeprom[tlv_index + 1]]
|
||||||
code = "0x%02X" % (ord(tlv[0]))
|
code = "0x%02X" % (tlv[0])
|
||||||
|
|
||||||
if ord(tlv[0]) == self._TLV_CODE_VENDOR_EXT:
|
|
||||||
value = str((ord(tlv[2]) << 24) | (ord(tlv[3]) << 16) |
|
|
||||||
(ord(tlv[4]) << 8) | ord(tlv[5]))
|
|
||||||
value += str(tlv[6:6 + ord(tlv[1])])
|
|
||||||
else:
|
|
||||||
name, value = self.decoder(None, tlv)
|
name, value = self.decoder(None, tlv)
|
||||||
|
|
||||||
self.eeprom_tlv_dict[code] = value
|
self.eeprom_tlv_dict[code] = value
|
||||||
if ord(eeprom[tlv_index]) == self._TLV_CODE_CRC_32:
|
if eeprom[tlv_index] == self._TLV_CODE_CRC_32:
|
||||||
break
|
break
|
||||||
|
|
||||||
tlv_index += ord(eeprom[tlv_index+1]) + 2
|
tlv_index += eeprom[tlv_index+1] + 2
|
||||||
|
|
||||||
self.base_mac = self.eeprom_tlv_dict.get(
|
self.base_mac = self.eeprom_tlv_dict.get(
|
||||||
"0x%X" % (self._TLV_CODE_MAC_BASE), 'NA')
|
"0x%X" % (self._TLV_CODE_MAC_BASE), 'NA')
|
||||||
@ -181,6 +176,9 @@ class Eeprom(TlvInfoDecoder):
|
|||||||
for field in self.format:
|
for field in self.format:
|
||||||
field_end = field_start + field[2]
|
field_end = field_start + field[2]
|
||||||
if field[0] == field_name:
|
if field[0] == field_name:
|
||||||
|
if decode:
|
||||||
|
return (True, self.eeprom_data[field_start:field_end].decode('ascii'))
|
||||||
|
else:
|
||||||
return (True, self.eeprom_data[field_start:field_end])
|
return (True, self.eeprom_data[field_start:field_end])
|
||||||
field_start = field_end
|
field_start = field_end
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user