From b7d73787c33f048c292c5779772653c42cac4a85 Mon Sep 17 00:00:00 2001 From: anilkpandey <47642449+anilkpandey@users.noreply.github.com> Date: Thu, 26 Sep 2019 15:36:02 -0700 Subject: [PATCH 1/3] add mock tables for LAG_NAME_MAP_TABLE in COUNTERS_DB --- tests/mock_tables/counters_db.json | 105 +++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) diff --git a/tests/mock_tables/counters_db.json b/tests/mock_tables/counters_db.json index 8aba20750..6f6b3092d 100644 --- a/tests/mock_tables/counters_db.json +++ b/tests/mock_tables/counters_db.json @@ -509,6 +509,108 @@ "SAI_PORT_STAT_PFC_7_RX_PKTS": "8", "SAI_PORT_STAT_PFC_7_TX_PKTS": "8" }, + "COUNTERS:oid:0x1000000000023": { + "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:0x100000000000f": { "SAI_PORT_STAT_ETHER_STATS_TX_NO_ERRORS": "0", "SAI_PORT_STAT_ETHER_STATS_OVERSIZE_PKTS": "0", @@ -2175,6 +2277,9 @@ "Ethernet20": "oid:0x1000000000015", "Ethernet68": "oid:0x1000000000020" }, + "COUNTERS_LAG_NAME_MAP": { + "PortChannel0": "oid:0x1000000000023" + }, "COUNTERS:oid:0x1000000000009": { "SAI_PORT_STAT_ETHER_STATS_TX_NO_ERRORS": "0", "SAI_PORT_STAT_ETHER_STATS_OVERSIZE_PKTS": "0", From 6efe63f1c72015e53ff4a384d01d47a9e57063ab Mon Sep 17 00:00:00 2001 From: Qi Luo Date: Sun, 12 Apr 2020 19:16:40 +0000 Subject: [PATCH 2/3] Fix init_sync_d_interface_tables(): only return ports and no portchannels --- src/sonic_ax_impl/mibs/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/sonic_ax_impl/mibs/__init__.py b/src/sonic_ax_impl/mibs/__init__.py index 0a8bd685f..7e199644c 100644 --- a/src/sonic_ax_impl/mibs/__init__.py +++ b/src/sonic_ax_impl/mibs/__init__.py @@ -183,6 +183,7 @@ def init_mgmt_interface_tables(db_conn): return oid_name_map, if_alias_map +# TODO: the function name include interface, but only return port by design. Fix the design or the name def init_sync_d_interface_tables(db_conn): """ Initializes interface maps for SyncD-connected MIB(s). @@ -195,6 +196,9 @@ def init_sync_d_interface_tables(db_conn): # { if_name (SONiC) -> sai_id } # ex: { "Ethernet76" : "1000000000023" } if_name_map, if_id_map = port_util.get_interface_oid_map(db_conn) + if_name_map = {if_name: sai_id for if_name, sai_id in if_name_map.items() if re.match(port_util.SONIC_ETHERNET_RE_PATTERN, if_name.decode())} + if_id_map = {sai_id: if_name for sai_id, if_name in if_id_map.items() if re.match(port_util.SONIC_ETHERNET_RE_PATTERN, if_name.decode())} + logger.debug("Port name map:\n" + pprint.pformat(if_name_map, indent=2)) logger.debug("Interface name map:\n" + pprint.pformat(if_id_map, indent=2)) From fa1f4f84cfa5bb701dfe4b38bbe41d5096081d39 Mon Sep 17 00:00:00 2001 From: Qi Luo Date: Sun, 12 Apr 2020 19:17:48 +0000 Subject: [PATCH 3/3] Fix mock_tables: counters_db portchannel name follows app_db --- tests/mock_tables/counters_db.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/mock_tables/counters_db.json b/tests/mock_tables/counters_db.json index 6f6b3092d..0ec1fa1c7 100644 --- a/tests/mock_tables/counters_db.json +++ b/tests/mock_tables/counters_db.json @@ -2278,7 +2278,7 @@ "Ethernet68": "oid:0x1000000000020" }, "COUNTERS_LAG_NAME_MAP": { - "PortChannel0": "oid:0x1000000000023" + "PortChannel01": "oid:0x1000000000023" }, "COUNTERS:oid:0x1000000000009": { "SAI_PORT_STAT_ETHER_STATS_TX_NO_ERRORS": "0",