From 4839a597d6df2a02a67288e6af071d90b07cd841 Mon Sep 17 00:00:00 2001 From: Taoyu Li Date: Wed, 22 Nov 2017 23:05:29 +0000 Subject: [PATCH 1/2] [config] Call hostname service to config hostname instead --- config/main.py | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/config/main.py b/config/main.py index ace8643b99..48dabbe537 100644 --- a/config/main.py +++ b/config/main.py @@ -94,6 +94,7 @@ def _abort_if_false(ctx, param, value): ctx.abort() def _restart_services(): + run_command("service hostname-config restart", display_cmd=True) run_command("service interfaces-config restart", display_cmd=True) run_command("service ntp-config restart", display_cmd=True) run_command("service rsyslog-config restart", display_cmd=True) @@ -143,12 +144,7 @@ def reload(filename): command = "{} -j {} --write-to-db".format(SONIC_CFGGEN_PATH, filename) run_command(command, display_cmd=True) client.set(config_db.INIT_INDICATOR, True) - command = "{} -j {} -v \"DEVICE_METADATA['localhost']['hostname']\"".format(SONIC_CFGGEN_PATH, filename) - p = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE) - p.wait() - hostname = p.communicate()[0].strip() - _change_hostname(hostname) - _restart_services() + _restart_services() @cli.command() @click.option('-y', '--yes', is_flag=True, callback=_abort_if_false, @@ -189,14 +185,10 @@ def load_minigraph(): command = "{} -m --write-to-db".format(SONIC_CFGGEN_PATH) run_command(command, display_cmd=True) client.set(config_db.INIT_INDICATOR, True) - command = "{} -m -v \"DEVICE_METADATA['localhost']['hostname']\"".format(SONIC_CFGGEN_PATH) - p = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE) - p.wait() - hostname = p.communicate()[0].strip() - _change_hostname(hostname) #FIXME: After config DB daemon is implemented, we'll no longer need to restart every service. _restart_services() print "Please note setting loaded from minigraph will be lost after system reboot. To preserve setting, run `config save`." + # # 'bgp' group # From 597bda89d469ab7adc734e6cc97590da1b046815 Mon Sep 17 00:00:00 2001 From: Taoyu Li Date: Wed, 22 Nov 2017 23:06:58 +0000 Subject: [PATCH 2/2] Fix typo --- config/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/main.py b/config/main.py index 48dabbe537..1e8fa1f30c 100644 --- a/config/main.py +++ b/config/main.py @@ -144,7 +144,7 @@ def reload(filename): command = "{} -j {} --write-to-db".format(SONIC_CFGGEN_PATH, filename) run_command(command, display_cmd=True) client.set(config_db.INIT_INDICATOR, True) - _restart_services() + _restart_services() @cli.command() @click.option('-y', '--yes', is_flag=True, callback=_abort_if_false,