]> git.puffer.fish Git - mirror/frr.git/commitdiff
tools: frr-reload do not attempt deleting lines that cannot be deleted 1437/head
authorDaniel Walton <dwalton@cumulusnetworks.com>
Fri, 10 Nov 2017 18:30:25 +0000 (18:30 +0000)
committerDaniel Walton <dwalton@cumulusnetworks.com>
Fri, 10 Nov 2017 18:30:25 +0000 (18:30 +0000)
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

tools/frr-reload.py

index fd46cc214389800e8f2804f9d58d07f3952e74f9..2c651ffbd52c410ee0b6105fb50859ed5fdb2659 100755 (executable)
@@ -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)