Skip to content

Commit

Permalink
load db config in sonic-cfggen as suggested in pr review
Browse files Browse the repository at this point in the history
to avoid loading db config in library like portconfig.py.

Signed-off-by: Suvarna Meenakshi <sumeenak@microsoft.com>
  • Loading branch information
SuvarnaMeenakshi committed Apr 15, 2022
1 parent 8fa9878 commit 8f26eb9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 0 additions & 5 deletions src/sonic-config-engine/portconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions src/sonic-config-engine/sonic-cfggen
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8f26eb9

Please sign in to comment.