mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-06-07 18:50:00 +00:00
Merge pull request #1262 from dwalton76/vtysh-conft-available2
tools: frr-reload.py should exit(1) if vtysh config mode is locked
This commit is contained in:
commit
09045d298d
@ -940,6 +940,32 @@ def compare_context_objects(newconf, running):
|
|||||||
return (lines_to_add, lines_to_del)
|
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__':
|
if __name__ == '__main__':
|
||||||
# Command line options
|
# Command line options
|
||||||
parser = argparse.ArgumentParser(description='Dynamically apply diff in frr configs')
|
parser = argparse.ArgumentParser(description='Dynamically apply diff in frr configs')
|
||||||
@ -1060,6 +1086,10 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
elif args.reload:
|
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())
|
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
|
# This looks a little odd but we have to do this twice...here is why
|
||||||
|
Loading…
Reference in New Issue
Block a user