Skip to content

Commit

Permalink
Merge pull request #2323 from mykolaf/eeprom_r
Browse files Browse the repository at this point in the history
[eeprom] check if source exists before reading eeprom on Mellanox platform
  • Loading branch information
liat-grozovik authored Nov 30, 2018
2 parents 405af31 + 85461de commit 40cb6e4
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion device/mellanox/x86_64-mlnx_msn2700-r0/plugins/eeprom.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,32 @@
except ImportError, e:
raise ImportError (str(e) + "- required module not found")

SYSLOG_IDENTIFIER = "eeprom.py"
EEPROM_SYMLINK = "/bsp/eeprom/vpd_info"
CACHE_FILE = "/var/cache/sonic/decode-syseeprom/syseeprom_cache"

def log_error(msg):
syslog.openlog(SYSLOG_IDENTIFIER)
syslog.syslog(syslog.LOG_ERR, msg)
syslog.closelog()

class board(eeprom_tlvinfo.TlvInfoDecoder):

_TLV_INFO_MAX_LEN = 256
RETRIES = 5

def __init__(self, name, path, cpld_root, ro):
self.eeprom_path = "/bsp/eeprom/vpd_info"
for attempt in range(self.RETRIES):
if not os.path.islink(EEPROM_SYMLINK):
time.sleep(1)
else:
break

if not (os.path.islink(EEPROM_SYMLINK) or os.isfile(CACHE_FILE)):
log_error("Nowhere to read syseeprom from! No symlink or cache file found")
raise RuntimeError("No syseeprom symlink or cache file found")

self.eeprom_path = EEPROM_SYMLINK
super(board, self).__init__(self.eeprom_path, 0, '', True)

def decode_eeprom(self, e):
Expand Down

0 comments on commit 40cb6e4

Please sign in to comment.