[Mellanox] update eeprom.py plugin for SimX (#4364)
Signed-off-by: Mykola Faryma <mykolaf@mellanox.com>
This commit is contained in:
parent
63450d7d21
commit
be0e923ca1
@ -21,6 +21,7 @@ try:
|
|||||||
from cStringIO import StringIO
|
from cStringIO import StringIO
|
||||||
from sonic_eeprom import eeprom_base
|
from sonic_eeprom import eeprom_base
|
||||||
from sonic_eeprom import eeprom_tlvinfo
|
from sonic_eeprom import eeprom_tlvinfo
|
||||||
|
from sonic_device_util import get_machine_info
|
||||||
import subprocess
|
import subprocess
|
||||||
except ImportError, e:
|
except ImportError, e:
|
||||||
raise ImportError (str(e) + "- required module not found")
|
raise ImportError (str(e) + "- required module not found")
|
||||||
@ -34,6 +35,14 @@ def log_error(msg):
|
|||||||
syslog.syslog(syslog.LOG_ERR, msg)
|
syslog.syslog(syslog.LOG_ERR, msg)
|
||||||
syslog.closelog()
|
syslog.closelog()
|
||||||
|
|
||||||
|
|
||||||
|
machine_info = get_machine_info()
|
||||||
|
onie_platform = machine_info['onie_platform']
|
||||||
|
if 'simx' in onie_platform:
|
||||||
|
platform_path = os.path.join('/usr/share/sonic/device', onie_platform)
|
||||||
|
subprocess.check_call(['/usr/bin/xxd', '-r', '-p', 'syseeprom.hex', 'syseeprom.bin'], cwd=platform_path)
|
||||||
|
CACHE_FILE = os.path.join(platform_path, 'syseeprom.bin')
|
||||||
|
|
||||||
class board(eeprom_tlvinfo.TlvInfoDecoder):
|
class board(eeprom_tlvinfo.TlvInfoDecoder):
|
||||||
|
|
||||||
_TLV_INFO_MAX_LEN = 256
|
_TLV_INFO_MAX_LEN = 256
|
||||||
@ -50,7 +59,7 @@ class board(eeprom_tlvinfo.TlvInfoDecoder):
|
|||||||
log_error("Nowhere to read syseeprom from! No symlink or cache file found")
|
log_error("Nowhere to read syseeprom from! No symlink or cache file found")
|
||||||
raise RuntimeError("No syseeprom symlink or cache file found")
|
raise RuntimeError("No syseeprom symlink or cache file found")
|
||||||
|
|
||||||
self.eeprom_path = EEPROM_SYMLINK
|
self.eeprom_path = EEPROM_SYMLINK if 'simx' not in onie_platform else CACHE_FILE
|
||||||
super(board, self).__init__(self.eeprom_path, 0, '', True)
|
super(board, self).__init__(self.eeprom_path, 0, '', True)
|
||||||
|
|
||||||
def decode_eeprom(self, e):
|
def decode_eeprom(self, e):
|
||||||
@ -60,3 +69,4 @@ class board(eeprom_tlvinfo.TlvInfoDecoder):
|
|||||||
decode_output = sys.stdout.getvalue()
|
decode_output = sys.stdout.getvalue()
|
||||||
sys.stdout = original_stdout
|
sys.stdout = original_stdout
|
||||||
print(decode_output.replace('\0', ''))
|
print(decode_output.replace('\0', ''))
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user