Skip to content

Commit

Permalink
Fix eos_vlan associated interface check (ansible#39661)
Browse files Browse the repository at this point in the history
* Fix eos_vlan associated interface check

Fix eos_vlan associated interface check by comparing
the interface in want and have without converting the
interface name to lower

* Update eos_vlan docs
  • Loading branch information
ganeshrn authored and Alexander Bethke committed May 14, 2018
1 parent 073d331 commit e746bec
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
18 changes: 9 additions & 9 deletions lib/ansible/modules/network/eos/eos_vlan.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@
required: true
interfaces:
description:
- List of interfaces that should be associated to the VLAN. The name of interface
should be in expanded format and not abbreviated.
- List of interfaces that should be associated to the VLAN. The name of interface is
case sensitive and should be in expanded format and not abbreviated.
associated_interfaces:
description:
- This is a intent option and checks the operational state of the for given vlan C(name)
for associated interfaces. The name of interface should be in expanded format and not abbreviated.
If the value in the C(associated_interfaces) does not match with the operational state of vlan
interfaces on device it will result in failure.
for associated interfaces. The name of interface is case sensitive and should be in
expanded format and not abbreviated. If the value in the C(associated_interfaces)
does not match with the operational state of vlan interfaces on device it will result in failure.
version_added: "2.5"
delay:
description:
Expand Down Expand Up @@ -245,10 +245,10 @@ def map_params_to_obj(module):
item[key] = module.params[key]

if item.get('interfaces'):
item['interfaces'] = [intf.replace(" ", "").lower() for intf in item.get('interfaces') if intf]
item['interfaces'] = [intf.replace(" ", "") for intf in item.get('interfaces') if intf]

if item.get('associated_interfaces'):
item['associated_interfaces'] = [intf.replace(" ", "").lower() for intf in item.get('associated_interfaces') if intf]
item['associated_interfaces'] = [intf.replace(" ", "") for intf in item.get('associated_interfaces') if intf]

d = item.copy()
d['vlan_id'] = str(d['vlan_id'])
Expand All @@ -259,8 +259,8 @@ def map_params_to_obj(module):
'vlan_id': str(module.params['vlan_id']),
'name': module.params['name'],
'state': module.params['state'],
'interfaces': [intf.replace(" ", "").lower() for intf in module.params['interfaces']] if module.params['interfaces'] else [],
'associated_interfaces': [intf.replace(" ", "").lower() for intf in
'interfaces': [intf.replace(" ", "") for intf in module.params['interfaces']] if module.params['interfaces'] else [],
'associated_interfaces': [intf.replace(" ", "") for intf in
module.params['associated_interfaces']] if module.params['associated_interfaces'] else []

})
Expand Down
12 changes: 6 additions & 6 deletions test/integration/targets/eos_vlan/tests/cli/basic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@
that:
- "result.changed == true"
- "'vlan 4000' in result.commands"
- "'interface ethernet1' in result.commands"
- "'interface Ethernet1' in result.commands"
- "'switchport access vlan 4000' in result.commands"
- "'interface ethernet2' in result.commands"
- "'interface Ethernet2' in result.commands"
- "'switchport access vlan 4000' in result.commands"
# Ensure sessions contains epoc. Will fail after 18th May 2033
- "'ansible_1' in result.session_name"
Expand All @@ -149,8 +149,8 @@
vlan_id: 4000
state: present
interfaces:
- ethernet 1 # interface name modified to test case insensitive and space scenario
- ethernet 2 # interface name modified to test case insensitive and space scenario
- Ethernet 1 # interface name space scenario
- Ethernet 2 # interface name space scenario
authorize: yes
provider: "{{ cli }}"
become: yes
Expand Down Expand Up @@ -194,7 +194,7 @@
that:
- "result.changed == true"
- "'vlan 4000' in result.commands"
- "'interface ethernet2' in result.commands"
- "'interface Ethernet2' in result.commands"
- "'no switchport access vlan 4000' in result.commands"
# Ensure sessions contains epoc. Will fail after 18th May 2033
- "'ansible_1' in result.session_name"
Expand All @@ -204,7 +204,7 @@
vlan_id: 4000
state: present
interfaces:
- ethernet 1 # interface name modified to handle case insensitive and space scenario
- Ethernet 1 # space scenario
authorize: yes
provider: "{{ cli }}"
become: yes
Expand Down

0 comments on commit e746bec

Please sign in to comment.