mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Fix nxos_mtu nxapi failure (#30153)
This commit is contained in:
parent
2cdf31d3a2
commit
cef7ed0310
2 changed files with 21 additions and 18 deletions
|
@ -125,15 +125,17 @@ from ansible.module_utils.nxos import load_config, run_commands
|
||||||
from ansible.module_utils.nxos import nxos_argument_spec, check_args
|
from ansible.module_utils.nxos import nxos_argument_spec, check_args
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
|
|
||||||
def execute_show_command(command, module, command_type='cli_show'):
|
def execute_show_command(command, module):
|
||||||
if module.params['transport'] == 'cli':
|
if 'show run' not in command:
|
||||||
if 'show run' not in command:
|
output = 'json'
|
||||||
command += ' | json'
|
else:
|
||||||
cmds = [command]
|
output = 'text'
|
||||||
body = run_commands(module, cmds)
|
cmds = [{
|
||||||
elif module.params['transport'] == 'nxapi':
|
'command': command,
|
||||||
cmds = [command]
|
'output': output,
|
||||||
body = run_commands(module, cmds)
|
}]
|
||||||
|
|
||||||
|
body = run_commands(module, cmds)
|
||||||
return body
|
return body
|
||||||
|
|
||||||
|
|
||||||
|
@ -169,7 +171,7 @@ def get_system_mtu(module):
|
||||||
command = 'show run all | inc jumbomtu'
|
command = 'show run all | inc jumbomtu'
|
||||||
sysmtu = ''
|
sysmtu = ''
|
||||||
|
|
||||||
body = execute_show_command(command, module, command_type='cli_show_ascii')
|
body = execute_show_command(command, module)
|
||||||
|
|
||||||
if body:
|
if body:
|
||||||
sysmtu = str(body[0].split(' ')[-1])
|
sysmtu = str(body[0].split(' ')[-1])
|
||||||
|
@ -237,8 +239,7 @@ def is_default(interface, module):
|
||||||
command = 'show run interface {0}'.format(interface)
|
command = 'show run interface {0}'.format(interface)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
body = execute_show_command(
|
body = execute_show_command(command, module)[0]
|
||||||
command, module, command_type='cli_show_ascii')[0]
|
|
||||||
if body == 'DNE':
|
if body == 'DNE':
|
||||||
return 'DNE'
|
return 'DNE'
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -1,18 +1,20 @@
|
||||||
---
|
---
|
||||||
- debug: msg="START {{ connection.transport }}/set_mtu.yaml"
|
- debug: msg="START {{ connection.transport }}/set_mtu.yaml"
|
||||||
|
|
||||||
|
- set_fact: testint="{{ nxos_int1 }}"
|
||||||
|
|
||||||
- name: setup
|
- name: setup
|
||||||
nxos_config:
|
nxos_config:
|
||||||
lines:
|
lines:
|
||||||
- no switchport
|
- no switchport
|
||||||
- no mtu
|
- no mtu
|
||||||
parents: interface Ethernet3/1
|
parents: "interface {{ testint }}"
|
||||||
match: none
|
match: none
|
||||||
provider: "{{ connection }}"
|
provider: "{{ connection }}"
|
||||||
|
|
||||||
- name: configure interface mtu
|
- name: configure interface mtu
|
||||||
nxos_mtu:
|
nxos_mtu:
|
||||||
interface: Ethernet3/1
|
interface: "{{ testint }}"
|
||||||
mtu: 2000
|
mtu: 2000
|
||||||
provider: "{{ connection }}"
|
provider: "{{ connection }}"
|
||||||
register: result
|
register: result
|
||||||
|
@ -23,7 +25,7 @@
|
||||||
|
|
||||||
- name: verify interface mtu
|
- name: verify interface mtu
|
||||||
nxos_mtu:
|
nxos_mtu:
|
||||||
interface: Ethernet3/1
|
interface: "{{ testint }}"
|
||||||
mtu: 2000
|
mtu: 2000
|
||||||
provider: "{{ connection }}"
|
provider: "{{ connection }}"
|
||||||
register: result
|
register: result
|
||||||
|
@ -34,7 +36,7 @@
|
||||||
|
|
||||||
- name: configure invalid (odd) interface mtu
|
- name: configure invalid (odd) interface mtu
|
||||||
nxos_mtu:
|
nxos_mtu:
|
||||||
interface: Ethernet3/1
|
interface: "{{ testint }}"
|
||||||
mtu: 2001
|
mtu: 2001
|
||||||
provider: "{{ connection }}"
|
provider: "{{ connection }}"
|
||||||
register: result
|
register: result
|
||||||
|
@ -46,7 +48,7 @@
|
||||||
|
|
||||||
- name: configure invalid (large) mtu setting
|
- name: configure invalid (large) mtu setting
|
||||||
nxos_mtu:
|
nxos_mtu:
|
||||||
interface: Ethernet3/1
|
interface: "{{ testint }}"
|
||||||
mtu: 100000
|
mtu: 100000
|
||||||
provider: "{{ connection }}"
|
provider: "{{ connection }}"
|
||||||
register: result
|
register: result
|
||||||
|
@ -59,7 +61,7 @@
|
||||||
- name: teardown
|
- name: teardown
|
||||||
nxos_config:
|
nxos_config:
|
||||||
lines: no mtu
|
lines: no mtu
|
||||||
parents: interface Ethernet3/1
|
parents: "interface {{ testint }}"
|
||||||
match: none
|
match: none
|
||||||
provider: "{{ connection }}"
|
provider: "{{ connection }}"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue