summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--changelogs/fragments/fix_static_routes_distance.yaml3
-rw-r--r--plugins/module_utils/network/vyos/config/static_routes/static_routes.py13
-rw-r--r--tests/unit/modules/network/vyos/test_vyos_static_routes.py8
3 files changed, 13 insertions, 11 deletions
diff --git a/changelogs/fragments/fix_static_routes_distance.yaml b/changelogs/fragments/fix_static_routes_distance.yaml
new file mode 100644
index 0000000..97caa18
--- /dev/null
+++ b/changelogs/fragments/fix_static_routes_distance.yaml
@@ -0,0 +1,3 @@
+---
+bugfixes:
+ - change admin_distance to distance 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 f1d4f38..61cb4ad 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
@@ -40,14 +40,9 @@ class Static_routes(ConfigBase):
The vyos_static_routes class
"""
- gather_subset = [
- "!all",
- "!min",
- ]
+ gather_subset = ["!all", "!min"]
- gather_network_resources = [
- "static_routes",
- ]
+ gather_network_resources = ["static_routes"]
def __init__(self, module):
super(Static_routes, self).__init__(module)
@@ -368,7 +363,7 @@ class Static_routes(ConfigBase):
key="next-hop",
attrib=hop["forward_router_address"]
+ " "
- + element,
+ + "distance",
value=str(hop[element]),
opr=opr,
)
@@ -475,7 +470,7 @@ class Static_routes(ConfigBase):
key="next-hop",
attrib=hop["forward_router_address"]
+ " "
- + element,
+ + "distance",
value=str(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 85c0842..d284b66 100644
--- a/tests/unit/modules/network/vyos/test_vyos_static_routes.py
+++ b/tests/unit/modules/network/vyos/test_vyos_static_routes.py
@@ -90,7 +90,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",
+ admin_distance=10,
),
dict(
forward_router_address="192.0.2.10"
@@ -108,6 +109,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 distance '10'",
"set protocols static route 192.0.2.48/28 next-hop '192.0.2.10'",
]
self.execute_module(changed=True, commands=commands)
@@ -158,7 +160,8 @@ class TestVyosStaticRoutesModule(TestVyosModule):
forward_router_address="192.0.2.9"
),
dict(
- forward_router_address="192.0.2.10"
+ forward_router_address="192.0.2.10",
+ admin_distance=10,
),
],
)
@@ -174,6 +177,7 @@ class TestVyosStaticRoutesModule(TestVyosModule):
"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.10'",
+ "set protocols static route 192.0.2.48/28 next-hop 192.0.2.10 distance '10'",
]
self.execute_module(changed=True, commands=commands)