diff options
author | Daniel Walton <dwalton@cumulusnetworks.com> | 2017-05-17 02:14:37 +0200 |
---|---|---|
committer | Daniel Walton <dwalton@cumulusnetworks.com> | 2017-05-17 02:14:37 +0200 |
commit | 825be4c27bc165e68ebcb1de8d1beebdbd8c82e9 (patch) | |
tree | 145b625364c77ad813ab2cbd2175f7d3ccca85f2 /tools | |
parent | Merge pull request #492 from dwalton76/stable/2.0 (diff) | |
download | frr-825be4c27bc165e68ebcb1de8d1beebdbd8c82e9.tar.xz frr-825be4c27bc165e68ebcb1de8d1beebdbd8c82e9.zip |
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>
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/frr-reload.py | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/tools/frr-reload.py b/tools/frr-reload.py index 80d2d6a2a..0e71eaa04 100755 --- a/tools/frr-reload.py +++ b/tools/frr-reload.py @@ -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) |