Skip to content

Commit

Permalink
Fix IPv6 static routes facts (#543)
Browse files Browse the repository at this point in the history
* Fix IPv6 static routes facts

Signed-off-by: rohitthakur2590 <rohitthakur2590@outlook.com>

* update test

* Update tests

Signed-off-by: rohitthakur2590 <rohitthakur2590@outlook.com>

* trivial

Signed-off-by: rohitthakur2590 <rohitthakur2590@outlook.com>

---------

Signed-off-by: rohitthakur2590 <rohitthakur2590@outlook.com>
  • Loading branch information
rohitthakur2590 authored Jun 11, 2024
1 parent 3fe67c7 commit 1584c11
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 3 deletions.
5 changes: 5 additions & 0 deletions changelogs/fragments/fix_statis_routes_ds_issue.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
bugfixes:
- Ensure IPv6 static route definitions are correctly filtered during facts gathering.
- Update the filter to accurately retrieve relevant static route configurations.
- Update integration tests for parse operations to ensure that ordering or address family (AF) does not affect assertions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def __init__(self, module, subspec="config", options="options"):
self.generated_spec = utils.generate_dict(facts_argument_spec)

def get_device_data(self, connection):
return connection.get("show running-config | grep route")
return connection.get("show running-config | include ^ip route|^ipv6 route")

def populate_facts(self, connection, ansible_facts, data=None):
"""Populate the facts for static_routes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ ip route 23.1.0.0/16 Nexthop-Group testgrp tag 42
ip route vrf testvrf 120.1.1.0/24 Ethernet1 23
ip route vrf vrftest1 77.77.1.0/24 33.1.1.1
ipv6 route 1000:10::/64 Ethernet1 67 tag 98
router ospf 1
router-id 170.21.0.4
router ospf 2 vrf vrf01
router ospf 3 vrf vrf02
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,41 @@
- default
gather_network_resources:
- static_routes
- name: Set expect response to be asserted
ansible.builtin.set_fact:
expected_parsed_output:
- address_families:
- afi: ipv4
routes:
- dest: 10.1.1.0/24
next_hops:
- interface: Management1
- admin_distance: 200
forward_router_address: 20.1.1.3
interface: Ethernet1
track: bfd
- dest: 10.50.0.0/16
next_hops:
- interface: Management1
- dest: 23.1.0.0/16
next_hops:
- nexthop_grp: testgrp
tag: 42
- address_families:
- afi: ipv4
routes:
- dest: 120.1.1.0/24
next_hops:
- admin_distance: 23
interface: Ethernet1
vrf: testvrf
- address_families:
- afi: ipv4
routes:
- dest: 77.77.1.0/24
next_hops:
- interface: 33.1.1.1
vrf: vrftest1

- name: Provide the running configuration for parsing (config to be parsed)
become: true
Expand All @@ -24,8 +59,8 @@

- ansible.builtin.assert:
that:
- "{{ ansible_facts['network_resources']['static_routes'] | symmetric_difference(result['parsed'])\
\ |length == 0 }}"
- "{{ expected_parsed_output | symmetric_difference(result['parsed']) |length ==\
\ 0 }}"

- name: Gather the existing running configuration (IDEMPOTENT)
become: true
Expand Down

0 comments on commit 1584c11

Please sign in to comment.