From 0b9bb2b12c3c68aab273bc11488f21ca7395e455 Mon Sep 17 00:00:00 2001 From: Prince Sunny Date: Thu, 26 Apr 2018 15:10:09 -0700 Subject: [PATCH] Stop services before pushing new config during "load_minigraph" (#247) * Stop sonic services before pushing new config * Address comments. Stop service during config reload --- config/main.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/config/main.py b/config/main.py index e3bb8af6bee1..61cf9445714b 100755 --- a/config/main.py +++ b/config/main.py @@ -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) @@ -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] @@ -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]