Skip to content

Commit

Permalink
To fix the NoneType error raised in ios_l2_interface when Access Mode…
Browse files Browse the repository at this point in the history
… VLAN is unassigned (ansible#42312)

* to fix the bug41657

* to fix review comment
  • Loading branch information
justjais authored Jul 5, 2018
1 parent 376b30e commit 828dd1a
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions lib/ansible/modules/network/ios/ios_l2_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,18 @@ def interface_is_portchannel(name, module):

def get_switchport(name, module):
config = run_commands(module, ['show interface {0} switchport'.format(name)])[0]
mode = re.search(r'Administrative Mode: (?:.* )?(\w+)$', config, re.M).group(1)
access = re.search(r'Access Mode VLAN: (\d+)', config).group(1)
native = re.search(r'Trunking Native Mode VLAN: (\d+)', config).group(1)
trunk = re.search(r'Trunking VLANs Enabled: (.+)$', config, re.M).group(1)
mode = re.search(r'Administrative Mode: (?:.* )?(\w+)$', config, re.M)
access = re.search(r'Access Mode VLAN: (\d+)', config)
native = re.search(r'Trunking Native Mode VLAN: (\d+)', config)
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':
trunk = '1-4094'

Expand Down

0 comments on commit 828dd1a

Please sign in to comment.