]> git.puffer.fish Git - matthieu/frr.git/commitdiff
tools: quagga-reload should raise Exception instead of exiting
authorDaniel Walton <dwalton@cumulusnetworks.com>
Tue, 27 Sep 2016 15:56:36 +0000 (15:56 +0000)
committerDaniel Walton <dwalton@cumulusnetworks.com>
Tue, 27 Sep 2016 15:56:36 +0000 (15:56 +0000)
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com>
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.

tools/quagga-reload.py

index 900ed55c43ac0c745309f0192629aa70dee42af0..ed36b940a9e8cc5bbf76731120741af165702678 100755 (executable)
@@ -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()