[platform]: Added exceptions handling for BFN syseeprom and psuutil (#3342)
Added exceptions handling for BFN psuutil.py and eeprom.py which are raised when syseepromd and psud try to connect to the BFN thrift server which is not up yet. Now the exceptions backtrace is not logged to the syslog. Also psud doesn't exit on system bootup due to uncaught exception. Signed-off-by: Vitaliy Senchyshyn <vsenchyshyn@barefootnetworks.com>
This commit is contained in:
parent
4fed69ecbe
commit
6f49deeae9
@ -74,6 +74,7 @@ EEPROM_SYMLINK = "/var/run/platform/eeprom/syseeprom"
|
||||
|
||||
|
||||
class board(eeprom_tlvinfo.TlvInfoDecoder):
|
||||
RETRIES = 30
|
||||
|
||||
def __init__(self, name, path, cpld_root, ro):
|
||||
|
||||
@ -88,7 +89,16 @@ class board(eeprom_tlvinfo.TlvInfoDecoder):
|
||||
|
||||
self.eeprom_path = EEPROM_SYMLINK
|
||||
super(board, self).__init__(self.eeprom_path, 0, '', True)
|
||||
self.eeprom_init()
|
||||
|
||||
for attempt in range(self.RETRIES + 1):
|
||||
if not self.eeprom_init():
|
||||
time.sleep(1)
|
||||
else:
|
||||
break
|
||||
|
||||
if attempt == self.RETRIES:
|
||||
raise RuntimeError("Could not initialize syseeprom")
|
||||
|
||||
|
||||
def thrift_setup(self):
|
||||
global thrift_server, transport, pltfm_mgr
|
||||
@ -109,9 +119,12 @@ class board(eeprom_tlvinfo.TlvInfoDecoder):
|
||||
|
||||
def eeprom_init(self):
|
||||
global pltfm_mgr
|
||||
self.thrift_setup()
|
||||
eeprom = pltfm_mgr.pltfm_mgr_sys_eeprom_get()
|
||||
self.thrift_teardown()
|
||||
try:
|
||||
self.thrift_setup()
|
||||
eeprom = pltfm_mgr.pltfm_mgr_sys_eeprom_get()
|
||||
self.thrift_teardown()
|
||||
except:
|
||||
return False
|
||||
|
||||
eeprom_params = ""
|
||||
for attr, val in eeprom.__dict__.iteritems():
|
||||
@ -143,3 +156,5 @@ class board(eeprom_tlvinfo.TlvInfoDecoder):
|
||||
sys.stdout = orig_stdout
|
||||
eeprom_base.EepromDecoder.write_eeprom(self, new_e)
|
||||
|
||||
return True
|
||||
|
||||
|
@ -63,9 +63,13 @@ class PsuUtil(PsuBase):
|
||||
return False
|
||||
|
||||
global pltfm_mgr
|
||||
self.thrift_setup()
|
||||
psu_info = pltfm_mgr.pltfm_mgr_pwr_supply_info_get(index)
|
||||
self.thrift_teardown()
|
||||
|
||||
try:
|
||||
self.thrift_setup()
|
||||
psu_info = pltfm_mgr.pltfm_mgr_pwr_supply_info_get(index)
|
||||
self.thrift_teardown()
|
||||
except:
|
||||
return False
|
||||
|
||||
return (psu_info.ffault == False)
|
||||
|
||||
@ -80,9 +84,13 @@ class PsuUtil(PsuBase):
|
||||
return False
|
||||
|
||||
global pltfm_mgr
|
||||
self.thrift_setup()
|
||||
status = pltfm_mgr.pltfm_mgr_pwr_supply_present_get(index)
|
||||
self.thrift_teardown()
|
||||
|
||||
try:
|
||||
self.thrift_setup()
|
||||
status = pltfm_mgr.pltfm_mgr_pwr_supply_present_get(index)
|
||||
self.thrift_teardown()
|
||||
except:
|
||||
return False
|
||||
|
||||
return status
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user