diff options
3 files changed, 11 insertions, 4 deletions
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 0000000..03168b7 --- /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 61cb4ad..bd7fd15 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 d284b66..d92efa2 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'", ] |