From 8d62b1417ee85862a85454f635168e5e3fcf682d Mon Sep 17 00:00:00 2001 From: Daniel Walton Date: Tue, 27 Sep 2016 15:56:36 +0000 Subject: [PATCH] tools: quagga-reload should raise Exception instead of exiting Signed-off-by: Daniel Walton Reviewed-by: Donald Sharp NCLU imports quagga-reload.py and uses its Config class to parse Quagga.conf. The Config class will call 'vtysh -m -f Quagga.conf" and if that exited with an error Config would call sys.exit(1) which in my cases causes the NCLU daemon to exit which is bad. The fix is to have the Config class raise an exception instead of exiting, then NCLU can catch the exception, log it and move on. (cherry picked from commit 276887bb1c2961fa37b42ce7160346f1417577a8) --- tools/quagga-reload.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/quagga-reload.py b/tools/quagga-reload.py index 900ed55c43..ed36b940a9 100755 --- a/tools/quagga-reload.py +++ b/tools/quagga-reload.py @@ -26,6 +26,10 @@ from pprint import pformat log = logging.getLogger(__name__) +class VtyshMarkException(Exception): + pass + + class Context(object): """ @@ -88,9 +92,7 @@ class Config(object): try: file_output = subprocess.check_output(['/usr/bin/vtysh', '-m', '-f', filename]) except subprocess.CalledProcessError as e: - log.error('vtysh marking of config file %s failed with error %s:', filename, str(e)) - print "vtysh marking of file %s failed with error: %s" % (filename, str(e)) - sys.exit(1) + raise VtyshMarkException(str(e)) for line in file_output.split('\n'): line = line.strip() @@ -115,9 +117,7 @@ class Config(object): "/usr/bin/vtysh -c 'show run' | /usr/bin/tail -n +4 | /usr/bin/vtysh -m -f -", shell=True) except subprocess.CalledProcessError as e: - log.error('vtysh marking of running config failed with error %s:', str(e)) - print "vtysh marking of running config failed with error %s:" % (str(e)) - sys.exit(1) + raise VtyshMarkException(str(e)) for line in config_text.split('\n'): line = line.strip() -- 2.39.5