]> git.puffer.fish Git - mirror/frr.git/commitdiff
tools: frr-reload.py should exit(1) if vtysh config mode is locked 1262/head
authorDaniel Walton <dwalton@cumulusnetworks.com>
Wed, 27 Sep 2017 18:47:47 +0000 (18:47 +0000)
committerDaniel Walton <dwalton@cumulusnetworks.com>
Wed, 27 Sep 2017 18:47:47 +0000 (18:47 +0000)
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
tools/frr-reload.py

index afe66b6eafea5e818d937abc172eb767f1fda4ad..e19eeb04eea305d96b0ea11ff603afd050844bcc 100755 (executable)
@@ -940,6 +940,32 @@ def compare_context_objects(newconf, running):
     return (lines_to_add, lines_to_del)
 
 
+
+def vtysh_config_available():
+    """
+    Return False if no frr daemon is running or some other vtysh session is
+    in 'configuration terminal' mode which will prevent us from making any
+    configuration changes.
+    """
+
+    try:
+        cmd = ['/usr/bin/vtysh', '-c', 'conf t']
+        output = subprocess.check_output(cmd, stderr=subprocess.STDOUT).strip()
+
+        if 'VTY configuration is locked by other VTY' in output:
+            print output
+            log.error("'%s' returned\n%s\n" % (' '.join(cmd), output))
+            return False
+
+    except subprocess.CalledProcessError as e:
+        msg = "vtysh could not connect with any frr daemons"
+        print msg
+        log.error(msg)
+        return False
+
+    return True
+
+
 if __name__ == '__main__':
     # Command line options
     parser = argparse.ArgumentParser(description='Dynamically apply diff in frr configs')
@@ -1060,6 +1086,10 @@ if __name__ == '__main__':
 
     elif args.reload:
 
+        # We will not be able to do anything, go ahead and exit(1)
+        if not vtysh_config_available():
+            sys.exit(1)
+
         log.debug('New Frr Config\n%s', newconf.get_lines())
 
         # This looks a little odd but we have to do this twice...here is why