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

[route_maps] Enable handling of route-maps without set/match #856

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
4 changes: 4 additions & 0 deletions changelogs/fragments/route_maps.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
minor_changes:
- "route_maps - support simple route-maps that do not contain set or match statements.
it allows for the creation and management of purely basic route-map entries like 'route-map test-1 permit 10'."
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def __init__(self, module):
tmplt=Route_mapsTemplate(),
)
self.linear_parsers = [
"route_map",
"description",
"continue_sequence",
"set.as_path.prepend.last_as",
Expand Down
89 changes: 89 additions & 0 deletions tests/unit/modules/network/nxos/test_nxos_route_maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -1493,3 +1493,92 @@ def test_nxos_route_maps_extcomm_rt(self):
]
result = self.execute_module(changed=True)
self.assertEqual(set(result["commands"]), set(commands))

def test_nxos_route_maps_without_match_and_set_merged(self):
self.get_config.return_value = dedent(
"""\
route-map test-1 permit 10
""",
)
set_module_args(
dict(
config=[
dict(
route_map="test-1",
entries=[
dict(
action="permit",
sequence=20,
),
],
),
],
state="merged",
),
)
commands = [
"route-map test-1 permit 20",
]
result = self.execute_module(changed=True)
self.assertEqual(set(result["commands"]), set(commands))

def test_nxos_route_maps_without_match_and_set_overridden(self):
self.get_config.return_value = dedent(
"""\
route-map test-1 permit 10
""",
)
set_module_args(
dict(
config=[
dict(
route_map="test-2",
entries=[
dict(
action="permit",
sequence=10,
),
],
),
],
state="overridden",
),
)
commands = [
"no route-map test-1 permit 10",
"route-map test-2 permit 10",
]
result = self.execute_module(changed=True)
self.assertEqual(set(result["commands"]), set(commands))

def test_nxos_route_maps_without_match_and_set_replaced(self):
self.get_config.return_value = dedent(
"""\
route-map test-1 permit 10
route-map test-1 permit 20
route-map test-2 permit 10
""",
)
set_module_args(
dict(
config=[
dict(
route_map="test-1",
entries=[
dict(
action="permit",
sequence=30,
),
],
),
],
state="replaced",
),
)
commands = [
"no route-map test-1 permit 10",
"no route-map test-1 permit 20",
"route-map test-1 permit 30",
]
result = self.execute_module(changed=True)
self.assertEqual(set(result["commands"]), set(commands))
Loading