mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-02 13:23:44 +00:00
tools: frr-reload.py should exit non-zero when "set src x.x.x.x" fails
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com> Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
parent
9b938b384c
commit
825be4c27b
@ -346,6 +346,7 @@ end
|
||||
"debug ",
|
||||
"dump ",
|
||||
"enable ",
|
||||
"frr ",
|
||||
"hostname ",
|
||||
"ip ",
|
||||
"ipv6 ",
|
||||
@ -888,11 +889,15 @@ if __name__ == '__main__':
|
||||
|
||||
# Verify the new config file is valid
|
||||
if not os.path.isfile(args.filename):
|
||||
print "Filename %s does not exist" % args.filename
|
||||
msg = "Filename %s does not exist" % args.filename
|
||||
print msg
|
||||
log.error(msg)
|
||||
sys.exit(1)
|
||||
|
||||
if not os.path.getsize(args.filename):
|
||||
print "Filename %s is an empty file" % args.filename
|
||||
msg = "Filename %s is an empty file" % args.filename
|
||||
print msg
|
||||
log.error(msg)
|
||||
sys.exit(1)
|
||||
|
||||
# Verify that 'service integrated-vtysh-config' is configured
|
||||
@ -909,7 +914,9 @@ if __name__ == '__main__':
|
||||
break
|
||||
|
||||
if not service_integrated_vtysh_config:
|
||||
print "'service integrated-vtysh-config' is not configured, this is required for 'service frr reload'"
|
||||
msg = "'service integrated-vtysh-config' is not configured, this is required for 'service frr reload'"
|
||||
print msg
|
||||
log.error(msg)
|
||||
sys.exit(1)
|
||||
|
||||
if args.debug:
|
||||
@ -920,6 +927,7 @@ if __name__ == '__main__':
|
||||
# Create a Config object from the config generated by newconf
|
||||
newconf = Config()
|
||||
newconf.load_from_file(args.filename)
|
||||
reload_ok = True
|
||||
|
||||
if args.test:
|
||||
|
||||
@ -1029,7 +1037,7 @@ if __name__ == '__main__':
|
||||
# 'no ip ospf authentication message-digest 1.1.1.1' in
|
||||
# our example above
|
||||
# - Split that last entry by whitespace and drop the last word
|
||||
log.warning('Failed to execute %s', ' '.join(cmd))
|
||||
log.info('Failed to execute %s', ' '.join(cmd))
|
||||
last_arg = cmd[-1].split(' ')
|
||||
|
||||
if len(last_arg) <= 2:
|
||||
@ -1064,9 +1072,25 @@ if __name__ == '__main__':
|
||||
with open(filename, 'w') as fh:
|
||||
for line in lines_to_configure:
|
||||
fh.write(line + '\n')
|
||||
subprocess.call(['/usr/bin/vtysh', '-f', filename])
|
||||
|
||||
output = subprocess.check_output(['/usr/bin/vtysh', '-f', filename])
|
||||
|
||||
# exit non-zero if we see these errors
|
||||
for x in ('BGP instance name and AS number mismatch',
|
||||
'BGP instance is already running',
|
||||
'% not a local address'):
|
||||
for line in output.splitlines():
|
||||
if x in line:
|
||||
msg = "ERROR: %s" % x
|
||||
log.error(msg)
|
||||
print msg
|
||||
reload_ok = False
|
||||
|
||||
os.unlink(filename)
|
||||
|
||||
# Make these changes persistent
|
||||
if args.overwrite or args.filename != '/etc/frr/frr.conf':
|
||||
subprocess.call(['/usr/bin/vtysh', '-c', 'write'])
|
||||
|
||||
if not reload_ok:
|
||||
sys.exit(1)
|
||||
|
@ -635,7 +635,7 @@ vtysh_mark_file (const char *filename)
|
||||
}
|
||||
}
|
||||
/* This is the end */
|
||||
fprintf(stdout, "end\n");
|
||||
fprintf(stdout, "\nend\n");
|
||||
vty_close(vty);
|
||||
XFREE(MTYPE_VTYSH_CMD, vty_buf_copy);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user