diff --git a/scripts/vnet_route_check.py b/scripts/vnet_route_check.py index d925427d40..c747bf7efb 100755 --- a/scripts/vnet_route_check.py +++ b/scripts/vnet_route_check.py @@ -74,7 +74,7 @@ def print_message(lvl, *args): def check_vnet_cfg(): ''' Returns True if VNET is configured in APP_DB or False if no VNET configuration. ''' - db = swsscommon.DBConnector('APPL_DB', 0) + db = swsscommon.DBConnector('APPL_DB', 0, True) vnet_db_keys = swsscommon.Table(db, 'VNET_TABLE').getKeys() @@ -85,7 +85,7 @@ def get_vnet_intfs(): ''' Returns dictionary of VNETs and related VNET interfaces. Format: { : [ ] } ''' - db = swsscommon.DBConnector('APPL_DB', 0) + db = swsscommon.DBConnector('APPL_DB', 0, True) intfs_table = swsscommon.Table(db, 'INTF_TABLE') intfs_keys = swsscommon.Table(db, 'INTF_TABLE').getKeys() @@ -109,7 +109,7 @@ def get_all_rifs_oids(): ''' Returns dictionary of all router interfaces and their OIDs. Format: { : } ''' - db = swsscommon.DBConnector('COUNTERS_DB', 0) + db = swsscommon.DBConnector('COUNTERS_DB', 0, True) rif_table = swsscommon.Table(db, 'COUNTERS_RIF_NAME_MAP') rif_name_oid_map = dict(rif_table.get('')[1]) @@ -140,7 +140,7 @@ def get_vrf_entries(): ''' Returns dictionary of VNET interfaces and corresponding VRF OIDs. Format: { : } ''' - db = swsscommon.DBConnector('ASIC_DB', 0) + db = swsscommon.DBConnector('ASIC_DB', 0, True) rif_table = swsscommon.Table(db, 'ASIC_STATE') vnet_rifs_oids = get_vnet_rifs_oids() @@ -162,7 +162,7 @@ def filter_out_vnet_ip2me_routes(vnet_routes): ''' Filters out IP2ME routes from the provided dictionary with VNET routes Format: { : { 'routes': [ ], 'vrf_oid': } } ''' - db = swsscommon.DBConnector('APPL_DB', 0) + db = swsscommon.DBConnector('APPL_DB', 0, True) all_rifs_db_keys = swsscommon.Table(db, 'INTF_TABLE').getKeys() vnet_intfs = get_vnet_intfs() @@ -198,7 +198,7 @@ def get_vnet_routes_from_app_db(): ''' Returns dictionary of VNET routes configured per each VNET in APP_DB. Format: { : { 'routes': [ ], 'vrf_oid': } } ''' - db = swsscommon.DBConnector('APPL_DB', 0) + db = swsscommon.DBConnector('APPL_DB', 0, True) vnet_intfs = get_vnet_intfs() vnet_vrfs = get_vrf_entries() @@ -245,7 +245,7 @@ def get_vnet_routes_from_asic_db(): ''' Returns dictionary of VNET routes configured per each VNET in ASIC_DB. Format: { : { 'routes': [ ], 'vrf_oid': } } ''' - db = swsscommon.DBConnector('ASIC_DB', 0) + db = swsscommon.DBConnector('ASIC_DB', 0, True) tbl = swsscommon.Table(db, 'ASIC_STATE') @@ -363,7 +363,7 @@ def main(): # Don't run VNET routes consistancy logic if there is no VNET configuration if not check_vnet_cfg(): return rc - asic_db = swsscommon.DBConnector('ASIC_DB', 0) + asic_db = swsscommon.DBConnector('ASIC_DB', 0, True) virtual_router = swsscommon.Table(asic_db, 'ASIC_STATE:SAI_OBJECT_TYPE_VIRTUAL_ROUTER') if virtual_router.getKeys() != []: global default_vrf_oid diff --git a/tests/vnet_route_check_test.py b/tests/vnet_route_check_test.py index 092a89e2f9..10d97f21a3 100644 --- a/tests/vnet_route_check_test.py +++ b/tests/vnet_route_check_test.py @@ -341,7 +341,9 @@ def get(self, key): db_conns = {"APPL_DB": APPL_DB, "ASIC_DB": ASIC_DB, "COUNTERS_DB": CNTR_DB} -def conn_side_effect(arg, _): + + +def conn_side_effect(arg, _, __): return db_conns[arg]