1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Fix nxos modules idempotence issue (#46437)

* nxos_interface vlan and port-channel idempotence fix for mtu

* Fix MTU reconfiguration at each execution

* nxos_interface port-channel idempotence fix for mode (#44248)

* Fix trunk mode idempotence for port-channel
* Gather ethernet and port-channel code for mode management

* nxos_linkagg port-channel idempotence fix for channel-group's mode

The regex to retrieve channel-group's mode is not enough accurate.
Therefore, the swhitchport mode  was matched instead of the
channel-group's mode.

* This fix add accuracy to match the right configuration command

* Add support for switchport mode dot1q-tunnel in nxos_interface

* Fix layer reconfiguration at each execution
This commit is contained in:
Olivier BLIN 2018-11-29 05:53:51 +01:00 committed by Trishna Guha
parent af1e6878e9
commit c51407c806
2 changed files with 10 additions and 13 deletions

View file

@ -514,7 +514,12 @@ def map_config_to_obj(want, module):
intf_type = get_interface_type(w['name']) intf_type = get_interface_type(w['name'])
if intf_type in ['portchannel', 'ethernet']: if intf_type in ['portchannel', 'ethernet']:
if not interface_table.get('eth_mode'): mode = interface_table.get('eth_mode')
if mode in ('access', 'trunk', 'dot1q-tunnel'):
obj['mode'] = 'layer2'
elif mode in ('routed', 'layer3'):
obj['mode'] = 'layer3'
else:
obj['mode'] = 'layer3' obj['mode'] = 'layer3'
if intf_type == 'ethernet': if intf_type == 'ethernet':
@ -524,11 +529,6 @@ def map_config_to_obj(want, module):
obj['mtu'] = interface_table.get('eth_mtu') obj['mtu'] = interface_table.get('eth_mtu')
obj['duplex'] = interface_table.get('eth_duplex') obj['duplex'] = interface_table.get('eth_duplex')
speed = interface_table.get('eth_speed') speed = interface_table.get('eth_speed')
mode = interface_table.get('eth_mode')
if mode in ('access', 'trunk'):
obj['mode'] = 'layer2'
elif mode in ('routed', 'layer3'):
obj['mode'] = 'layer3'
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]
@ -557,6 +557,7 @@ def map_config_to_obj(want, module):
'nxapibug')) 'nxapibug'))
obj['description'] = str(attributes.get('description', obj['description'] = str(attributes.get('description',
'nxapi_bug')) 'nxapi_bug'))
obj['mtu'] = interface_table.get('svi_mtu')
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]
@ -578,11 +579,7 @@ def map_config_to_obj(want, module):
obj['name'] = normalize_interface(interface_table.get('interface')) obj['name'] = normalize_interface(interface_table.get('interface'))
obj['admin_state'] = interface_table.get('admin_state') obj['admin_state'] = interface_table.get('admin_state')
obj['description'] = interface_table.get('desc') obj['description'] = interface_table.get('desc')
mode = interface_table.get('eth_mode') obj['mtu'] = interface_table.get('eth_mtu')
if mode == 'access':
obj['mode'] = 'layer2'
else:
obj['mode'] = 'layer3'
objs.append(obj) objs.append(obj)

View file

@ -291,9 +291,9 @@ def parse_mode(module, m):
flags = ['| section interface.{0}'.format(m)] flags = ['| section interface.{0}'.format(m)]
config = get_config(module, flags=flags) config = get_config(module, flags=flags)
match = re.search(r'mode (\S+)', config, re.M) match = re.search(r'channel-group [0-9]+ (force )?mode (\S+)', config, re.M)
if match: if match:
mode = match.group(1) mode = match.group(2)
return mode return mode