Skip to content

nxos_static_routes module cannot delete static routes of Vlan interfaces. #986

@h-hirokawa

Description

@h-hirokawa
SUMMARY

cisco.nxos.nxos_static_routes module cannot delete static routes when the next-hop with Vlan interface. This seems to stem from the regex used in the rm_template, which does not recognize Vlan interfaces.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

nxos_static_routes module

ANSIBLE VERSION
ansible [core 2.18.2]
COLLECTION VERSION
cisco.nxos              10.2.0 
CONFIGURATION
CONFIG_FILE() = None
OS / ENVIRONMENT

Tested only in a mocked unit-test environment.

STEPS TO REPRODUCE

Add the following test case to tests/unit/modules/network/nxos/test_nxos_static_routes:TestNxosStaticRoutesModule and run the tests.

    def test_nxos_static_routes_deletedroute_vlan(self):
        self.execute_show_command.return_value = dedent(
            """\
            ip route 192.0.2.20/28 Vlan274 192.0.2.21 name vlan_route1
            ip route 192.0.2.22/28 Vlan275 192.0.2.23 name vlan_route2
            ip route 192.0.2.17/28 192.0.2.23 name replaced_route1 3
            ip route 192.0.2.17/28 Ethernet1/2 192.0.2.45 vrf destinationVRF name replaced_route2
            ip route 192.0.2.79/28 192.0.2.26 tag 12
            vrf context Test
              ip route 192.0.2.48/28 192.0.2.13
              ip route 192.0.2.48/28 192.0.2.14 5
            """,
        )
        set_module_args(
            dict(
                config=[
                    {
                        "address_families": [
                            {
                                "afi": "ipv4",
                                "routes": [
                                    {
                                        "next_hops": [
                                            {
                                                "interface": "Vlan274",
                                                "forward_router_address": "192.0.2.21",
                                                "route_name": "vlan_route1",
                                            },
                                        ],
                                        "dest": "192.0.2.20/28",
                                    },
                                ],
                            },
                        ],
                    },
                ],
                state="deleted",
            ),
        )
        commands = [
            "no ip route 192.0.2.20/28 Vlan274 192.0.2.21 name vlan_route1",
        ]
        result = self.execute_module(changed=True)
        self.assertEqual(result["commands"], commands)
EXPECTED RESULTS

The tests passed.

ACTUAL RESULTS

The following exception raised.

AssertionError: Lists differ: ['no ip route 192.0.2.17/28 192.0.2.23 name replaced_route1 3',[134 chars] 12'] != ['no ip route 192.0.2.20/28 Vlan274 192.0.2.21 name vlan_route1']

First differing element 0:
'no ip route 192.0.2.17/28 192.0.2.23 name replaced_route1 3'
'no ip route 192.0.2.20/28 Vlan274 192.0.2.21 name vlan_route1'

First list contains 2 additional elements.
First extra element 1:
'no ip route 192.0.2.17/28 Ethernet1/2 192.0.2.45 vrf destinationVRF name replaced_route2'

+ ['no ip route 192.0.2.20/28 Vlan274 192.0.2.21 name vlan_route1']
- ['no ip route 192.0.2.17/28 192.0.2.23 name replaced_route1 3',
-  'no ip route 192.0.2.17/28 Ethernet1/2 192.0.2.45 vrf destinationVRF name '
-  'replaced_route2',
-  'no ip route 192.0.2.79/28 192.0.2.26 tag 12']

tests/unit/modules/network/nxos/test_nxos_static_routes.py:1371: AssertionError

The deletion of routes not specified in the module args has been reported in #985.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions