Skip to content

Commit

Permalink
[port_util] Allow system with no ports in config db run without errors
Browse files Browse the repository at this point in the history
Signed-off-by: liora <liora@nvidia.com>
  • Loading branch information
liorghub committed Jun 13, 2021
1 parent 6e42d58 commit 40637b8
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/swsssdk/port_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,19 @@ def get_interface_oid_map(db):
"""
Get the Interface names from Counters DB
"""
if_name_map = {}
if_id_map = {}

db.connect('COUNTERS_DB')
if_name_map = db.get_all('COUNTERS_DB', 'COUNTERS_PORT_NAME_MAP', blocking=True)
if_lag_name_map = db.get_all('COUNTERS_DB', 'COUNTERS_LAG_NAME_MAP', blocking=True)
if_name_map.update(if_lag_name_map)
if db.exists('COUNTERS_DB', 'COUNTERS_PORT_NAME_MAP'):
if_name_map = db.get_all('COUNTERS_DB', 'COUNTERS_PORT_NAME_MAP', blocking=True)

if db.exists('COUNTERS_DB', 'COUNTERS_LAG_NAME_MAP'):
if_lag_name_map = db.get_all('COUNTERS_DB', 'COUNTERS_LAG_NAME_MAP', blocking=True)
if_name_map.update(if_lag_name_map)

if not if_name_map:
return {}, {}

oid_pfx = len("oid:0x")
if_name_map = {if_name: sai_oid[oid_pfx:] for if_name, sai_oid in if_name_map.items()}
Expand Down

0 comments on commit 40637b8

Please sign in to comment.