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
(cherry picked from commit c51407c806
)
This commit is contained in:
parent
eafc7fc531
commit
d0416733a9
2 changed files with 10 additions and 13 deletions
|
@ -514,7 +514,12 @@ def map_config_to_obj(want, module):
|
|||
intf_type = get_interface_type(w['name'])
|
||||
|
||||
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'
|
||||
|
||||
if intf_type == 'ethernet':
|
||||
|
@ -524,11 +529,6 @@ def map_config_to_obj(want, module):
|
|||
obj['mtu'] = interface_table.get('eth_mtu')
|
||||
obj['duplex'] = interface_table.get('eth_duplex')
|
||||
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'])
|
||||
body = execute_show_command(command, module)[0]
|
||||
|
@ -557,6 +557,7 @@ def map_config_to_obj(want, module):
|
|||
'nxapibug'))
|
||||
obj['description'] = str(attributes.get('description',
|
||||
'nxapi_bug'))
|
||||
obj['mtu'] = interface_table.get('svi_mtu')
|
||||
|
||||
command = 'show run interface {0}'.format(obj['name'])
|
||||
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['admin_state'] = interface_table.get('admin_state')
|
||||
obj['description'] = interface_table.get('desc')
|
||||
mode = interface_table.get('eth_mode')
|
||||
if mode == 'access':
|
||||
obj['mode'] = 'layer2'
|
||||
else:
|
||||
obj['mode'] = 'layer3'
|
||||
obj['mtu'] = interface_table.get('eth_mtu')
|
||||
|
||||
objs.append(obj)
|
||||
|
||||
|
|
|
@ -291,9 +291,9 @@ def parse_mode(module, m):
|
|||
|
||||
flags = ['| section interface.{0}'.format(m)]
|
||||
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:
|
||||
mode = match.group(1)
|
||||
mode = match.group(2)
|
||||
|
||||
return mode
|
||||
|
||||
|
|
Loading…
Reference in a new issue