From 306c9cf311b7311e0eeda2b37ada6d341813ab75 Mon Sep 17 00:00:00 2001 From: Sangita Maity Date: Fri, 6 Dec 2019 01:28:41 +0000 Subject: [PATCH] Refractored portconfig to be used by breakout CLI subcommand Signed-off-by: Sangita Maity --- src/sonic-config-engine/portconfig.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/sonic-config-engine/portconfig.py b/src/sonic-config-engine/portconfig.py index 427ee0e500db..183e9517211c 100644 --- a/src/sonic-config-engine/portconfig.py +++ b/src/sonic-config-engine/portconfig.py @@ -17,7 +17,7 @@ HWSKU_ROOT_PATH = '/usr/share/sonic/hwsku' PLATFORM_JSON = 'platform.json' -PORT_CONFIG_INI = 'portconfig.ini' +PORT_CONFIG_INI = 'port_config.ini' PORT_STR = "Ethernet" BRKOUT_MODE = "default_brkout_mode" @@ -33,8 +33,7 @@ def db_connect_configdb(): return None try: config_db.connect() - except Exception as e: - print("Config DB is not available with error {}".format(str(e))) + except: config_db = None return config_db @@ -204,10 +203,17 @@ def parse_platform_json_file(port_config_file, interface_name=None, target_brkou if match_list is not None: offset = 0 parent_intf_id = int(re.search("Ethernet(\d+)", intf).group(1)) + + if interface_name is not None and interface_name == intf: + ports = {} + for k in match_list: # k is a tuple in "match_list" offset = gen_port_config(ports, parent_intf_id, index, alias_at_lanes, lanes, k, offset) brkout_mode = None + + if interface_name is not None and interface_name == intf: + return ports else: raise Exception("match_list should not be None.") if not ports: