From 531eabfbaf56ffa3ec777b208a9a578e4c79ce41 Mon Sep 17 00:00:00 2001 From: Nikos Triantafillis Date: Mon, 6 Nov 2017 18:05:28 -0800 Subject: [PATCH 1/2] config reload needs to restart services --- config/main.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/config/main.py b/config/main.py index ed2f131298..57ed0a0e2f 100644 --- a/config/main.py +++ b/config/main.py @@ -131,6 +131,21 @@ 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) + 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) + run_command("service swss restart", display_cmd=True) + run_command("service bgp restart", display_cmd=True) + run_command("service teamd restart", display_cmd=True) + run_command("service pmon restart", display_cmd=True) + run_command("service lldp restart", display_cmd=True) + run_command("service snmp restart", display_cmd=True) + run_command("service dhcp_relay restart", display_cmd=True) @cli.command() @click.option('-y', '--yes', is_flag=True, callback=_abort_if_false, From caca60ea8b0950c9838962420d7fd9ee2b0a92fc Mon Sep 17 00:00:00 2001 From: Nikos Triantafillis Date: Wed, 8 Nov 2017 15:13:45 -0800 Subject: [PATCH 2/2] config reload needs to restart services --- config/main.py | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/config/main.py b/config/main.py index 57ed0a0e2f..ace8643b99 100644 --- a/config/main.py +++ b/config/main.py @@ -93,6 +93,18 @@ def _abort_if_false(ctx, param, value): if not value: ctx.abort() +def _restart_services(): + 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) + run_command("service swss restart", display_cmd=True) + run_command("service bgp restart", display_cmd=True) + run_command("service teamd restart", display_cmd=True) + run_command("service pmon restart", display_cmd=True) + run_command("service lldp restart", display_cmd=True) + run_command("service snmp restart", display_cmd=True) + run_command("service dhcp_relay restart", display_cmd=True) + # This is our main entrypoint - the main 'config' command @click.group() def cli(): @@ -136,16 +148,7 @@ def reload(filename): p.wait() hostname = p.communicate()[0].strip() _change_hostname(hostname) - 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) - run_command("service swss restart", display_cmd=True) - run_command("service bgp restart", display_cmd=True) - run_command("service teamd restart", display_cmd=True) - run_command("service pmon restart", display_cmd=True) - run_command("service lldp restart", display_cmd=True) - run_command("service snmp restart", display_cmd=True) - run_command("service dhcp_relay restart", display_cmd=True) + _restart_services() @cli.command() @click.option('-y', '--yes', is_flag=True, callback=_abort_if_false, @@ -192,16 +195,7 @@ def load_minigraph(): hostname = p.communicate()[0].strip() _change_hostname(hostname) #FIXME: After config DB daemon is implemented, we'll no longer need to restart every service. - 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) - run_command("service swss restart", display_cmd=True) - run_command("service bgp restart", display_cmd=True) - run_command("service teamd restart", display_cmd=True) - run_command("service pmon restart", display_cmd=True) - run_command("service lldp restart", display_cmd=True) - run_command("service snmp restart", display_cmd=True) - run_command("service dhcp_relay restart", display_cmd=True) + _restart_services() print "Please note setting loaded from minigraph will be lost after system reboot. To preserve setting, run `config save`." # # 'bgp' group