Skip to content

Commit

Permalink
Stop services before pushing new config during "load_minigraph" (soni…
Browse files Browse the repository at this point in the history
…c-net#247)

* Stop sonic services before pushing new config
* Address comments. Stop service during config reload
  • Loading branch information
prsunny authored and lguohan committed Apr 27, 2018
1 parent dc119c9 commit 0b9bb2b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,15 @@ def _abort_if_false(ctx, param, value):
if not value:
ctx.abort()

def _stop_services():
run_command("service dhcp_relay stop", display_cmd=True)
run_command("service swss stop", display_cmd=True)
run_command("service snmp stop", display_cmd=True)
run_command("service lldp stop", display_cmd=True)
run_command("service pmon stop", display_cmd=True)
run_command("service bgp stop", display_cmd=True)
run_command("service teamd stop", display_cmd=True)

def _restart_services():
run_command("service hostname-config restart", display_cmd=True)
run_command("service interfaces-config restart", display_cmd=True)
Expand Down Expand Up @@ -186,6 +195,8 @@ def load(filename):
@click.argument('filename', default='/etc/sonic/config_db.json', type=click.Path(exists=True))
def reload(filename):
"""Clear current configuration and import a previous saved config DB dump file."""
#Stop services before config push
_stop_services()
config_db = ConfigDBConnector()
config_db.connect()
client = config_db.redis_clients[config_db.CONFIG_DB]
Expand Down Expand Up @@ -224,6 +235,9 @@ def load_mgmt_config(filename):
expose_value=False, prompt='Reload config from minigraph?')
def load_minigraph():
"""Reconfigure based on minigraph."""
#Stop services before config push
_stop_services()

config_db = ConfigDBConnector()
config_db.connect()
client = config_db.redis_clients[config_db.CONFIG_DB]
Expand Down

0 comments on commit 0b9bb2b

Please sign in to comment.