diff --git a/src/sonic-config-engine/portconfig.py b/src/sonic-config-engine/portconfig.py index c1784cbc3b7f..89f87804c4b8 100644 --- a/src/sonic-config-engine/portconfig.py +++ b/src/sonic-config-engine/portconfig.py @@ -73,11 +73,6 @@ def db_connect_configdb(namespace=None): """ Connect to configdb """ - if not swsscommon.SonicDBConfig.isInit(): - if multi_asic.is_multi_asic(): - swsscommon.SonicDBConfig.load_sonic_global_db_config(namespace=namespace) - else: - swsscommon.SonicDBConfig.load_sonic_db_config() config_db = swsscommon.ConfigDBConnector(use_unix_socket_path=True, namespace=namespace) if config_db is None: return None diff --git a/src/sonic-config-engine/sonic-cfggen b/src/sonic-config-engine/sonic-cfggen index aebd4d0544f5..cbe6d29c117e 100755 --- a/src/sonic-config-engine/sonic-cfggen +++ b/src/sonic-config-engine/sonic-cfggen @@ -309,6 +309,12 @@ def main(): 'localhost': {'namespace_id': namespace_id} } }) + # load db config + if not swsscommon.SonicDBConfig.isInit(): + if multi_asic.is_multi_asic(): + swsscommon.SonicDBConfig.load_sonic_global_db_config(namespace=asic_name) + else: + swsscommon.SonicDBConfig.load_sonic_db_config() if hwsku is not None: hardware_data = {'DEVICE_METADATA': {'localhost': { 'hwsku': hwsku