sonic-buildimage/device/dell/x86_64-dell_s6000_s1220-r0/plugins/eeprom.py
Arun Saravanan Balachandran 54b284f4b0
[DellEMC]: EEPROM decoder for S6000, S6000-ON (#4718)
**- Why I did it**

For decoding system EEPROM of S6000 based on Dell offset format and S6000-ON’s system EEPROM in ONIE TLV format.

**- How I did it**

- Differentiate between S6000 and S6000-ON using the product name available in ‘dmi’  ( “/sys/class/dmi/id/product_name” )
- For decoding S6000 system EEPROM in Dell offset format and updating the redis DB with the EEPROM contents, added a new class ‘EepromS6000’ in eeprom.py, 
- Renamed certain methods in both Eeprom, EepromS6000 classes to accommodate the plugin-specific methods.

**- How to verify it**

- Use 'decode-syseeprom' command to list the system EEPROM details.
- Wrote a python script to load chassis class and call the appropriate methods.

UT Logs: [S6000_eeprom_logs.txt](https://github.com/Azure/sonic-buildimage/files/4735515/S6000_eeprom_logs.txt), [S6000-ON_eeprom_logs.txt](https://github.com/Azure/sonic-buildimage/files/4735461/S6000-ON_eeprom_logs.txt)
Test script: [eeprom_test_py.txt](https://github.com/Azure/sonic-buildimage/files/4735509/eeprom_test_py.txt)
2020-06-09 09:08:15 -07:00

31 lines
992 B
Python

#!/usr/bin/env python
#############################################################################
# Dell S6000
#
# Platform and model specific eeprom subclass, inherits from the base class,
# and provides the followings:
# - the eeprom format definition
# - specific encoder/decoder if there is special need
#############################################################################
try:
from sonic_eeprom.eeprom_tlvinfo import TlvInfoDecoder
from sonic_platform.eeprom import EepromS6000
except ImportError as e:
raise ImportError(str(e) + "- required module not found")
class board(object):
def __new__(cls, name, path, cpld_root, ro):
eeprom_path = "/sys/class/i2c-adapter/i2c-10/10-0053/eeprom"
with open("/sys/class/dmi/id/product_name", "r") as fd:
board_type = fd.read()
if 'S6000-ON' in board_type:
return TlvInfoDecoder(eeprom_path, 0, '', True)
else:
return EepromS6000(is_plugin=True)