From 1b66a13186cd113963fd73c8334453c17892f254 Mon Sep 17 00:00:00 2001 From: Nathaniel Case Date: Tue, 28 May 2019 14:06:57 -0400 Subject: [PATCH] Fix flow in eos_l2_interface (#57059) * Also fix test debug labels --- .../modules/network/eos/eos_l2_interface.py | 20 +++++++++---------- .../tests/cli/no_interface.yaml | 4 ++-- .../tests/eapi/no_interface.yaml | 4 ++-- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/ansible/modules/network/eos/eos_l2_interface.py b/lib/ansible/modules/network/eos/eos_l2_interface.py index 7a3bc37efb..e25c2df1f2 100644 --- a/lib/ansible/modules/network/eos/eos_l2_interface.py +++ b/lib/ansible/modules/network/eos/eos_l2_interface.py @@ -215,7 +215,8 @@ def map_config_to_obj(module, warnings): if "Interface does not exist" in command_result[0]: warnings.append("Could not gather switchport information for {0}: {1}".format(item, command_result[0])) continue - elif command_result[0] != "": + + if command_result[0]: switchport_cfg = command_result[0].split(':')[1].strip() if switchport_cfg == 'Enabled': @@ -226,17 +227,16 @@ def map_config_to_obj(module, warnings): obj = { 'name': item.lower(), 'state': state, + 'access_vlan': parse_config_argument(configobj, item, 'switchport access vlan'), + 'native_vlan': parse_config_argument(configobj, item, 'switchport trunk native vlan'), + 'trunk_allowed_vlans': parse_config_argument(configobj, item, 'switchport trunk allowed vlan'), } + if obj['access_vlan']: + obj['mode'] = 'access' + else: + obj['mode'] = 'trunk' - obj['access_vlan'] = parse_config_argument(configobj, item, 'switchport access vlan') - obj['native_vlan'] = parse_config_argument(configobj, item, 'switchport trunk native vlan') - obj['trunk_allowed_vlans'] = parse_config_argument(configobj, item, 'switchport trunk allowed vlan') - if obj['access_vlan']: - obj['mode'] = 'access' - else: - obj['mode'] = 'trunk' - - instances.append(obj) + instances.append(obj) return instances diff --git a/test/integration/targets/eos_l2_interface/tests/cli/no_interface.yaml b/test/integration/targets/eos_l2_interface/tests/cli/no_interface.yaml index 59b402c75b..d406b0bd4a 100644 --- a/test/integration/targets/eos_l2_interface/tests/cli/no_interface.yaml +++ b/test/integration/targets/eos_l2_interface/tests/cli/no_interface.yaml @@ -1,6 +1,6 @@ --- - debug: - msg: "START eos_l3_interface/cli/no_interface.yaml on connection={{ ansible_connection }}" + msg: "START eos_l2_interface/cli/no_interface.yaml on connection={{ ansible_connection }}" - name: Create fake interface eos_interface: @@ -33,4 +33,4 @@ that: "result.warnings is not defined" - debug: - msg: "END eos_l3_interface/cli/no_interface.yaml on connection={{ ansible_connection }}" + msg: "END eos_l2_interface/cli/no_interface.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/eos_l2_interface/tests/eapi/no_interface.yaml b/test/integration/targets/eos_l2_interface/tests/eapi/no_interface.yaml index 5be724cbc1..a5b9977515 100644 --- a/test/integration/targets/eos_l2_interface/tests/eapi/no_interface.yaml +++ b/test/integration/targets/eos_l2_interface/tests/eapi/no_interface.yaml @@ -1,6 +1,6 @@ --- - debug: - msg: "START eos_l3_interface/eapi/no_interface.yaml on connection={{ ansible_connection }}" + msg: "START eos_l2_interface/eapi/no_interface.yaml on connection={{ ansible_connection }}" - name: Create fake interface eos_interface: @@ -34,4 +34,4 @@ that: "result.warnings is not defined" - debug: - msg: "END eos_l3_interface/eapi/no_interface.yaml on connection={{ ansible_connection }}" + msg: "END eos_l2_interface/eapi/no_interface.yaml on connection={{ ansible_connection }}"