summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@opensourcerouting.org>2017-05-18 12:15:04 +0200
committerDavid Lamparter <equinox@opensourcerouting.org>2017-05-18 12:23:13 +0200
commit92eedda1fb1b9c9fb2c31153677a033bee4573d3 (patch)
treed99e2aa0ac3346dc20c766026e717cf69b0abbbb /tools
parentMerge branch 'frr/pull/548' ("Pim dev 3.0 defect fixes") (diff)
parentPre-revert nonmergeable changes (diff)
downloadfrr-92eedda1fb1b9c9fb2c31153677a033bee4573d3.tar.xz
frr-92eedda1fb1b9c9fb2c31153677a033bee4573d3.zip
Merge branch stable/2.0 into stable/3.0
Conflicts: bgpd/bgp_fsm.c ospf6d/ospf6_lsa.c ospfd/ospf_vty.c zebra/redistribute.c Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'tools')
-rwxr-xr-xtools/frr-reload.py56
1 files changed, 47 insertions, 9 deletions
diff --git a/tools/frr-reload.py b/tools/frr-reload.py
index c91392da1..a7a04be63 100755
--- a/tools/frr-reload.py
+++ b/tools/frr-reload.py
@@ -109,9 +109,12 @@ class Config(object):
log.info('Loading Config object from file %s', filename)
try:
- file_output = subprocess.check_output(['/usr/bin/vtysh', '-m', '-f', filename])
+ file_output = subprocess.check_output(['/usr/bin/vtysh', '-m', '-f', filename],
+ stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as e:
- raise VtyshMarkException(str(e))
+ ve = VtyshMarkException(e)
+ ve.output = e.output
+ raise ve
for line in file_output.split('\n'):
line = line.strip()
@@ -134,9 +137,11 @@ class Config(object):
try:
config_text = subprocess.check_output(
"/usr/bin/vtysh -c 'show run' | /usr/bin/tail -n +4 | /usr/bin/vtysh -m -f -",
- shell=True)
+ shell=True, stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as e:
- raise VtyshMarkException(str(e))
+ ve = VtyshMarkException(e)
+ ve.output = e.output
+ raise ve
for line in config_text.split('\n'):
line = line.strip()
@@ -342,10 +347,12 @@ end
# the keywords that we know are single line contexts. bgp in this case
# is not the main router bgp block, but enabling multi-instance
oneline_ctx_keywords = ("access-list ",
+ "agentx",
"bgp ",
"debug ",
"dump ",
"enable ",
+ "frr ",
"hostname ",
"ip ",
"ipv6 ",
@@ -815,6 +822,14 @@ def compare_context_objects(newconf, running):
elif "router bgp" in running_ctx_keys[0] and len(running_ctx_keys) > 1 and delete_bgpd:
continue
+ elif ("router bgp" in running_ctx_keys[0] and
+ len(running_ctx_keys) > 1 and
+ running_ctx_keys[1].startswith('address-family')):
+ # There's no 'no address-family' support and so we have to
+ # delete each line individually again
+ for line in running_ctx.lines:
+ lines_to_del.append((running_ctx_keys, line))
+
# Non-global context
elif running_ctx_keys and not any("address-family" in key for key in running_ctx_keys):
lines_to_del.append((running_ctx_keys, None))
@@ -890,11 +905,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
@@ -911,7 +930,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:
@@ -922,6 +943,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:
@@ -1064,7 +1086,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:
@@ -1099,9 +1121,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)