Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes ios default interface idempotent options #114

Merged
merged 1 commit into from
Sep 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions hier_config/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,8 @@
],
"idempotent_commands": [
{"lineage": [{"startswith": "vlan"}, {"startswith": "name"}]},
{
"lineage": [
{"startswith": "interface"},
{"startswith": ["description", "ip address"]},
]
},
{"lineage": [{"startswith": "interface"}, {"startswith": "description"}]},
{"lineage": [{"startswith": "interface"}, {"startswith": "ip address"}]},
],
}
iosxe_options: dict = {
Expand Down
7 changes: 4 additions & 3 deletions tests/fixtures/options_ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,10 @@ idempotent_commands:
- startswith: name
- lineage:
- startswith: interface
- startswith:
- description
- ip address
- startswith: description
- lineage:
- startswith: interface
- startswith: ip address

# Default when expression: list of expressions
negation_default_when: []
Expand Down
27 changes: 27 additions & 0 deletions tests/test_various.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,30 @@ def test_issue104() -> None:
}
rem_lines = {line.cisco_style_text() for line in rem.all_children()}
assert expected_rem_lines == rem_lines


def test_issue_113() -> None:
running_config_raw = (
"interface Ethernet1/1\n"
" description test\n"
" ip address 192.0.2.1 255.255.255.0\n"
" switchport\n"
)
generated_config_raw = (
"interface Ethernet1/1\n"
" ip address 192.0.2.1 255.255.255.0\n"
" switchport\n"
)

host = Host(hostname="test", os="ios")
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 = {
"interface Ethernet1/1",
" no description test",
}
rem_lines = {line.cisco_style_text() for line in rem.all_children()}
assert expected_rem_lines == rem_lines
Loading