diff --git a/src/sonic_ax_impl/mibs/ietf/rfc1213.py b/src/sonic_ax_impl/mibs/ietf/rfc1213.py index 812cb21078a8..6e410ea79870 100644 --- a/src/sonic_ax_impl/mibs/ietf/rfc1213.py +++ b/src/sonic_ax_impl/mibs/ietf/rfc1213.py @@ -262,8 +262,9 @@ def update_if_counters(self): namespace, sai_id = mibs.split_sai_id_key(sai_id_key) if_idx = mibs.get_index_from_str(self.if_id_map[sai_id_key]) counters_db_data = self.namespace_db_map[namespace].get_all(mibs.COUNTERS_DB, - mibs.counter_table(sai_id), - blocking=True) + mibs.counter_table(sai_id)) + if counters_db_data is None: + counters_db_data = {} self.if_counters[if_idx] = { counter: int(value) for counter, value in counters_db_data.items() } @@ -272,8 +273,9 @@ def update_rif_counters(self): rif_sai_ids = list(self.rif_port_map) + list(self.vlan_name_map) for sai_id in rif_sai_ids: counters_db_data = Namespace.dbs_get_all(self.db_conn, mibs.COUNTERS_DB, - mibs.counter_table(mibs.split_sai_id_key(sai_id)[1]), - blocking=False) + mibs.counter_table(mibs.split_sai_id_key(sai_id)[1])) + if counters_db_data is None: + counters_db_data = {} self.rif_counters[sai_id] = { counter: int(value) for counter, value in counters_db_data.items() } @@ -358,8 +360,8 @@ def aggregate_counters(self): port_idx = mibs.get_index_from_str(self.if_id_map[port_sai_id]) for port_counter_name, rif_counter_name in mibs.RIF_DROPS_AGGR_MAP.items(): self.if_counters[port_idx][port_counter_name] = \ - self.if_counters[port_idx][port_counter_name] + \ - self.rif_counters[rif_sai_id][rif_counter_name] + self.if_counters[port_idx].get(port_counter_name, 0) + \ + self.rif_counters[rif_sai_id].get(rif_counter_name, 0) for vlan_sai_id, vlan_name in self.vlan_name_map.items(): for port_counter_name, rif_counter_name in mibs.RIF_COUNTERS_AGGR_MAP.items(): diff --git a/src/sonic_ax_impl/mibs/ietf/rfc2863.py b/src/sonic_ax_impl/mibs/ietf/rfc2863.py index e4f8c8a0ffc5..96d6bf3e4410 100644 --- a/src/sonic_ax_impl/mibs/ietf/rfc2863.py +++ b/src/sonic_ax_impl/mibs/ietf/rfc2863.py @@ -145,8 +145,11 @@ def update_data(self): for sai_id_key in self.if_id_map: namespace, sai_id = mibs.split_sai_id_key(sai_id_key) if_idx = mibs.get_index_from_str(self.if_id_map[sai_id_key]) - self.if_counters[if_idx] = self.namespace_db_map[namespace].get_all(mibs.COUNTERS_DB, \ - mibs.counter_table(sai_id), blocking=True) + counter_table = self.namespace_db_map[namespace].get_all(mibs.COUNTERS_DB, \ + mibs.counter_table(sai_id)) + if counter_table is None: + counter_table = {} + self.if_counters[if_idx] = counter_table self.lag_name_if_name_map, \ self.if_name_lag_name_map, \ diff --git a/src/sonic_ax_impl/mibs/vendor/cisco/ciscoPfcExtMIB.py b/src/sonic_ax_impl/mibs/vendor/cisco/ciscoPfcExtMIB.py index 51acc8fe462a..c2630d322513 100644 --- a/src/sonic_ax_impl/mibs/vendor/cisco/ciscoPfcExtMIB.py +++ b/src/sonic_ax_impl/mibs/vendor/cisco/ciscoPfcExtMIB.py @@ -47,8 +47,12 @@ def update_data(self): for sai_id_key in self.if_id_map: namespace, sai_id = mibs.split_sai_id_key(sai_id_key) if_idx = mibs.get_index_from_str(self.if_id_map[sai_id_key]) - self.if_counters[if_idx] = self.namespace_db_map[namespace].get_all(mibs.COUNTERS_DB, \ - mibs.counter_table(sai_id), blocking=True) + counter_table = self.namespace_db_map[namespace].get_all(mibs.COUNTERS_DB, \ + mibs.counter_table(sai_id)) + if counter_table is None: + counter_table = {} + self.if_counters[if_idx] = counter_table + self.lag_name_if_name_map, \ self.if_name_lag_name_map, \ diff --git a/tests/mock_tables/counters_db.json b/tests/mock_tables/counters_db.json index 6914ffa42428..a120b8a61fe9 100755 --- a/tests/mock_tables/counters_db.json +++ b/tests/mock_tables/counters_db.json @@ -203,108 +203,6 @@ "SAI_PORT_STAT_PFC_7_RX_PKTS": "8", "SAI_PORT_STAT_PFC_7_TX_PKTS": "8" }, - "COUNTERS:oid:0x1000000000020": { - "SAI_PORT_STAT_ETHER_STATS_TX_NO_ERRORS": "0", - "SAI_PORT_STAT_ETHER_STATS_OVERSIZE_PKTS": "0", - "SAI_PORT_STAT_IF_OUT_ERRORS": "0", - "SAI_PORT_STAT_ETHER_TX_OVERSIZE_PKTS": "0", - "SAI_PORT_STAT_ETHER_STATS_PKTS_1519_TO_2047_OCTETS": "0", - "SAI_PORT_STAT_IP_IN_RECEIVES": "0", - "SAI_PORT_STAT_ETHER_IN_PKTS_64_OCTETS": "0", - "SAI_PORT_STAT_IPV6_OUT_UCAST_PKTS": "0", - "SAI_PORT_STAT_ETHER_OUT_PKTS_4096_TO_9216_OCTETS": "0", - "SAI_PORT_STAT_IF_IN_ERRORS": "0", - "SAI_PORT_STAT_ETHER_STATS_PKTS": "0", - "SAI_PORT_STAT_ETHER_STATS_BROADCAST_PKTS": "0", - "SAI_PORT_STAT_IF_IN_DISCARDS": "0", - "SAI_PORT_STAT_IP_OUT_DISCARDS": "0", - "SAI_PORT_STAT_IF_IN_UNKNOWN_PROTOS": "0", - "SAI_PORT_STAT_IPV6_IN_DISCARDS": "0", - "SAI_PORT_STAT_IPV6_OUT_DISCARDS": "0", - "SAI_PORT_STAT_IPV6_IN_OCTETS": "0", - "SAI_PORT_STAT_ETHER_OUT_PKTS_65_TO_127_OCTETS": "0", - "SAI_PORT_STAT_IF_IN_BROADCAST_PKTS": "0", - "SAI_PORT_STAT_ETHER_IN_PKTS_1519_TO_2047_OCTETS": "0", - "SAI_PORT_STAT_IF_OUT_MULTICAST_PKTS": "0", - "SAI_PORT_STAT_ETHER_OUT_PKTS_512_TO_1023_OCTETS": "0", - "SAI_PORT_STAT_ETHER_STATS_PKTS_256_TO_511_OCTETS": "0", - "SAI_PORT_STAT_ETHER_STATS_PKTS_9217_TO_16383_OCTETS": "0", - "SAI_PORT_STAT_ETHER_IN_PKTS_512_TO_1023_OCTETS": "0", - "SAI_PORT_STAT_IPV6_IN_NON_UCAST_PKTS": "0", - "SAI_PORT_STAT_ETHER_IN_PKTS_4096_TO_9216_OCTETS": "0", - "SAI_PORT_STAT_IF_OUT_BROADCAST_PKTS": "0", - "SAI_PORT_STAT_IPV6_OUT_NON_UCAST_PKTS": "0", - "SAI_PORT_STAT_IF_IN_VLAN_DISCARDS": "0", - "SAI_PORT_STAT_ETHER_IN_PKTS_65_TO_127_OCTETS": "0", - "SAI_PORT_STAT_IP_IN_NON_UCAST_PKTS": "0", - "SAI_PORT_STAT_ETHER_STATS_FRAGMENTS": "0", - "SAI_PORT_STAT_IPV6_IN_UCAST_PKTS": "0", - "SAI_PORT_STAT_IPV6_IN_RECEIVES": "0", - "SAI_PORT_STAT_ETHER_STATS_PKTS_4096_TO_9216_OCTETS": "0", - "SAI_PORT_STAT_IF_OUT_DISCARDS": "0", - "SAI_PORT_STAT_ETHER_STATS_DROP_EVENTS": "0", - "SAI_PORT_STAT_IPV6_OUT_MCAST_PKTS": "0", - "SAI_PORT_STAT_ETHER_RX_OVERSIZE_PKTS": "0", - "SAI_PORT_STAT_IF_OUT_OCTETS": "0", - "SAI_PORT_STAT_IF_IN_NON_UCAST_PKTS": "0", - "SAI_PORT_STAT_ETHER_IN_PKTS_9217_TO_16383_OCTETS": "0", - "SAI_PORT_STAT_ETHER_OUT_PKTS_1024_TO_1518_OCTETS": "0", - "SAI_PORT_STAT_ETHER_STATS_PKTS_2048_TO_4095_OCTETS": "0", - "SAI_PORT_STAT_ETHER_STATS_PKTS_512_TO_1023_OCTETS": "0", - "SAI_PORT_STAT_ETHER_OUT_PKTS_1519_TO_2047_OCTETS": "0", - "SAI_PORT_STAT_ETHER_STATS_RX_NO_ERRORS": "0", - "SAI_PORT_STAT_ETHER_OUT_PKTS_64_OCTETS": "0", - "SAI_PORT_STAT_ETHER_STATS_COLLISIONS": "0", - "SAI_PORT_STAT_ETHER_IN_PKTS_1024_TO_1518_OCTETS": "0", - "SAI_PORT_STAT_ETHER_STATS_PKTS_1024_TO_1518_OCTETS": "0", - "SAI_PORT_STAT_ETHER_IN_PKTS_256_TO_511_OCTETS": "0", - "SAI_PORT_STAT_ETHER_OUT_PKTS_2048_TO_4095_OCTETS": "0", - "SAI_PORT_STAT_ETHER_STATS_OCTETS": "0", - "SAI_PORT_STAT_IF_OUT_UCAST_PKTS": "0", - "SAI_PORT_STAT_ETHER_STATS_UNDERSIZE_PKTS": "0", - "SAI_PORT_STAT_ETHER_OUT_PKTS_128_TO_255_OCTETS": "0", - "SAI_PORT_STAT_ETHER_STATS_PKTS_64_OCTETS": "0", - "SAI_PORT_STAT_IP_OUT_OCTETS": "0", - "SAI_PORT_STAT_IF_IN_UCAST_PKTS": "0", - "SAI_PORT_STAT_ETHER_OUT_PKTS_9217_TO_16383_OCTETS": "0", - "SAI_PORT_STAT_ETHER_IN_PKTS_2048_TO_4095_OCTETS": "0", - "SAI_PORT_STAT_IP_OUT_NON_UCAST_PKTS": "0", - "SAI_PORT_STAT_ETHER_STATS_JABBERS": "0", - "SAI_PORT_STAT_IF_IN_OCTETS": "0", - "SAI_PORT_STAT_IPV6_IN_MCAST_PKTS": "0", - "SAI_PORT_STAT_ETHER_STATS_PKTS_65_TO_127_OCTETS": "0", - "SAI_PORT_STAT_IF_OUT_QLEN": "0", - "SAI_PORT_STAT_ETHER_STATS_PKTS_128_TO_255_OCTETS": "0", - "SAI_PORT_STAT_IP_IN_DISCARDS": "0", - "SAI_PORT_STAT_IPV6_OUT_OCTETS": "0", - "SAI_PORT_STAT_IF_OUT_NON_UCAST_PKTS": "0", - "SAI_PORT_STAT_IP_IN_OCTETS": "0", - "SAI_PORT_STAT_ETHER_OUT_PKTS_256_TO_511_OCTETS": "0", - "SAI_PORT_STAT_ETHER_STATS_CRC_ALIGN_ERRORS": "0", - "SAI_PORT_STAT_IP_OUT_UCAST_PKTS": "0", - "SAI_PORT_STAT_IP_IN_UCAST_PKTS": "0", - "SAI_PORT_STAT_ETHER_STATS_MULTICAST_PKTS": "0", - "SAI_PORT_STAT_ETHER_IN_PKTS_128_TO_255_OCTETS": "0", - "SAI_PORT_STAT_IF_IN_MULTICAST_PKTS": "0", - "SAI_PORT_STAT_PAUSE_RX_PKTS": "0", - "SAI_PORT_STAT_PAUSE_TX_PKTS": "0", - "SAI_PORT_STAT_PFC_0_RX_PKTS": "1", - "SAI_PORT_STAT_PFC_0_TX_PKTS": "1", - "SAI_PORT_STAT_PFC_1_RX_PKTS": "2", - "SAI_PORT_STAT_PFC_1_TX_PKTS": "2", - "SAI_PORT_STAT_PFC_2_RX_PKTS": "3", - "SAI_PORT_STAT_PFC_2_TX_PKTS": "3", - "SAI_PORT_STAT_PFC_3_RX_PKTS": "4", - "SAI_PORT_STAT_PFC_3_TX_PKTS": "4", - "SAI_PORT_STAT_PFC_4_RX_PKTS": "5", - "SAI_PORT_STAT_PFC_4_TX_PKTS": "5", - "SAI_PORT_STAT_PFC_5_RX_PKTS": "6", - "SAI_PORT_STAT_PFC_5_TX_PKTS": "6", - "SAI_PORT_STAT_PFC_6_RX_PKTS": "7", - "SAI_PORT_STAT_PFC_6_TX_PKTS": "7", - "SAI_PORT_STAT_PFC_7_RX_PKTS": "8", - "SAI_PORT_STAT_PFC_7_TX_PKTS": "8" - }, "COUNTERS:oid:0x1000000000021": { "SAI_PORT_STAT_ETHER_STATS_TX_NO_ERRORS": "0", "SAI_PORT_STAT_ETHER_STATS_OVERSIZE_PKTS": "0", diff --git a/tests/mock_tables/dbconnector.py b/tests/mock_tables/dbconnector.py index 84ce65e7b7fd..e6a30e6606de 100644 --- a/tests/mock_tables/dbconnector.py +++ b/tests/mock_tables/dbconnector.py @@ -65,7 +65,7 @@ def connect_SonicV2Connector(self, db_name, retry_on=True): _old_connect_SonicV2Connector(self, db_name, retry_on) -def _subscribe_keyspace_notification(self, db_name, client): +def _subscribe_keyspace_notification(self, db_name): pass