Skip to content

Commit c45ad99

Browse files
authored
[config/main.py] Modify reload() function to load configuration from init_cfg.json implicitly (sonic-net#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 <[email protected]> * [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 <[email protected]> * [config/main.py] Correct a typo. Signed-off-by: Yong Zhao <[email protected]> * [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 <[email protected]> * [config/main.py] Correct a typo error. Signed-off-by: Yong Zhao <[email protected]> * [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 <[email protected]> * [config/main.py] Use constant string to represent the path of init_cfg.json. Signed-off-by: Yong Zhao <[email protected]>
1 parent a4385f0 commit c45ad99

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

config/main.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
SYSLOG_IDENTIFIER = "config"
2828
VLAN_SUB_INTERFACE_SEPARATOR = '.'
2929

30+
INIT_CFG_FILE = '/etc/sonic/init_cfg.json'
31+
3032
# ========================== Syslog wrappers ==========================
3133

3234
def log_debug(msg):
@@ -544,7 +546,11 @@ def reload(filename, yes, load_sysinfo):
544546
command = "{} -H -k {} --write-to-db".format(SONIC_CFGGEN_PATH, cfg_hwsku)
545547
run_command(command, display_cmd=True)
546548

547-
command = "{} -j {} --write-to-db".format(SONIC_CFGGEN_PATH, filename)
549+
if os.path.isfile(INIT_CFG_FILE):
550+
command = "{} -j {} -j {} --write-to-db".format(SONIC_CFGGEN_PATH, INIT_CFG_FILE, filename)
551+
else:
552+
command = "{} -j {} --write-to-db".format(SONIC_CFGGEN_PATH, filename)
553+
548554
run_command(command, display_cmd=True)
549555
client.set(config_db.INIT_INDICATOR, 1)
550556

0 commit comments

Comments
 (0)