From 7b66e0d9b3a51e4318d1a9b62b094225c9c5c22a Mon Sep 17 00:00:00 2001 From: Shu0T1an ChenG Date: Mon, 20 Aug 2018 12:15:39 -0700 Subject: [PATCH] [config]: Add file check before load_minigraph command This will prevent config load_minigraph fail during the middle of the command execution. Signed-off-by: Shu0T1an ChenG --- config/main.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/config/main.py b/config/main.py index 7ce6cae9bf..775c39b3d1 100755 --- a/config/main.py +++ b/config/main.py @@ -15,6 +15,7 @@ import mlnx SONIC_CFGGEN_PATH = "sonic-cfggen" +SONIC_MINIGRAPH_PATH = "/etc/sonic/minigraph.xml" # # Helper functions @@ -321,7 +322,11 @@ 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 + # Check /etc/sonic/minigraph.xml file exists + if not os.path.isfile(SONIC_MINIGRAPH_PATH): + exit("No minigraph.xml file found under folder /etc/sonic") + + # Stop services before config push _stop_services() config_db = ConfigDBConnector()