From 8141aa9a555a7a8ea88f2fd394b6574039344dd6 Mon Sep 17 00:00:00 2001 From: Sumit Jaiswal Date: Sat, 31 Aug 2019 05:06:15 +0530 Subject: [PATCH] To fix iosxr_l3_interfaces module zuul tests (#61592) * fix 61540 * fix utils (cherry picked from commit 24ad1dffc9ad18df7090cc3782fd87523449e955) --- .../module_utils/network/iosxr/utils/utils.py | 4 + .../tests/cli/_populate_config.yaml | 10 +- .../tests/cli/_remove_config.yaml | 7 +- .../tests/cli/deleted.yaml | 4 +- .../iosxr_l3_interfaces/tests/cli/merged.yaml | 14 +-- .../tests/cli/overridden.yaml | 5 +- .../tests/cli/replaced.yaml | 8 +- .../iosxr_l3_interfaces/vars/main.yaml | 115 +++++------------- 8 files changed, 44 insertions(+), 123 deletions(-) diff --git a/lib/ansible/module_utils/network/iosxr/utils/utils.py b/lib/ansible/module_utils/network/iosxr/utils/utils.py index a8bc716f4f9..555a905097d 100644 --- a/lib/ansible/module_utils/network/iosxr/utils/utils.py +++ b/lib/ansible/module_utils/network/iosxr/utils/utils.py @@ -96,6 +96,10 @@ def filter_dict_having_none_value(want, have): if each.get('secondary') and diff_ip is True: test_key_dict.update({'secondary': True}) test_dict.update({'ipv4': test_key_dict}) + # Checks if want doesn't have secondary IP but have has secondary IP set + elif have.get('ipv4'): + if [True for each_have in have.get('ipv4') if 'secondary' in each_have]: + test_dict.update({'ipv4': {'secondary': True}}) if k == 'l2protocol': if want[k] != have.get('l2protocol') and have.get('l2protocol'): test_dict.update({k: v}) diff --git a/test/integration/targets/iosxr_l3_interfaces/tests/cli/_populate_config.yaml b/test/integration/targets/iosxr_l3_interfaces/tests/cli/_populate_config.yaml index 177d2d90281..7c9e80cfd8e 100644 --- a/test/integration/targets/iosxr_l3_interfaces/tests/cli/_populate_config.yaml +++ b/test/integration/targets/iosxr_l3_interfaces/tests/cli/_populate_config.yaml @@ -4,13 +4,9 @@ config: "{{ lines }}" vars: lines: | - interface GigabitEthernet 0/0/0/1 + interface GigabitEthernet 0/0/0/0 ipv4 address 198.51.100.1 255.255.255.0 - interface GigabitEthernet 0/0/0/2 + ipv6 address 2001:db8::/32 + interface GigabitEthernet 0/0/0/1 ipv4 address 192.0.2.1 255.255.255.0 ipv4 address 192.0.2.2 255.255.255.0 secondary - interface GigabitEthernet 0/0/0/3 - ipv4 address 203.0.110.1 255.255.255.0 - ipv6 address 2001:db8::/32 - interface GigabitEthernet 0/0/0/3.100 - ipv4 address 203.0.113.1 255.255.255.0 diff --git a/test/integration/targets/iosxr_l3_interfaces/tests/cli/_remove_config.yaml b/test/integration/targets/iosxr_l3_interfaces/tests/cli/_remove_config.yaml index a96cdb7f424..ebc3d1c2de5 100644 --- a/test/integration/targets/iosxr_l3_interfaces/tests/cli/_remove_config.yaml +++ b/test/integration/targets/iosxr_l3_interfaces/tests/cli/_remove_config.yaml @@ -4,10 +4,9 @@ config: "{{ lines }}" vars: lines: | + interface GigabitEthernet 0/0/0/0 + no ipv4 address + no ipv6 address interface GigabitEthernet 0/0/0/1 no ipv4 address no ipv6 address - no interface GigabitEthernet 0/0/0/2 - no interface GigabitEthernet 0/0/0/3 - no interface GigabitEthernet 0/0/0/3.100 - no interface GigabitEthernet 0/0/0/4 diff --git a/test/integration/targets/iosxr_l3_interfaces/tests/cli/deleted.yaml b/test/integration/targets/iosxr_l3_interfaces/tests/cli/deleted.yaml index 8c1d5ca3f9c..70ec49771c9 100644 --- a/test/integration/targets/iosxr_l3_interfaces/tests/cli/deleted.yaml +++ b/test/integration/targets/iosxr_l3_interfaces/tests/cli/deleted.yaml @@ -10,10 +10,8 @@ - name: Delete attributes of all configured interfaces iosxr_l3_interfaces: &deleted config: + - name: GigabitEthernet0/0/0/0 - name: GigabitEthernet0/0/0/1 - - name: GigabitEthernet0/0/0/2 - - name: GigabitEthernet0/0/0/3 - - name: GigabitEthernet0/0/0/3.100 state: deleted register: result diff --git a/test/integration/targets/iosxr_l3_interfaces/tests/cli/merged.yaml b/test/integration/targets/iosxr_l3_interfaces/tests/cli/merged.yaml index 02a0293a19a..624491e1075 100644 --- a/test/integration/targets/iosxr_l3_interfaces/tests/cli/merged.yaml +++ b/test/integration/targets/iosxr_l3_interfaces/tests/cli/merged.yaml @@ -8,26 +8,16 @@ - name: Merge provided configuration with device configuration iosxr_l3_interfaces: &merged config: - - name: GigabitEthernet0/0/0/1 + - name: GigabitEthernet0/0/0/0 ipv4: - address: 198.51.100.1/24 - - name: GigabitEthernet0/0/0/2 + - name: GigabitEthernet0/0/0/1 ipv6: - address: 2001:db8:0:3::/64 ipv4: - address: 192.0.2.1/24 - address: 192.0.2.2/24 secondary: True - - name: GigabitEthernet0/0/0/3 - ipv4: - - address: 203.0.110.1/24 - - address: 203.0.110.5/24 - secondary: True - - name: GigabitEthernet0/0/0/3.100 - ipv4: - - address: 198.51.100.14/24 - ipv6: - - address: 2001:db8:0:4::/64 state: merged register: result diff --git a/test/integration/targets/iosxr_l3_interfaces/tests/cli/overridden.yaml b/test/integration/targets/iosxr_l3_interfaces/tests/cli/overridden.yaml index 7e2e8440ec4..2bb52f02179 100644 --- a/test/integration/targets/iosxr_l3_interfaces/tests/cli/overridden.yaml +++ b/test/integration/targets/iosxr_l3_interfaces/tests/cli/overridden.yaml @@ -10,10 +10,7 @@ - name: Override device configuration of all interfaces with provided configuration iosxr_l3_interfaces: &overridden config: - - name: GigabitEthernet0/0/0/3 - ipv4: - - address: 203.0.112.24/24 - - name: GigabitEthernet0/0/0/3.100 + - name: GigabitEthernet0/0/0/1 ipv4: - address: 198.51.102.1/24 ipv6: diff --git a/test/integration/targets/iosxr_l3_interfaces/tests/cli/replaced.yaml b/test/integration/targets/iosxr_l3_interfaces/tests/cli/replaced.yaml index a867fbd6ced..ee0dee50ccf 100644 --- a/test/integration/targets/iosxr_l3_interfaces/tests/cli/replaced.yaml +++ b/test/integration/targets/iosxr_l3_interfaces/tests/cli/replaced.yaml @@ -10,17 +10,11 @@ - name: Replaces device configuration of listed interfaces with provided configuration iosxr_l3_interfaces: &replaced config: - - name: GigabitEthernet0/0/0/1 + - name: GigabitEthernet0/0/0/0 ipv4: - address: 203.0.113.27/24 - - name: GigabitEthernet0/0/0/2 - ipv4: - - address: 203.0.115.2/24 - address: 203.0.114.1/24 secondary: True - - name: GigabitEthernet0/0/0/3.100 - ipv4: - - address: 192.0.2.10/24 state: replaced register: result diff --git a/test/integration/targets/iosxr_l3_interfaces/vars/main.yaml b/test/integration/targets/iosxr_l3_interfaces/vars/main.yaml index 2d66aeb55da..f49514eda79 100644 --- a/test/integration/targets/iosxr_l3_interfaces/vars/main.yaml +++ b/test/integration/targets/iosxr_l3_interfaces/vars/main.yaml @@ -5,42 +5,26 @@ merged: - name: Loopback999 commands: - - "interface GigabitEthernet0/0/0/1" + - "interface GigabitEthernet0/0/0/0" - "ipv4 address 198.51.100.1 255.255.255.0" - - "interface GigabitEthernet0/0/0/2" + - "interface GigabitEthernet0/0/0/1" - "ipv4 address 192.0.2.2 255.255.255.0 secondary" - "ipv4 address 192.0.2.1 255.255.255.0" - "ipv6 address 2001:db8:0:3::/64" - - "interface GigabitEthernet0/0/0/3" - - "ipv4 address 203.0.110.1 255.255.255.0" - - "ipv4 address 203.0.110.5 255.255.255.0 secondary" - - "interface GigabitEthernet0/0/0/3.100" - - "ipv4 address 198.51.100.14 255.255.255.0" - - "ipv6 address 2001:db8:0:4::/64" after: - name: Loopback888 - name: Loopback999 - ipv4: - address: 198.51.100.1 255.255.255.0 - name: GigabitEthernet0/0/0/1 + name: GigabitEthernet0/0/0/0 - ipv4: - address: 192.0.2.1 255.255.255.0 - address: 192.0.2.2 255.255.255.0 secondary: true ipv6: - address: 2001:db8:0:3::/64 - name: GigabitEthernet0/0/0/2 - - ipv4: - - address: 203.0.110.1 255.255.255.0 - - address: 203.0.110.5 255.255.255.0 - secondary: true - name: GigabitEthernet0/0/0/3 - - ipv4: - - address: 198.51.100.14 255.255.255.0 - ipv6: - - address: 2001:db8:0:4::/64 - name: GigabitEthernet0/0/0/3.100 + name: GigabitEthernet0/0/0/1 replaced: before: @@ -48,50 +32,34 @@ replaced: - name: Loopback999 - ipv4: - address: 198.51.100.1 255.255.255.0 - name: GigabitEthernet0/0/0/1 + ipv6: + - address: 2001:db8::/32 + name: GigabitEthernet0/0/0/0 - ipv4: - address: 192.0.2.1 255.255.255.0 - address: 192.0.2.2 255.255.255.0 secondary: true - name: GigabitEthernet0/0/0/2 - - ipv4: - - address: 203.0.110.1 255.255.255.0 - ipv6: - - address: 2001:db8::/32 - name: GigabitEthernet0/0/0/3 - - ipv4: - - address: 203.0.113.1 255.255.255.0 - name: GigabitEthernet0/0/0/3.100 + name: GigabitEthernet0/0/0/1 commands: - - "interface GigabitEthernet0/0/0/1" + - "interface GigabitEthernet0/0/0/0" + - "no ipv6 address" - "ipv4 address 203.0.113.27 255.255.255.0" - - "interface GigabitEthernet0/0/0/2" - - "no ipv4 address" - - "ipv4 address 203.0.115.2 255.255.255.0" - "ipv4 address 203.0.114.1 255.255.255.0 secondary" - - "interface GigabitEthernet0/0/0/3.100" - - "ipv4 address 192.0.2.10 255.255.255.0" after: - name: Loopback888 - name: Loopback999 - ipv4: - address: 203.0.113.27 255.255.255.0 - name: GigabitEthernet0/0/0/1 - - ipv4: - - address: 203.0.115.2 255.255.255.0 - address: 203.0.114.1 255.255.255.0 secondary: true - name: GigabitEthernet0/0/0/2 + name: GigabitEthernet0/0/0/0 - ipv4: - - address: 203.0.110.1 255.255.255.0 - ipv6: - - address: 2001:db8::/32 - name: GigabitEthernet0/0/0/3 - - ipv4: - - address: 192.0.2.10 255.255.255.0 - name: GigabitEthernet0/0/0/3.100 + - address: 192.0.2.1 255.255.255.0 + - address: 192.0.2.2 255.255.255.0 + secondary: true + name: GigabitEthernet0/0/0/1 overridden: before: @@ -99,45 +67,32 @@ overridden: - name: Loopback999 - ipv4: - address: 198.51.100.1 255.255.255.0 - name: GigabitEthernet0/0/0/1 + ipv6: + - address: 2001:db8::/32 + name: GigabitEthernet0/0/0/0 - ipv4: - address: 192.0.2.1 255.255.255.0 - address: 192.0.2.2 255.255.255.0 secondary: true - name: GigabitEthernet0/0/0/2 - - ipv4: - - address: 203.0.110.1 255.255.255.0 - ipv6: - - address: 2001:db8::/32 - name: GigabitEthernet0/0/0/3 - - ipv4: - - address: 203.0.113.1 255.255.255.0 - name: GigabitEthernet0/0/0/3.100 + name: GigabitEthernet0/0/0/1 commands: - - "interface GigabitEthernet0/0/0/1" - - "no ipv4 address" - - "interface GigabitEthernet0/0/0/2" + - "interface GigabitEthernet0/0/0/0" - "no ipv4 address" - - "interface GigabitEthernet0/0/0/3" - "no ipv6 address" - - "ipv4 address 203.0.112.24 255.255.255.0" - - "interface GigabitEthernet0/0/0/3.100" + - "interface GigabitEthernet0/0/0/1" + - "no ipv4 address" - "ipv4 address 198.51.102.1 255.255.255.0" - "ipv6 address 2001:db8:1::/64" after: - name: Loopback888 - name: Loopback999 - - name: GigabitEthernet0/0/0/2 - - ipv4: - - address: 203.0.112.24 255.255.255.0 - name: GigabitEthernet0/0/0/3 - ipv4: - address: 198.51.102.1 255.255.255.0 ipv6: - address: 2001:db8:1::/64 - name: GigabitEthernet0/0/0/3.100 + name: GigabitEthernet0/0/0/1 deleted: before: @@ -145,34 +100,22 @@ deleted: - name: Loopback999 - ipv4: - address: 198.51.100.1 255.255.255.0 - name: GigabitEthernet0/0/0/1 + ipv6: + - address: 2001:db8::/32 + name: GigabitEthernet0/0/0/0 - ipv4: - address: 192.0.2.1 255.255.255.0 - address: 192.0.2.2 255.255.255.0 secondary: true - name: GigabitEthernet0/0/0/2 - - ipv4: - - address: 203.0.110.1 255.255.255.0 - ipv6: - - address: 2001:db8::/32 - name: GigabitEthernet0/0/0/3 - - ipv4: - - address: 203.0.113.1 255.255.255.0 - name: GigabitEthernet0/0/0/3.100 + name: GigabitEthernet0/0/0/1 commands: - - "interface GigabitEthernet0/0/0/1" - - "no ipv4 address" - - "interface GigabitEthernet0/0/0/2" - - "no ipv4 address" - - "interface GigabitEthernet0/0/0/3" + - "interface GigabitEthernet0/0/0/0" - "no ipv4 address" - "no ipv6 address" - - "interface GigabitEthernet0/0/0/3.100" + - "interface GigabitEthernet0/0/0/1" - "no ipv4 address" after: - name: Loopback888 - name: Loopback999 - - name: GigabitEthernet0/0/0/3 - - name: GigabitEthernet0/0/0/3.100