[portconfig]: Remove try exception during config_db initialization. (#10960)
Why I did it Provide fix for comment: https://github.com/Azure/sonic-buildimage/pull/10475/files#r847753187; Move laoding database config to application code instead of portconfig as portconfig is used as a library. #10581 was raised for this fix, but had to be reverted due to issue with multi-asic platform. How I did it Remove try exception handing from portconfig.py during config_db intialization. Move loading of database config to application that uses portconfig.py. How to verify it unit-test passes. Verified that it does not cause issue during boot up of multi-asic VS image. Verified that config_db generation was successful in multi-asic VS.
This commit is contained in:
parent
a07765ffea
commit
77ad3ff19d
@ -72,12 +72,7 @@ def db_connect_configdb(namespace=None):
|
||||
"""
|
||||
Connect to configdb
|
||||
"""
|
||||
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
|
||||
config_db = swsscommon.ConfigDBConnector(use_unix_socket_path=True, namespace=namespace)
|
||||
if config_db is None:
|
||||
return None
|
||||
try:
|
||||
|
@ -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
|
||||
from sonic_py_common.multi_asic import get_asic_id_from_name, get_asic_device_id, is_multi_asic
|
||||
from sonic_py_common import device_info
|
||||
from swsscommon.swsscommon import SonicV2Connector, ConfigDBConnector, SonicDBConfig, ConfigDBPipeConnector
|
||||
|
||||
@ -138,6 +138,13 @@ def ip_network(value):
|
||||
return "Invalid ip address %s" % value
|
||||
return r_v.network
|
||||
|
||||
def load_namespace_config(asic_name):
|
||||
if not SonicDBConfig.isInit():
|
||||
if is_multi_asic():
|
||||
SonicDBConfig.load_sonic_global_db_config(namespace=asic_name)
|
||||
else:
|
||||
SonicDBConfig.load_sonic_db_config()
|
||||
|
||||
class FormatConverter:
|
||||
"""Convert config DB based schema to legacy minigraph based schema for backward capability.
|
||||
We will move to DB schema and remove this class when the config templates are modified.
|
||||
@ -303,6 +310,7 @@ def main():
|
||||
deep_update(data, hardware_data)
|
||||
if args.port_config is None:
|
||||
args.port_config = device_info.get_path_to_port_config_file(hwsku)
|
||||
load_namespace_config(asic_name)
|
||||
(ports, _, _) = get_port_config(hwsku, platform, args.port_config, asic_id)
|
||||
if ports is None:
|
||||
print('Failed to get port config', file=sys.stderr)
|
||||
@ -328,6 +336,7 @@ def main():
|
||||
|
||||
if args.minigraph is not None:
|
||||
minigraph = args.minigraph
|
||||
load_namespace_config(asic_name)
|
||||
if platform:
|
||||
if args.port_config is not None:
|
||||
deep_update(data, parse_xml(minigraph, platform, args.port_config, asic_name=asic_name, hwsku_config_file=args.hwsku_config))
|
||||
|
Loading…
Reference in New Issue
Block a user