Skip to content

Commit 3b72a6f

Browse files
authored
Fix: handle empty LOC_CHASSIS_TABLE (#190)
**- What I did** We notice sometimes an error message. This PR will handle the case when the specific Redis table is not available/empty. ``` Jan 1 23:11:19.144294 vlab-01 ERR snmp#snmp-subagent [ax_interface] ERROR: MIBUpdater.start() caught an unexpected exception during update_data() Traceback (most recent call last): File "/usr/local/lib/python3.7/dist-packages/ax_interface/mib.py", line 37, in start self.reinit_data() File "/usr/local/lib/python3.7/dist-packages/sonic_ax_impl/mibs/ieee802_1ab.py", line 115, in reinit_data self.loc_chassis_data['lldp_loc_sys_cap_supported'] = parse_sys_capability(self.loc_chassis_data['lldp_loc_sys_cap_supported']) KeyError: 'lldp_loc_sys_cap_supported' ``` **- How I did it** **- How to verify it** Unit test
1 parent 4aad821 commit 3b72a6f

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/sonic_ax_impl/mibs/ieee802_1ab.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,10 @@ def reinit_data(self):
112112
# establish connection to application database.
113113
Namespace.connect_all_dbs(self.db_conn, mibs.APPL_DB)
114114
self.loc_chassis_data = Namespace.dbs_get_all(self.db_conn, mibs.APPL_DB, mibs.LOC_CHASSIS_TABLE)
115-
self.loc_chassis_data['lldp_loc_sys_cap_supported'] = parse_sys_capability(self.loc_chassis_data['lldp_loc_sys_cap_supported'])
116-
self.loc_chassis_data['lldp_loc_sys_cap_enabled'] = parse_sys_capability(self.loc_chassis_data['lldp_loc_sys_cap_enabled'])
115+
if self.loc_chassis_data:
116+
self.loc_chassis_data['lldp_loc_sys_cap_supported'] = parse_sys_capability(self.loc_chassis_data['lldp_loc_sys_cap_supported'])
117+
self.loc_chassis_data['lldp_loc_sys_cap_enabled'] = parse_sys_capability(self.loc_chassis_data['lldp_loc_sys_cap_enabled'])
118+
117119
def update_data(self):
118120
"""
119121
Avoid NotImplementedError

0 commit comments

Comments
 (0)