Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[platform]: Added exceptions handling for BFN syseeprom and psuutil #3342

Merged
merged 1 commit into from
Aug 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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