To fix the NoneType error raised in ios_l2_interface when Access Mode VLAN is unassigned (#42343)

* To fix the NoneType error raised in ios_l2_interface when Access Mode VLAN is unassigned (#42312)

* to fix the bug41657

* to fix review comment

(cherry picked from commit 828dd1a663)

* adding changelog

* renaming the changelog file name

* deleting the wrong changelog file name
pull/42531/head
Sumit Jaiswal 6 years ago committed by Matt Clay
parent d48fae9990
commit 6e479d5989

@ -0,0 +1,4 @@
---
bugfixes:
- To fix the NoneType error raised in ios_l2_interface when Access Mode VLAN is unassigned
(https://github.com/ansible/ansible/pull/42312)

@ -154,10 +154,18 @@ def interface_is_portchannel(name, module):
def get_switchport(name, module): def get_switchport(name, module):
config = run_commands(module, ['show interface {0} switchport'.format(name)])[0] config = run_commands(module, ['show interface {0} switchport'.format(name)])[0]
mode = re.search(r'Administrative Mode: (?:.* )?(\w+)$', config, re.M).group(1) mode = re.search(r'Administrative Mode: (?:.* )?(\w+)$', config, re.M)
access = re.search(r'Access Mode VLAN: (\d+)', config).group(1) access = re.search(r'Access Mode VLAN: (\d+)', config)
native = re.search(r'Trunking Native Mode VLAN: (\d+)', config).group(1) native = re.search(r'Trunking Native Mode VLAN: (\d+)', config)
trunk = re.search(r'Trunking VLANs Enabled: (.+)$', config, re.M).group(1) trunk = re.search(r'Trunking VLANs Enabled: (.+)$', config, re.M)
if mode:
mode = mode.group(1)
if access:
access = access.group(1)
if native:
native = native.group(1)
if trunk:
trunk = trunk.group(1)
if trunk == 'ALL': if trunk == 'ALL':
trunk = '1-4094' trunk = '1-4094'

Loading…
Cancel
Save