Refactor/fix nxos_nxapi to use show run (#28675)

* Refactor/fix nxos_nxapi to use show run

* Fix unit tests

* Python 3 compatibility
This commit is contained in:
Mike Wiebe 2017-08-28 15:00:56 -04:00 committed by Nathaniel Case
commit 3d46258cff
11 changed files with 45 additions and 24 deletions

View file

@ -1,2 +1,4 @@
---
# Only cli tests for this module since cli is used
# to test nxapi
- { include: cli.yaml, tags: ['cli'] }

View file

@ -0,0 +1,7 @@
---
- name: Assert configuration changes
assert:
that:
- result.stdout[0]['TABLE_listen_on_port']['ROW_listen_on_port'].l_port
- result.stdout[0]['TABLE_listen_on_port']['ROW_listen_on_port'].l_port | string | search("9443")
- result.stdout[0]['operation_status'].o_status == 'nxapi enabled'

View file

@ -0,0 +1,7 @@
---
- name: Assert configuration changes
assert:
that:
- result.stdout[0].http_port is not defined
- result.stdout[0].https_port | string | search("9443")
- result.stdout[0].sandbox_status == 'Enabled'

View file

@ -1,6 +1,9 @@
---
- debug: msg="START cli/configure.yaml"
- set_fact: nxapi_sandbox_option="yes"
when: platform | search('N7K')
- name: Setup - put NXAPI in stopped state
nxos_nxapi:
state: absent
@ -9,7 +12,7 @@
- name: Configure NXAPI
nxos_nxapi:
enable_http: no
enable_sandbox: no
enable_sandbox: "{{nxapi_sandbox_option|default(omit)}}"
enable_https: yes
https_port: 9443
provider: "{{ cli }}"
@ -21,17 +24,16 @@
provider: "{{ cli }}"
register: result
- name: Assert configuration changes
assert:
that:
- result.stdout[0].http_port is not defined
- result.stdout[0].https_port == 9443
- result.stdout[0].sandbox_status == 'Disabled'
- include: targets/nxos_nxapi/tasks/platform/n7k/assert_changes.yaml
when: platform | match('N7K')
- include: targets/nxos_nxapi/tasks/platform/default/assert_changes.yaml
when: not (platform | search('N7K'))
- name: Configure NXAPI again
nxos_nxapi:
enable_http: no
enable_sandbox: no
enable_sandbox: "{{nxapi_sandbox_option|default(omit)}}"
enable_https: yes
https_port: 9443
provider: "{{ cli }}"

View file

@ -40,7 +40,5 @@
assert:
that:
result.changed == false
# FIXME https://github.com/ansible/ansible-modules-core/issues/4955
ignore_errors: yes
- debug: msg="END cli/disable.yaml"

View file

@ -9,7 +9,7 @@
- name: Enable NXAPI
nxos_nxapi:
state: started
state: present
provider: "{{ cli }}"
register: result