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

multiple fixes nxos #32903

Merged
merged 1 commit into from
Nov 14, 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
2 changes: 1 addition & 1 deletion lib/ansible/module_utils/nxos.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def run_commands(self, commands, check_rc=True):
except ValueError:
out = to_text(out).strip()

if item['output'] == 'json' and out != 'ok' and isinstance(out, string_types):
if item['output'] == 'json' and out != '' and isinstance(out, string_types):
self._module.fail_json(msg='failed to retrieve output of %s in json format' % item['command'])

responses.append(out)
Expand Down
3 changes: 3 additions & 0 deletions lib/ansible/modules/network/nxos/nxos_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,9 @@ def get_interface_config_commands(interface, intf, existing):
if mtu != 'None':
commands.append('mtu {0}'.format(mtu))

if 'mtu None' in commands:
commands.pop()

admin_state = interface.get('admin_state')
if admin_state:
command = get_admin_state(interface, intf, admin_state)
Expand Down
8 changes: 4 additions & 4 deletions test/integration/targets/nxos_file_copy/tests/cli/sanity.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
local_file: "./nxos.yaml"
file_system: "bootflash:"
provider: "{{ cli }}"
username: "{{ nxos_cli_user | default('admin') }}"
password: "{{ nxos_cli_pass | default('admin') }}"
username: "{{ ansible_ssh_user }}"
password: "{{ ansible_ssh_pass }}"
host: "{{ ansible_host }}"
register: result

Expand All @@ -48,8 +48,8 @@
remote_file: "nxos.yaml"
file_system: "bootflash:"
provider: "{{ cli }}"
username: "{{ nxos_cli_user | default('admin') }}"
password: "{{ nxos_cli_pass | default('admin') }}"
username: "{{ ansible_ssh_user }}"
password: "{{ ansible_ssh_pass }}"
host: "{{ ansible_host }}"
register: result

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
local_file: "./nxos.yaml"
file_system: "bootflash:"
provider: "{{ nxapi }}"
username: "{{ nxos_nxapi_user | default('admin') }}"
password: "{{ nxos_nxapi_pass | default('admin') }}"
username: "{{ ansible_ssh_user }}"
password: "{{ ansible_ssh_pass }}"
host: "{{ ansible_host }}"
register: result

Expand All @@ -51,8 +51,8 @@
remote_file: "nxos.yaml"
file_system: "bootflash:"
provider: "{{ nxapi }}"
username: "{{ nxos_nxapi_user | default('admin') }}"
password: "{{ nxos_nxapi_pass | default('admin') }}"
username: "{{ ansible_ssh_user }}"
password: "{{ ansible_ssh_pass }}"
host: "{{ ansible_host }}"
register: result

Expand Down
6 changes: 2 additions & 4 deletions test/units/modules/network/nxos/test_nxos_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,12 @@ def load_from_file(*args, **kwargs):
def test_nxos_interface_up(self):
set_module_args(dict(interface='loopback0'))
result = self.execute_module(changed=True)
self.assertIn('interface loopback0', result['commands'])
self.assertIn('no shutdown', result['commands'])
self.assertEqual(result['commands'], ['interface loopback0', 'no shutdown'])

def test_nxos_interface_down(self):
set_module_args(dict(interface='loopback0', admin_state='down'))
result = self.execute_module(changed=True)
self.assertIn('interface loopback0', result['commands'])
self.assertIn('shutdown', result['commands'])
self.assertEqual(result['commands'], ['interface loopback0', 'shutdown'])

def test_nxos_interface_delete(self):
set_module_args(dict(interface='loopback0', state='absent'))
Expand Down