Skip to content

Commit

Permalink
[platform]: Added exceptions handling for BFN syseeprom and psuutil (#…
Browse files Browse the repository at this point in the history
…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>
  • Loading branch information
vsenchyshyn authored and lguohan committed Aug 15, 2019
1 parent 4fed69e commit 6f49dee
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 10 deletions.
23 changes: 19 additions & 4 deletions device/barefoot/x86_64-accton_wedge100bf_32x-r0/plugins/eeprom.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@


class board(eeprom_tlvinfo.TlvInfoDecoder):
RETRIES = 30

def __init__(self, name, path, cpld_root, ro):

Expand All @@ -88,7 +89,16 @@ def __init__(self, name, path, cpld_root, ro):

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
Expand All @@ -109,9 +119,12 @@ def thrift_teardown(self):

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():
Expand Down Expand Up @@ -143,3 +156,5 @@ def eeprom_init(self):
sys.stdout = orig_stdout
eeprom_base.EepromDecoder.write_eeprom(self, new_e)

return True

20 changes: 14 additions & 6 deletions device/barefoot/x86_64-accton_wedge100bf_32x-r0/plugins/psuutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,13 @@ def get_psu_status(self, index):
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)

Expand All @@ -80,9 +84,13 @@ def get_psu_presence(self, index):
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

0 comments on commit 6f49dee

Please sign in to comment.