Skip to content

Commit

Permalink
Remove usage of oid_sai_map data structure as it is not being used.
Browse files Browse the repository at this point in the history
The required data can be retrieved from oid_name_map data structure.

Signed-off-by: SuvarnaMeenakshi <sumeenak@microsoft.com>
  • Loading branch information
SuvarnaMeenakshi committed Aug 12, 2020
1 parent b0b7d02 commit 4d8cae2
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 29 deletions.
12 changes: 3 additions & 9 deletions src/sonic_ax_impl/mibs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,12 +245,6 @@ def init_sync_d_interface_tables(db_conn):
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))

# { OID -> sai_id }
oid_sai_map = {get_index(if_name): sai_id for if_name, sai_id in if_name_map.items()
# only map the interface if it's a style understood to be a SONiC interface.
if get_index(if_name) is not None}
logger.debug("OID sai map:\n" + pprint.pformat(oid_sai_map, indent=2))

# { OID -> if_name (SONiC) }
oid_name_map = {get_index(if_name): if_name for if_name in if_name_map
# only map the interface if it's a style understood to be a SONiC interface.
Expand All @@ -259,14 +253,14 @@ def init_sync_d_interface_tables(db_conn):
logger.debug("OID name map:\n" + pprint.pformat(oid_name_map, indent=2))

# SyncD consistency checks.
if not oid_sai_map:
if not oid_name_map:
# In the event no interface exists that follows the SONiC pattern, no OIDs are able to be registered.
# A RuntimeError here will prevent the 'main' module from loading. (This is desirable.)
message = "No interfaces found matching pattern '{}'. SyncD database is incoherent." \
.format(port_util.SONIC_ETHERNET_RE_PATTERN)
logger.error(message)
raise RuntimeError(message)
elif len(if_id_map) < len(if_name_map) or len(oid_sai_map) < len(if_name_map):
elif len(if_id_map) < len(if_name_map) or len(oid_name_map) < len(if_name_map):
# a length mismatch indicates a bad interface name
logger.warning("SyncD database contains incoherent interface names. Interfaces must match pattern '{}'"
.format(port_util.SONIC_ETHERNET_RE_PATTERN))
Expand All @@ -281,7 +275,7 @@ def init_sync_d_interface_tables(db_conn):

logger.debug("Chassis name map:\n" + pprint.pformat(if_alias_map, indent=2))

return if_name_map, if_alias_map, if_id_map, oid_sai_map, oid_name_map
return if_name_map, if_alias_map, if_id_map, oid_name_map

def init_sync_d_lag_tables(db_conn):
"""
Expand Down
6 changes: 1 addition & 5 deletions src/sonic_ax_impl/mibs/ieee802_1ab.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ def __init__(self):
self.if_name_map = {}
self.if_alias_map = {}
self.if_id_map = {}
self.oid_sai_map = {}
self.oid_name_map = {}

self.mgmt_oid_name_map = {}
Expand All @@ -165,7 +164,6 @@ def reinit_data(self):
self.if_name_map, \
self.if_alias_map, \
self.if_id_map, \
self.oid_sai_map, \
self.oid_name_map = Namespace.get_sync_d_from_all_namespace(mibs.init_sync_d_interface_tables, self.db_conn)

self.mgmt_oid_name_map, \
Expand Down Expand Up @@ -382,7 +380,6 @@ def __init__(self):
self.if_name_map = {}
self.if_alias_map = {}
self.if_id_map = {}
self.oid_sai_map = {}
self.oid_name_map = {}

self.mgmt_oid_name_map = {}
Expand All @@ -400,7 +397,6 @@ def reinit_data(self):
self.if_name_map, \
self.if_alias_map, \
self.if_id_map, \
self.oid_sai_map, \
self.oid_name_map = Namespace.get_sync_d_from_all_namespace(mibs.init_sync_d_interface_tables, self.db_conn)

self.mgmt_oid_name_map, _ = mibs.init_mgmt_interface_tables(self.db_conn[0])
Expand Down Expand Up @@ -566,7 +562,7 @@ def reinit_data(self):
"""
Subclass reinit data routine.
"""
_, _, _, _, self.oid_name_map = Namespace.get_sync_d_from_all_namespace(mibs.init_sync_d_interface_tables, self.db_conn)
_, _, _, self.oid_name_map = Namespace.get_sync_d_from_all_namespace(mibs.init_sync_d_interface_tables, self.db_conn)

self.mgmt_oid_name_map, _ = mibs.init_mgmt_interface_tables(self.db_conn[0])

Expand Down
4 changes: 1 addition & 3 deletions src/sonic_ax_impl/mibs/ietf/rfc1213.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ def __init__(self):
self.if_name_map = {}
self.if_alias_map = {}
self.if_id_map = {}
self.oid_sai_map = {}
self.oid_name_map = {}
self.namespace_db_map = Namespace.get_namespace_db_map(self.db_conn)

Expand All @@ -211,7 +210,6 @@ def reinit_data(self):
self.if_name_map, \
self.if_alias_map, \
self.if_id_map, \
self.oid_sai_map, \
self.oid_name_map = Namespace.get_sync_d_from_all_namespace(mibs.init_sync_d_interface_tables, self.db_conn)
"""
db_conn - will have db_conn to all namespace DBs and
Expand All @@ -236,7 +234,7 @@ def update_data(self):
self.if_name_lag_name_map, \
self.oid_lag_name_map = Namespace.get_sync_d_from_all_namespace(mibs.init_sync_d_lag_tables, self.db_conn)

self.if_range = sorted(list(self.oid_sai_map.keys()) +
self.if_range = sorted(list(self.oid_name_map.keys()) +
list(self.oid_lag_name_map.keys()) +
list(self.mgmt_oid_name_map.keys()))
self.if_range = [(i,) for i in self.if_range]
Expand Down
2 changes: 1 addition & 1 deletion src/sonic_ax_impl/mibs/ietf/rfc2737.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def reinit_data(self):
self.physical_model_name_map = {}

# update interface maps
_, self.if_alias_map, _, _, _ = \
_, self.if_alias_map, _, _ = \
Namespace.get_sync_d_from_all_namespace(mibs.init_sync_d_interface_tables, Namespace.init_namespace_dbs())

device_metadata = mibs.get_device_metadata(self.statedb[0])
Expand Down
4 changes: 1 addition & 3 deletions src/sonic_ax_impl/mibs/ietf/rfc2863.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ def __init__(self):
self.if_name_map = {}
self.if_alias_map = {}
self.if_id_map = {}
self.oid_sai_map = {}
self.oid_name_map = {}
self.lag_name_if_name_map = {}
self.if_name_lag_name_map = {}
Expand All @@ -76,7 +75,6 @@ def reinit_data(self):
self.if_name_map, \
self.if_alias_map, \
self.if_id_map, \
self.oid_sai_map, \
self.oid_name_map = Namespace.get_sync_d_from_all_namespace(mibs.init_sync_d_interface_tables, self.db_conn)

self.lag_name_if_name_map, \
Expand All @@ -90,7 +88,7 @@ def reinit_data(self):
self.mgmt_oid_name_map, \
self.mgmt_alias_map = mibs.init_mgmt_interface_tables(self.db_conn[0])

self.if_range = sorted(list(self.oid_sai_map.keys()) +
self.if_range = sorted(list(self.oid_name_map.keys()) +
list(self.oid_lag_name_map.keys()) +
list(self.mgmt_oid_name_map.keys()))
self.if_range = [(i,) for i in self.if_range]
Expand Down
2 changes: 0 additions & 2 deletions src/sonic_ax_impl/mibs/ietf/rfc4363.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ def __init__(self):
self.if_name_map = {}
self.if_alias_map = {}
self.if_id_map = {}
self.oid_sai_map = {}
self.oid_name_map = {}
self.vlanmac_ifindex_map = {}
self.vlanmac_ifindex_list = []
Expand All @@ -40,7 +39,6 @@ def reinit_data(self):
self.if_name_map, \
self.if_alias_map, \
self.if_id_map, \
self.oid_sai_map, \
self.oid_name_map = Namespace.get_sync_d_from_all_namespace(mibs.init_sync_d_interface_tables, self.db_conn)

self.if_bpid_map = Namespace.dbs_get_bridge_port_map(self.db_conn, mibs.ASIC_DB)
Expand Down
4 changes: 1 addition & 3 deletions src/sonic_ax_impl/mibs/vendor/cisco/ciscoPfcExtMIB.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ def __init__(self):
self.if_name_map = {}
self.if_alias_map = {}
self.if_id_map = {}
self.oid_sai_map = {}
self.oid_name_map = {}

self.lag_name_if_name_map = {}
Expand All @@ -36,7 +35,6 @@ def reinit_data(self):
self.if_name_map, \
self.if_alias_map, \
self.if_id_map, \
self.oid_sai_map, \
self.oid_name_map = Namespace.get_sync_d_from_all_namespace(mibs.init_sync_d_interface_tables, self.db_conn)

self.update_data()
Expand All @@ -56,7 +54,7 @@ def update_data(self):
self.if_name_lag_name_map, \
self.oid_lag_name_map = Namespace.get_sync_d_from_all_namespace(mibs.init_sync_d_lag_tables, self.db_conn)

self.if_range = sorted(list(self.oid_sai_map.keys()) + list(self.oid_lag_name_map.keys()))
self.if_range = sorted(list(self.oid_name_map.keys()) + list(self.oid_lag_name_map.keys()))
self.if_range = [(i,) for i in self.if_range]

def get_next(self, sub_id):
Expand Down
4 changes: 1 addition & 3 deletions src/sonic_ax_impl/mibs/vendor/cisco/ciscoSwitchQosMIB.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ def __init__(self):
self.if_name_map = {}
self.if_alias_map = {}
self.if_id_map = {}
self.oid_sai_map = {}
self.oid_name_map = {}

self.port_queues_map = {}
Expand All @@ -75,7 +74,6 @@ def reinit_data(self):
self.if_name_map, \
self.if_alias_map, \
self.if_id_map, \
self.oid_sai_map, \
self.oid_name_map = Namespace.get_sync_d_from_all_namespace(mibs.init_sync_d_interface_tables, self.db_conn)

for sai_id_key in self.if_id_map:
Expand Down Expand Up @@ -123,7 +121,7 @@ def update_stats(self):
self.mib_oid_list = []

# Sort the ports to keep the OID order in the MIB
if_range = list(self.oid_sai_map.keys())
if_range = list(self.oid_name_map.keys())
# Update queue counters for port
for if_index in if_range:
if if_index not in self.port_queue_list_map:
Expand Down

0 comments on commit 4d8cae2

Please sign in to comment.