From c45ad992c62c98c745af443460807d83449794d5 Mon Sep 17 00:00:00 2001 From: yozhao101 <56170650+yozhao101@users.noreply.github.com> Date: Thu, 13 Feb 2020 14:22:20 -0800 Subject: [PATCH] [config/main.py] Modify reload() function to load configuration from init_cfg.json implicitly (#812) * [config/main.py] Modify the load() and reload() functions to load config from config_db.json and init_cfg.json. Signed-off-by: Yong Zhao * [config/main.py] Undo the changes which load the configuration from init_cfg.json for load() function and define a constant string for the path of init_cfg.json. Signed-off-by: Yong Zhao * [config/main.py] Correct a typo. Signed-off-by: Yong Zhao * [config/main.py] Added an else statement in line 551 to decide whether the init_cfg.json exsits or not in reload function. Signed-off-by: Yong Zhao * [config/main.py] Correct a typo error. Signed-off-by: Yong Zhao * [config/main.py] Change the loading order and we should first load init_cfg.json and then config_db.json. Signed-off-by: Yong Zhao * [config/main.py] Use constant string to represent the path of init_cfg.json. Signed-off-by: Yong Zhao --- config/main.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/config/main.py b/config/main.py index 8ef53a66b03f..0d9d134b1992 100755 --- a/config/main.py +++ b/config/main.py @@ -27,6 +27,8 @@ SYSLOG_IDENTIFIER = "config" VLAN_SUB_INTERFACE_SEPARATOR = '.' +INIT_CFG_FILE = '/etc/sonic/init_cfg.json' + # ========================== Syslog wrappers ========================== def log_debug(msg): @@ -544,7 +546,11 @@ def reload(filename, yes, load_sysinfo): command = "{} -H -k {} --write-to-db".format(SONIC_CFGGEN_PATH, cfg_hwsku) run_command(command, display_cmd=True) - command = "{} -j {} --write-to-db".format(SONIC_CFGGEN_PATH, filename) + if os.path.isfile(INIT_CFG_FILE): + command = "{} -j {} -j {} --write-to-db".format(SONIC_CFGGEN_PATH, INIT_CFG_FILE, filename) + else: + command = "{} -j {} --write-to-db".format(SONIC_CFGGEN_PATH, filename) + run_command(command, display_cmd=True) client.set(config_db.INIT_INDICATOR, 1)