summaryrefslogtreecommitdiff
path: root/tools/frr-reload.py
diff options
context:
space:
mode:
authorDaniel Walton <dwalton@cumulusnetworks.com>2017-11-10 18:30:25 +0000
committerDaniel Walton <dwalton@cumulusnetworks.com>2017-11-10 18:30:25 +0000
commitb05a1d3c030dce184b3cc011113458697dbe738d (patch)
tree0100b7ae6ddfddae5b9e74591a41e6a514b9271e /tools/frr-reload.py
parent4c76e59220604af526cb9d78f1d9ca72c393e918 (diff)
tools: frr-reload do not attempt deleting lines that cannot be deleted
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com> There are several lines that we cannot do a "no" on - frr version - frr defaults - password - line vty frr-reload should ignore these if asked to do a "no" on them
Diffstat (limited to 'tools/frr-reload.py')
-rwxr-xr-xtools/frr-reload.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/tools/frr-reload.py b/tools/frr-reload.py
index fd46cc2143..2c651ffbd5 100755
--- a/tools/frr-reload.py
+++ b/tools/frr-reload.py
@@ -874,6 +874,34 @@ def ignore_delete_re_add_lines(lines_to_add, lines_to_del):
return (lines_to_add, lines_to_del)
+def ignore_unconfigurable_lines(lines_to_add, lines_to_del):
+ """
+ There are certain commands that cannot be removed. Remove
+ those commands from lines_to_del.
+ """
+ lines_to_del_to_del = []
+
+ for (ctx_keys, line) in lines_to_del:
+
+ if (ctx_keys[0].startswith('frr version') or
+ ctx_keys[0].startswith('frr defaults') or
+ ctx_keys[0].startswith('password') or
+ ctx_keys[0].startswith('line vty') or
+
+ # This is technically "no"able but if we did so frr-reload would
+ # stop working so do not let the user shoot themselves in the foot
+ # by removing this.
+ ctx_keys[0].startswith('service integrated-vtysh-config')):
+
+ log.info("(%s, %s) cannot be removed" % (pformat(ctx_keys), line))
+ lines_to_del_to_del.append((ctx_keys, line))
+
+ for (ctx_keys, line) in lines_to_del_to_del:
+ lines_to_del.remove((ctx_keys, line))
+
+ return (lines_to_add, lines_to_del)
+
+
def compare_context_objects(newconf, running):
"""
Create a context diff for the two specified contexts
@@ -959,6 +987,7 @@ def compare_context_objects(newconf, running):
lines_to_add.append((newconf_ctx_keys, line))
(lines_to_add, lines_to_del) = ignore_delete_re_add_lines(lines_to_add, lines_to_del)
+ (lines_to_add, lines_to_del) = ignore_unconfigurable_lines(lines_to_add, lines_to_del)
return (lines_to_add, lines_to_del)