From e24c547a3a810e6d4496f96845dcd8c3a2aad2c0 Mon Sep 17 00:00:00 2001 From: rahushen Date: Fri, 16 Feb 2018 23:46:03 -0500 Subject: [PATCH] Fixes for the N3500 platform that uses the A8 image (#36261) * fix nxos_l3_interface tests as n35 doesn't support ipv6 * add terminal dont-ask to nxos_feature and nxos_lldp * put interfaces in L2 mode for N35 * fix nxos_feature unit-tests --- lib/ansible/modules/network/nxos/nxos_feature.py | 3 +++ lib/ansible/modules/network/nxos/nxos_lldp.py | 3 +++ .../targets/nxos_l3_interface/tests/cli/sanity.yaml | 8 ++++++-- .../targets/nxos_l3_interface/tests/nxapi/sanity.yaml | 10 +++++++--- .../targets/nxos_linkagg/tests/common/sanity.yaml | 8 ++++++++ .../targets/nxos_lldp/tests/cli/sanity.yaml | 5 +++-- .../targets/nxos_lldp/tests/nxapi/sanity.yaml | 5 +++-- .../targets/prepare_nxos_tests/tasks/main.yml | 4 ++++ test/units/modules/network/nxos/test_nxos_feature.py | 4 ++-- 9 files changed, 39 insertions(+), 11 deletions(-) diff --git a/lib/ansible/modules/network/nxos/nxos_feature.py b/lib/ansible/modules/network/nxos/nxos_feature.py index 6c3cc6fa0b1..e5fc994fc0f 100644 --- a/lib/ansible/modules/network/nxos/nxos_feature.py +++ b/lib/ansible/modules/network/nxos/nxos_feature.py @@ -236,6 +236,9 @@ def main(): cmds = get_commands(proposed, existing, state, module) if cmds: + # On N35 A8 images, some features return a yes/no prompt + # on enablement or disablement. Bypass using terminal dont-ask + cmds.insert(0, 'terminal dont-ask') if not module.check_mode: load_config(module, cmds) results['changed'] = True diff --git a/lib/ansible/modules/network/nxos/nxos_lldp.py b/lib/ansible/modules/network/nxos/nxos_lldp.py index e8345bcb8f0..a81c956c5e9 100644 --- a/lib/ansible/modules/network/nxos/nxos_lldp.py +++ b/lib/ansible/modules/network/nxos/nxos_lldp.py @@ -99,6 +99,9 @@ def main(): result['commands'] = commands if commands: + # On N35 A8 images, some features return a yes/no prompt + # on enablement or disablement. Bypass using terminal dont-ask + commands.insert(0, 'terminal dont-ask') if not module.check_mode: load_config(module, commands) diff --git a/test/integration/targets/nxos_l3_interface/tests/cli/sanity.yaml b/test/integration/targets/nxos_l3_interface/tests/cli/sanity.yaml index b6f7a80ca57..0da11f07a1e 100644 --- a/test/integration/targets/nxos_l3_interface/tests/cli/sanity.yaml +++ b/test/integration/targets/nxos_l3_interface/tests/cli/sanity.yaml @@ -7,6 +7,10 @@ - set_fact: testint2="{{ nxos_int2 }}" - set_fact: testint3="{{ nxos_int3 }}" +- set_fact: ipv6_address="" +- set_fact: ipv6_address="33:db::2/8" + when: ipv6_supported + - name: Setup - remove address from interface prior to testing(Part1) nxos_config: lines: @@ -69,7 +73,7 @@ nxos_l3_interface: &conf_agg aggregate: - { name: "{{ testint2 }}", ipv4: 192.168.22.1/24 } - - { name: "{{ testint3 }}", ipv4: 192.168.20.1/24, ipv6: "33:db::2/8" } + - { name: "{{ testint3 }}", ipv4: 192.168.20.1/24, ipv6: "{{ ipv6_address }}" } provider: "{{ cli }}" register: result @@ -89,7 +93,7 @@ nxos_l3_interface: &rm_agg aggregate: - { name: "{{ testint2 }}", ipv4: 192.168.22.1/24 } - - { name: "{{ testint3 }}", ipv4: 192.168.20.1/24, ipv6: "33:db::2/8" } + - { name: "{{ testint3 }}", ipv4: 192.168.20.1/24, ipv6: "{{ ipv6_address }}" } provider: "{{ cli }}" state: absent register: result diff --git a/test/integration/targets/nxos_l3_interface/tests/nxapi/sanity.yaml b/test/integration/targets/nxos_l3_interface/tests/nxapi/sanity.yaml index 5c95b459061..dd64379671e 100644 --- a/test/integration/targets/nxos_l3_interface/tests/nxapi/sanity.yaml +++ b/test/integration/targets/nxos_l3_interface/tests/nxapi/sanity.yaml @@ -7,11 +7,15 @@ - set_fact: testint2="{{ nxos_int2 }}" - set_fact: testint3="{{ nxos_int3 }}" +- set_fact: ipv6_address="" +- set_fact: ipv6_address="33:db::2/8" + when: ipv6_supported + - name: Setup - Remove address from interfaces aggregate nxos_l3_interface: aggregate: - { name: "{{ testint2 }}", ipv4: 192.168.22.1/24 } - - { name: "{{ testint3 }}", ipv4: 192.168.20.1/24, ipv6: "33:db::2/8" } + - { name: "{{ testint3 }}", ipv4: 192.168.20.1/24, ipv6: "{{ ipv6_address }}" } provider: "{{ nxapi }}" state: absent ignore_errors: yes @@ -59,7 +63,7 @@ nxos_l3_interface: &conf_agg aggregate: - { name: "{{ testint2 }}", ipv4: 192.168.22.1/24 } - - { name: "{{ testint3 }}", ipv4: 192.168.20.1/24, ipv6: "33:db::2/8" } + - { name: "{{ testint3 }}", ipv4: 192.168.20.1/24, ipv6: "{{ ipv6_address }}" } provider: "{{ nxapi }}" register: result @@ -79,7 +83,7 @@ nxos_l3_interface: &rm_agg aggregate: - { name: "{{ testint2 }}", ipv4: 192.168.22.1/24 } - - { name: "{{ testint3 }}", ipv4: 192.168.20.1/24, ipv6: "33:db::2/8" } + - { name: "{{ testint3 }}", ipv4: 192.168.20.1/24, ipv6: "{{ ipv6_address }}" } provider: "{{ nxapi }}" state: absent register: result diff --git a/test/integration/targets/nxos_linkagg/tests/common/sanity.yaml b/test/integration/targets/nxos_linkagg/tests/common/sanity.yaml index 94b24fd4f59..b508986b94c 100644 --- a/test/integration/targets/nxos_linkagg/tests/common/sanity.yaml +++ b/test/integration/targets/nxos_linkagg/tests/common/sanity.yaml @@ -31,6 +31,14 @@ - "interface {{ testint1 }}" - "interface {{ testint2 }}" +- name: Put interface in L2 mode + nxos_interface: + aggregate: + - { name: "{{testint1}}" } + - { name: "{{testint2}}" } + mode: layer2 + when: platform is match("N35") + - name: create linkagg nxos_linkagg: &create group: 20 diff --git a/test/integration/targets/nxos_lldp/tests/cli/sanity.yaml b/test/integration/targets/nxos_lldp/tests/cli/sanity.yaml index 777f360f234..e5a21d2775c 100644 --- a/test/integration/targets/nxos_lldp/tests/cli/sanity.yaml +++ b/test/integration/targets/nxos_lldp/tests/cli/sanity.yaml @@ -4,8 +4,9 @@ when: ansible_connection == "local" - name: Make sure LLDP is not running before tests - nxos_config: - lines: no feature lldp + nxos_feature: + feature: lldp + state: disabled provider: "{{ connection }}" - name: Enable LLDP service diff --git a/test/integration/targets/nxos_lldp/tests/nxapi/sanity.yaml b/test/integration/targets/nxos_lldp/tests/nxapi/sanity.yaml index 3ed60c24352..e44daa72348 100644 --- a/test/integration/targets/nxos_lldp/tests/nxapi/sanity.yaml +++ b/test/integration/targets/nxos_lldp/tests/nxapi/sanity.yaml @@ -4,8 +4,9 @@ when: ansible_connection == "local" - name: Make sure LLDP is not running before tests - nxos_config: - lines: no feature lldp + nxos_feature: + feature: lldp + state: disabled provider: "{{ connection }}" - name: Enable LLDP service diff --git a/test/integration/targets/prepare_nxos_tests/tasks/main.yml b/test/integration/targets/prepare_nxos_tests/tasks/main.yml index 2b1b673a889..ef88383ad2b 100644 --- a/test/integration/targets/prepare_nxos_tests/tasks/main.yml +++ b/test/integration/targets/prepare_nxos_tests/tasks/main.yml @@ -105,3 +105,7 @@ - debug: msg="IMAGE VERSION {{ image_version }}" - debug: msg="IMAGE TAG {{ imagetag }}" - debug: msg="IMAGE MR {{ imagemr }}" + +- set_fact: ipv6_supported="true" +- set_fact: ipv6_supported="false" + when: platform is match("N35") diff --git a/test/units/modules/network/nxos/test_nxos_feature.py b/test/units/modules/network/nxos/test_nxos_feature.py index c63b4a70a23..3c824b94777 100644 --- a/test/units/modules/network/nxos/test_nxos_feature.py +++ b/test/units/modules/network/nxos/test_nxos_feature.py @@ -69,9 +69,9 @@ class TestNxosFeatureModule(TestNxosModule): def test_nxos_feature_enable(self): set_module_args(dict(feature='nve', state='enabled')) result = self.execute_module(changed=True) - self.assertEqual(result['commands'], ['feature nv overlay']) + self.assertEqual(result['commands'], ['terminal dont-ask', 'feature nv overlay']) def test_nxos_feature_disable(self): set_module_args(dict(feature='ospf', state='disabled')) result = self.execute_module(changed=True) - self.assertEqual(result['commands'], ['no feature ospf']) + self.assertEqual(result['commands'], ['terminal dont-ask', 'no feature ospf'])