From 57f53b2b3cc139e3ee5570f6f69b9a1f5c2ed308 Mon Sep 17 00:00:00 2001 From: liora Date: Sun, 13 Jun 2021 02:41:33 +0000 Subject: [PATCH] [port_util] Allow system with no ports in config db run without errors Signed-off-by: liora --- src/swsssdk/port_util.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/swsssdk/port_util.py b/src/swsssdk/port_util.py index 742f334f..4a1c1ab2 100644 --- a/src/swsssdk/port_util.py +++ b/src/swsssdk/port_util.py @@ -57,20 +57,14 @@ 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: return {}, {}