mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
nxos_interface: AttributeError: 'NoneType' object has no attribute 'group' (#38544)
This fixes an issue we recently encounteredi with nxos_interface: ``` Traceback (most recent call last): File "/tmp/ansible_JmLoba/ansible_module_nxos_interface.py", line 777, in main have = map_config_to_obj(want, module) File "/tmp/ansible_JmLoba/ansible_module_nxos_interface.py", line 606, in map_config_to_obj obj['speed'] = re.search(r'speed (\d+)', body).group(1) AttributeError: 'NoneType' object has no attribute 'group' ```
This commit is contained in:
parent
2f99a17856
commit
dca6e2d94d
1 changed files with 8 additions and 6 deletions
|
@ -602,15 +602,17 @@ def map_config_to_obj(want, module):
|
||||||
command = 'show run interface {0}'.format(obj['name'])
|
command = 'show run interface {0}'.format(obj['name'])
|
||||||
body = execute_show_command(command, module)[0]
|
body = execute_show_command(command, module)[0]
|
||||||
|
|
||||||
if 'speed' in body:
|
speed_match = re.search(r'speed (\d+)', body)
|
||||||
obj['speed'] = re.search(r'speed (\d+)', body).group(1)
|
if speed_match is None:
|
||||||
else:
|
|
||||||
obj['speed'] = 'auto'
|
obj['speed'] = 'auto'
|
||||||
|
|
||||||
if 'duplex' in body:
|
|
||||||
obj['duplex'] = re.search(r'duplex (\S+)', body).group(1)
|
|
||||||
else:
|
else:
|
||||||
|
obj['speed'] = speed_match.group(1)
|
||||||
|
|
||||||
|
duplex_match = re.search(r'duplex (\S+)', body)
|
||||||
|
if duplex_match is None:
|
||||||
obj['duplex'] = 'auto'
|
obj['duplex'] = 'auto'
|
||||||
|
else:
|
||||||
|
obj['duplex'] = duplex_match.group(1)
|
||||||
|
|
||||||
if 'ip forward' in body:
|
if 'ip forward' in body:
|
||||||
obj['ip_forward'] = 'enable'
|
obj['ip_forward'] = 'enable'
|
||||||
|
|
Loading…
Reference in a new issue