Skip to content

Commit

Permalink
Fix: handle empty LOC_CHASSIS_TABLE (#190)
Browse files Browse the repository at this point in the history
**- 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
  • Loading branch information
qiluo-msft authored Jan 2, 2021
1 parent 4aad821 commit 3b72a6f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/sonic_ax_impl/mibs/ieee802_1ab.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,10 @@ def reinit_data(self):
# establish connection to application database.
Namespace.connect_all_dbs(self.db_conn, mibs.APPL_DB)
self.loc_chassis_data = Namespace.dbs_get_all(self.db_conn, mibs.APPL_DB, mibs.LOC_CHASSIS_TABLE)
self.loc_chassis_data['lldp_loc_sys_cap_supported'] = parse_sys_capability(self.loc_chassis_data['lldp_loc_sys_cap_supported'])
self.loc_chassis_data['lldp_loc_sys_cap_enabled'] = parse_sys_capability(self.loc_chassis_data['lldp_loc_sys_cap_enabled'])
if self.loc_chassis_data:
self.loc_chassis_data['lldp_loc_sys_cap_supported'] = parse_sys_capability(self.loc_chassis_data['lldp_loc_sys_cap_supported'])
self.loc_chassis_data['lldp_loc_sys_cap_enabled'] = parse_sys_capability(self.loc_chassis_data['lldp_loc_sys_cap_enabled'])

def update_data(self):
"""
Avoid NotImplementedError
Expand Down

0 comments on commit 3b72a6f

Please sign in to comment.