Revert "[portconfig]: Remove try block for db config initialization (#10581)" (#10756)

This reverts commit 5cd6bc4ce2.
This commit is contained in:
SuvarnaMeenakshi 2022-05-06 11:12:56 -07:00 committed by GitHub
parent 7104664c05
commit 66c96eaf4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 8 deletions

View File

@ -72,7 +72,12 @@ def db_connect_configdb(namespace=None):
"""
Connect to configdb
"""
config_db = swsscommon.ConfigDBConnector(use_unix_socket_path=True, namespace=namespace)
try:
if namespace is not None:
swsscommon.SonicDBConfig.load_sonic_global_db_config(namespace=namespace)
config_db = swsscommon.ConfigDBConnector(use_unix_socket_path=True, namespace=namespace)
except Exception as e:
return None
if config_db is None:
return None
try:

View File

@ -32,7 +32,7 @@ from functools import partial
from minigraph import minigraph_encoder, parse_xml, parse_device_desc_xml, parse_asic_sub_role, parse_asic_switch_type
from portconfig import get_port_config, get_breakout_mode
from redis_bcc import RedisBytecodeCache
from sonic_py_common.multi_asic import get_asic_id_from_name, get_asic_device_id, is_multi_asic
from sonic_py_common.multi_asic import get_asic_id_from_name, get_asic_device_id
from sonic_py_common import device_info
from swsscommon.swsscommon import SonicV2Connector, ConfigDBConnector, SonicDBConfig, ConfigDBPipeConnector
@ -296,12 +296,6 @@ def main():
'localhost': {'namespace_id': namespace_id}
}
})
# load db config
if not SonicDBConfig.isInit():
if is_multi_asic():
SonicDBConfig.load_sonic_global_db_config(namespace=asic_name)
else:
SonicDBConfig.load_sonic_db_config()
if hwsku is not None:
hardware_data = {'DEVICE_METADATA': {'localhost': {
'hwsku': hwsku