Skip to content

Commit

Permalink
[config/main.py] Modify reload() function to load configuration from …
Browse files Browse the repository at this point in the history
…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 <yozhao@microsoft.com>

* [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 <yozhao@microsoft.com>

* [config/main.py] Correct a typo.

Signed-off-by: Yong Zhao <yozhao@microsoft.com>

* [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 <yozhao@microsoft.com>

* [config/main.py] Correct a typo error.

Signed-off-by: Yong Zhao <yozhao@microsoft.com>

* [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 <yozhao@microsoft.com>

* [config/main.py] Use constant string to represent the path of
init_cfg.json.

Signed-off-by: Yong Zhao <yozhao@microsoft.com>
  • Loading branch information
yozhao101 committed Feb 13, 2020
1 parent a4385f0 commit c45ad99
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit c45ad99

Please sign in to comment.