From 86b6d04c3d00e93e391bdbc1c7788789a9d4c8fe Mon Sep 17 00:00:00 2001 From: Björn Hemfjäll <25451914+bgh88@users.noreply.github.com> Date: Tue, 22 Jun 2021 23:51:01 +0200 Subject: static route fixes (#165) static route fixes Reviewed-by: https://github.com/apps/ansible-zuul --- changelogs/fragments/fix_static_routes_next_hop_interface.yaml | 3 +++ .../network/vyos/config/static_routes/static_routes.py | 4 ++-- tests/unit/modules/network/vyos/test_vyos_static_routes.py | 8 ++++++-- 3 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 changelogs/fragments/fix_static_routes_next_hop_interface.yaml diff --git a/changelogs/fragments/fix_static_routes_next_hop_interface.yaml b/changelogs/fragments/fix_static_routes_next_hop_interface.yaml new file mode 100644 index 00000000..03168b71 --- /dev/null +++ b/changelogs/fragments/fix_static_routes_next_hop_interface.yaml @@ -0,0 +1,3 @@ +--- +bugfixes: + - change interface to next-hop-interface while generating static_routes nexthop command. diff --git a/plugins/module_utils/network/vyos/config/static_routes/static_routes.py b/plugins/module_utils/network/vyos/config/static_routes/static_routes.py index 61cb4ad5..bd7fd15e 100644 --- a/plugins/module_utils/network/vyos/config/static_routes/static_routes.py +++ b/plugins/module_utils/network/vyos/config/static_routes/static_routes.py @@ -375,7 +375,7 @@ class Static_routes(ConfigBase): key="next-hop", attrib=hop["forward_router_address"] + " " - + element, + + "next-hop-interface", value=hop[element], opr=opr, ) @@ -482,7 +482,7 @@ class Static_routes(ConfigBase): key="next-hop", attrib=hop["forward_router_address"] + " " - + element, + + "next-hop-interface", value=hop[element], remove=True, ) diff --git a/tests/unit/modules/network/vyos/test_vyos_static_routes.py b/tests/unit/modules/network/vyos/test_vyos_static_routes.py index d284b660..d92efa26 100644 --- a/tests/unit/modules/network/vyos/test_vyos_static_routes.py +++ b/tests/unit/modules/network/vyos/test_vyos_static_routes.py @@ -94,7 +94,8 @@ class TestVyosStaticRoutesModule(TestVyosModule): admin_distance=10, ), dict( - forward_router_address="192.0.2.10" + forward_router_address="192.0.2.10", + interface="eth0", ), ], ) @@ -111,6 +112,7 @@ class TestVyosStaticRoutesModule(TestVyosModule): "set protocols static route 192.0.2.48/28 next-hop '192.0.2.9'", "set protocols static route 192.0.2.48/28 next-hop 192.0.2.9 distance '10'", "set protocols static route 192.0.2.48/28 next-hop '192.0.2.10'", + "set protocols static route 192.0.2.48/28 next-hop 192.0.2.10 next-hop-interface 'eth0'", ] self.execute_module(changed=True, commands=commands) @@ -157,7 +159,8 @@ class TestVyosStaticRoutesModule(TestVyosModule): dest="192.0.2.48/28", next_hops=[ dict( - forward_router_address="192.0.2.9" + forward_router_address="192.0.2.9", + interface="eth0", ), dict( forward_router_address="192.0.2.10", @@ -176,6 +179,7 @@ class TestVyosStaticRoutesModule(TestVyosModule): commands = [ "set protocols static route 192.0.2.48/28", "set protocols static route 192.0.2.48/28 next-hop '192.0.2.9'", + "set protocols static route 192.0.2.48/28 next-hop 192.0.2.9 next-hop-interface 'eth0'", "set protocols static route 192.0.2.48/28 next-hop '192.0.2.10'", "set protocols static route 192.0.2.48/28 next-hop 192.0.2.10 distance '10'", ] -- cgit v1.2.3