Skip to content

Commit

Permalink
[config]: config reload needs to restart services (sonic-net#146)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikos-github authored and Shuotian Cheng committed Nov 14, 2017
1 parent e87bb97 commit a4087dd
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down Expand Up @@ -131,6 +143,12 @@ 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()

@cli.command()
@click.option('-y', '--yes', is_flag=True, callback=_abort_if_false,
Expand Down Expand Up @@ -177,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
Expand Down

0 comments on commit a4087dd

Please sign in to comment.