Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix nxos_mtu nxapi failure - module errors out. #30153

Merged
merged 1 commit into from
Sep 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 13 additions & 12 deletions lib/ansible/modules/network/nxos/_nxos_mtu.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,17 @@
from ansible.module_utils.nxos import nxos_argument_spec, check_args
from ansible.module_utils.basic import AnsibleModule

def execute_show_command(command, module, command_type='cli_show'):
if module.params['transport'] == 'cli':
if 'show run' not in command:
command += ' | json'
cmds = [command]
body = run_commands(module, cmds)
elif module.params['transport'] == 'nxapi':
cmds = [command]
body = run_commands(module, cmds)
def execute_show_command(command, module):
if 'show run' not in command:
output = 'json'
else:
output = 'text'
cmds = [{
'command': command,
'output': output,
}]

body = run_commands(module, cmds)
return body


Expand Down Expand Up @@ -169,7 +171,7 @@ def get_system_mtu(module):
command = 'show run all | inc jumbomtu'
sysmtu = ''

body = execute_show_command(command, module, command_type='cli_show_ascii')
body = execute_show_command(command, module)

if body:
sysmtu = str(body[0].split(' ')[-1])
Expand Down Expand Up @@ -237,8 +239,7 @@ def is_default(interface, module):
command = 'show run interface {0}'.format(interface)

try:
body = execute_show_command(
command, module, command_type='cli_show_ascii')[0]
body = execute_show_command(command, module)[0]
if body == 'DNE':
return 'DNE'
else:
Expand Down
14 changes: 8 additions & 6 deletions test/integration/targets/nxos_mtu/tests/common/set_mtu.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
---
- debug: msg="START {{ connection.transport }}/set_mtu.yaml"

- set_fact: testint="{{ nxos_int1 }}"

- name: setup
nxos_config:
lines:
- no switchport
- no mtu
parents: interface Ethernet3/1
parents: "interface {{ testint }}"
match: none
provider: "{{ connection }}"

- name: configure interface mtu
nxos_mtu:
interface: Ethernet3/1
interface: "{{ testint }}"
mtu: 2000
provider: "{{ connection }}"
register: result
Expand All @@ -23,7 +25,7 @@

- name: verify interface mtu
nxos_mtu:
interface: Ethernet3/1
interface: "{{ testint }}"
mtu: 2000
provider: "{{ connection }}"
register: result
Expand All @@ -34,7 +36,7 @@

- name: configure invalid (odd) interface mtu
nxos_mtu:
interface: Ethernet3/1
interface: "{{ testint }}"
mtu: 2001
provider: "{{ connection }}"
register: result
Expand All @@ -46,7 +48,7 @@

- name: configure invalid (large) mtu setting
nxos_mtu:
interface: Ethernet3/1
interface: "{{ testint }}"
mtu: 100000
provider: "{{ connection }}"
register: result
Expand All @@ -59,7 +61,7 @@
- name: teardown
nxos_config:
lines: no mtu
parents: interface Ethernet3/1
parents: "interface {{ testint }}"
match: none
provider: "{{ connection }}"

Expand Down