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 <[email protected]>
  • Loading branch information
liorghub committed Jul 25, 2021
1 parent 40637b8 commit 90a2006
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions src/swsssdk/port_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,16 @@ def get_index_from_str(if_name):
if match:
return int(match.group(1)) + baseidx

def get_interface_oid_map(db):
def get_interface_oid_map(db, blocking=True):
"""
Get the Interface names from Counters DB
"""
if_name_map = {}
if_id_map = {}

db.connect('COUNTERS_DB')
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_name_map = db.get_all('COUNTERS_DB', 'COUNTERS_PORT_NAME_MAP', blocking)
if_lag_name_map = db.get_all('COUNTERS_DB', 'COUNTERS_LAG_NAME_MAP', blocking)
if_name_map.update(if_lag_name_map)

if not if_name_map:
if if_name_map == {}:
return {}, {}

oid_pfx = len("oid:0x")
Expand Down

0 comments on commit 90a2006

Please sign in to comment.