summaryrefslogtreecommitdiffstats
path: root/tools/frr-reload.py
diff options
context:
space:
mode:
authorDaniel Walton <dwalton@cumulusnetworks.com>2017-09-27 20:47:47 +0200
committerDaniel Walton <dwalton@cumulusnetworks.com>2017-09-27 20:47:47 +0200
commit2f52ad9627a9e585dcc486b396ca0afe6ca6cb1a (patch)
tree59ec89ea06a223f5a49f1eb95cd6e2b16701d117 /tools/frr-reload.py
parentMerge pull request #1180 from dwalton76/ipv6-static-route-null0 (diff)
downloadfrr-2f52ad9627a9e585dcc486b396ca0afe6ca6cb1a.tar.xz
frr-2f52ad9627a9e585dcc486b396ca0afe6ca6cb1a.zip
tools: frr-reload.py should exit(1) if vtysh config mode is locked
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
Diffstat (limited to 'tools/frr-reload.py')
-rwxr-xr-xtools/frr-reload.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/tools/frr-reload.py b/tools/frr-reload.py
index afe66b6ea..e19eeb04e 100755
--- a/tools/frr-reload.py
+++ b/tools/frr-reload.py
@@ -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