Skip to content

Commit

Permalink
Fix PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
liuh-80 committed Aug 30, 2023
1 parent 2ac5432 commit 8f88ee2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/sonic_ax_impl/mibs/ietf/rfc3433.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ def reinit_data(self):
self.ent_phy_sensor_precision_map = {}
self.ent_phy_sensor_value_map = {}
self.ent_phy_sensor_oper_state_map = {}
self.broken_transceiver_info.clear()

transceiver_dom_encoded = Namespace.dbs_keys(self.statedb, mibs.STATE_DB, self.TRANSCEIVER_DOM_KEY_PATTERN)
if transceiver_dom_encoded:
Expand Down Expand Up @@ -423,18 +424,17 @@ def update_xcvr_dom_data(self):
in STATE_DB, skipping".format(transceiver_dom_entry))
continue

# skip RJ45 port
transceiver_info_entry_data = Namespace.dbs_get_all(self.statedb, mibs.STATE_DB, mibs.transceiver_info_table(interface))

if 'type' not in transceiver_info_entry_data:
# Only write error log once
if interface not in self.broken_transceiver_info:
mibs.logger.error(
mibs.logger.warn(
"Invalid interface {} in STATE_DB, \
attribute 'type' missing in transceiver_info '{}'".format(interface, transceiver_info_entry_data))
self.broken_transceiver_info.append(interface)
continue

# skip RJ45 port
if transceiver_info_entry_data['type'] == RJ45_PORT_TYPE:
continue

Expand Down
4 changes: 2 additions & 2 deletions tests/test_rfc3433.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ def test_PhysicalSensorTableMIBUpdater_transceiver_info_key_missing(self):
updater = PhysicalSensorTableMIBUpdater()
updater.transceiver_dom.append("TRANSCEIVER_INFO|Ethernet0")

with mock.patch('sonic_ax_impl.mibs.logger.error') as mocked_error:
with mock.patch('sonic_ax_impl.mibs.logger.warn') as mocked_warn:
updater.update_data()

# check warning
mocked_error.assert_called()
mocked_warn.assert_called()

self.assertTrue(len(updater.sub_ids) == 0)

0 comments on commit 8f88ee2

Please sign in to comment.