diff --git a/changelogs/fragments/route_maps.yaml b/changelogs/fragments/route_maps.yaml new file mode 100644 index 000000000..b02073095 --- /dev/null +++ b/changelogs/fragments/route_maps.yaml @@ -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'." diff --git a/plugins/module_utils/network/nxos/config/route_maps/route_maps.py b/plugins/module_utils/network/nxos/config/route_maps/route_maps.py index fa7d57b1b..77f8f02be 100644 --- a/plugins/module_utils/network/nxos/config/route_maps/route_maps.py +++ b/plugins/module_utils/network/nxos/config/route_maps/route_maps.py @@ -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", diff --git a/tests/unit/modules/network/nxos/test_nxos_route_maps.py b/tests/unit/modules/network/nxos/test_nxos_route_maps.py index d247c02b4..45a64775e 100644 --- a/tests/unit/modules/network/nxos/test_nxos_route_maps.py +++ b/tests/unit/modules/network/nxos/test_nxos_route_maps.py @@ -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))