diff options
| author | GomathiselviS <gomathiselvi@gmail.com> | 2021-05-17 15:26:10 -0400 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-05-17 19:26:10 +0000 | 
| commit | 58083777641f6e11b84d40de3a35400cda8c08a4 (patch) | |
| tree | 2d0785fcf751422381bd94b3514bf2eea8f2b074 | |
| parent | b40a269ef86aff5928dfda162cad8a7e6884debb (diff) | |
| download | vyos.vyos-58083777641f6e11b84d40de3a35400cda8c08a4.tar.gz vyos.vyos-58083777641f6e11b84d40de3a35400cda8c08a4.zip | |
linters fix (#160)
Replace admin_distance with distance while generating static_routes nexthop command
Reviewed-by: https://github.com/apps/ansible-zuul
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 00000000..97caa18b --- /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 f1d4f38d..61cb4ad5 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 85c08422..d284b660 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) | 
