From 7e67f2a4a7902db1623453c83cb9606f9fc6f1f3 Mon Sep 17 00:00:00 2001 From: Andrew Edwards Date: Mon, 16 May 2022 08:01:44 -0500 Subject: [PATCH 1/2] Rm overmatching tacacs-server idemopotency rule for nxos This rule was an attempt at addressing idempotency in tacacs-server commands but is far too broad. A working solution would require comparing the ip address of the tacacs-server in the command between the generated and running config lines. There isn't a mechanism for this included in the project, yet. In the past, I have addressed these types of issues with a series of functions that fix up specific problems after the remedations config has been built. --- hier_config/options.py | 1 - tests/test_various.py | 26 ++++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 tests/test_various.py diff --git a/hier_config/options.py b/hier_config/options.py index f0cc4f9..f6239d7 100644 --- a/hier_config/options.py +++ b/hier_config/options.py @@ -350,7 +350,6 @@ "ip telnet source-interface", "ip tacacs source-interface", "logging source-interface", - "tacacs-server", ], "re_search": "^spanning-tree vlan ([\\d,-]+) priority", } diff --git a/tests/test_various.py b/tests/test_various.py new file mode 100644 index 0000000..f505a77 --- /dev/null +++ b/tests/test_various.py @@ -0,0 +1,26 @@ +from hier_config import HConfig, Host + + +def test_issue104() -> None: + running_config_raw = ( + "tacacs-server deadtime 3\n" "tacacs-server host 192.168.1.99 key 7 Test12345\n" + ) + generated_config_raw = ( + "tacacs-server host 192.168.1.98 key 0 Test135 timeout 3\n" + "tacacs-server host 192.168.100.98 key 0 test135 timeout 3\n" + ) + + host = Host(hostname="test", os="nxos") + running_config = HConfig(host=host) + running_config.load_from_string(running_config_raw) + generated_config = HConfig(host=host) + generated_config.load_from_string(generated_config_raw) + rem = running_config.config_to_get_to(generated_config) + expected_rem_lines = { + "no tacacs-server deadtime 3", + "no tacacs-server host 192.168.1.99 key 7 Test12345", + "tacacs-server host 192.168.1.98 key 0 Test135 timeout 3", + "tacacs-server host 192.168.100.98 key 0 test135 timeout 3", + } + rem_lines = {line.cisco_style_text() for line in rem.all_children()} + assert expected_rem_lines == rem_lines From 59cf1c9b3d122a7a5e71e2236cb1b19fb71ed754 Mon Sep 17 00:00:00 2001 From: Andrew Edwards Date: Mon, 16 May 2022 08:02:14 -0500 Subject: [PATCH 2/2] bump version and update email address --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index fc8f4ab..36660b6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,12 +1,12 @@ [tool.poetry] name = "hier-config" -version = "2.2.0" +version = "2.2.1" description = "A network configuration comparison tool, used to build remediation configurations." packages = [ { include="hier_config", from="."}, ] authors = [ - "Andrew Edwards ", + "Andrew Edwards ", "James Williams