multiple fixes nxos (#32903)

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
pull/32909/head
Trishna Guha 7 years ago committed by GitHub
parent 177a4fb3ec
commit 3ee2501c83
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -169,7 +169,7 @@ class Cli:
except ValueError: except ValueError:
out = to_text(out).strip() 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']) self._module.fail_json(msg='failed to retrieve output of %s in json format' % item['command'])
responses.append(out) responses.append(out)

@ -488,6 +488,9 @@ def get_interface_config_commands(interface, intf, existing):
if mtu != 'None': if mtu != 'None':
commands.append('mtu {0}'.format(mtu)) commands.append('mtu {0}'.format(mtu))
if 'mtu None' in commands:
commands.pop()
admin_state = interface.get('admin_state') admin_state = interface.get('admin_state')
if admin_state: if admin_state:
command = get_admin_state(interface, intf, admin_state) command = get_admin_state(interface, intf, admin_state)

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

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

@ -62,14 +62,12 @@ class TestNxosInterfaceModule(TestNxosModule):
def test_nxos_interface_up(self): def test_nxos_interface_up(self):
set_module_args(dict(interface='loopback0')) set_module_args(dict(interface='loopback0'))
result = self.execute_module(changed=True) result = self.execute_module(changed=True)
self.assertIn('interface loopback0', result['commands']) self.assertEqual(result['commands'], ['interface loopback0', 'no shutdown'])
self.assertIn('no shutdown', result['commands'])
def test_nxos_interface_down(self): def test_nxos_interface_down(self):
set_module_args(dict(interface='loopback0', admin_state='down')) set_module_args(dict(interface='loopback0', admin_state='down'))
result = self.execute_module(changed=True) result = self.execute_module(changed=True)
self.assertIn('interface loopback0', result['commands']) self.assertEqual(result['commands'], ['interface loopback0', 'shutdown'])
self.assertIn('shutdown', result['commands'])
def test_nxos_interface_delete(self): def test_nxos_interface_delete(self):
set_module_args(dict(interface='loopback0', state='absent')) set_module_args(dict(interface='loopback0', state='absent'))

Loading…
Cancel
Save