From b05a1d3c030dce184b3cc011113458697dbe738d Mon Sep 17 00:00:00 2001 From: Daniel Walton Date: Fri, 10 Nov 2017 18:30:25 +0000 Subject: [PATCH] tools: frr-reload do not attempt deleting lines that cannot be deleted Signed-off-by: Daniel Walton 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 | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) 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) -- 2.39.5