Skip to content

Commit

Permalink
[route_maps] Enable handling of route-maps without set/match (#856)
Browse files Browse the repository at this point in the history
* Enable handling of route-maps without set/match

This commit introduces the ability to handle simple route-maps
that do not contain set or match statements.

Specifically, it allows for the creation and management of
purely basic route-map entries like 'route-map test-1 permit 10'.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Add changelogs

* Fix ansible-lint error

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Nilashish Chakraborty <nilashishchakraborty8@gmail.com>
  • Loading branch information
3 people authored May 22, 2024
1 parent 649abdf commit 0a2659d
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 0 deletions.
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))

0 comments on commit 0a2659d

Please sign in to comment.