Skip to content

Commit 6f49dee

Browse files
vsenchyshynlguohan
authored andcommitted
[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 <[email protected]>
1 parent 4fed69e commit 6f49dee

File tree

2 files changed

+33
-10
lines changed

2 files changed

+33
-10
lines changed

device/barefoot/x86_64-accton_wedge100bf_32x-r0/plugins/eeprom.py

+19-4
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474

7575

7676
class board(eeprom_tlvinfo.TlvInfoDecoder):
77+
RETRIES = 30
7778

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

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

8990
self.eeprom_path = EEPROM_SYMLINK
9091
super(board, self).__init__(self.eeprom_path, 0, '', True)
91-
self.eeprom_init()
92+
93+
for attempt in range(self.RETRIES + 1):
94+
if not self.eeprom_init():
95+
time.sleep(1)
96+
else:
97+
break
98+
99+
if attempt == self.RETRIES:
100+
raise RuntimeError("Could not initialize syseeprom")
101+
92102

93103
def thrift_setup(self):
94104
global thrift_server, transport, pltfm_mgr
@@ -109,9 +119,12 @@ def thrift_teardown(self):
109119

110120
def eeprom_init(self):
111121
global pltfm_mgr
112-
self.thrift_setup()
113-
eeprom = pltfm_mgr.pltfm_mgr_sys_eeprom_get()
114-
self.thrift_teardown()
122+
try:
123+
self.thrift_setup()
124+
eeprom = pltfm_mgr.pltfm_mgr_sys_eeprom_get()
125+
self.thrift_teardown()
126+
except:
127+
return False
115128

116129
eeprom_params = ""
117130
for attr, val in eeprom.__dict__.iteritems():
@@ -143,3 +156,5 @@ def eeprom_init(self):
143156
sys.stdout = orig_stdout
144157
eeprom_base.EepromDecoder.write_eeprom(self, new_e)
145158

159+
return True
160+

device/barefoot/x86_64-accton_wedge100bf_32x-r0/plugins/psuutil.py

+14-6
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,13 @@ def get_psu_status(self, index):
6363
return False
6464

6565
global pltfm_mgr
66-
self.thrift_setup()
67-
psu_info = pltfm_mgr.pltfm_mgr_pwr_supply_info_get(index)
68-
self.thrift_teardown()
66+
67+
try:
68+
self.thrift_setup()
69+
psu_info = pltfm_mgr.pltfm_mgr_pwr_supply_info_get(index)
70+
self.thrift_teardown()
71+
except:
72+
return False
6973

7074
return (psu_info.ffault == False)
7175

@@ -80,9 +84,13 @@ def get_psu_presence(self, index):
8084
return False
8185

8286
global pltfm_mgr
83-
self.thrift_setup()
84-
status = pltfm_mgr.pltfm_mgr_pwr_supply_present_get(index)
85-
self.thrift_teardown()
87+
88+
try:
89+
self.thrift_setup()
90+
status = pltfm_mgr.pltfm_mgr_pwr_supply_present_get(index)
91+
self.thrift_teardown()
92+
except:
93+
return False
8694

8795
return status
8896

0 commit comments

Comments
 (0)