summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/ansible/plugins/action/nxos.py3
-rw-r--r--test/integration/targets/nxos_nxapi/tasks/cli.yaml4
-rw-r--r--test/integration/targets/nxos_nxapi/tasks/main.yaml3
-rw-r--r--test/integration/targets/nxos_nxapi/tasks/nxapi.yaml27
-rw-r--r--test/integration/targets/nxos_nxapi/tests/nxapi/badtransport.yaml (renamed from test/integration/targets/nxos_nxapi/tests/cli/badtransport.yaml)6
-rw-r--r--test/integration/targets/nxos_smoke/tasks/cli.yaml2
-rw-r--r--test/integration/targets/nxos_smoke/tests/common/misc_tests.yaml6
7 files changed, 43 insertions, 8 deletions
diff --git a/lib/ansible/plugins/action/nxos.py b/lib/ansible/plugins/action/nxos.py
index bf97fe1438..d98afa256f 100644
--- a/lib/ansible/plugins/action/nxos.py
+++ b/lib/ansible/plugins/action/nxos.py
@@ -43,6 +43,9 @@ class ActionModule(_ActionModule):
socket_path = None
+ if self._task.args.get('provider', {}).get('transport') == 'nxapi' and self._task.action == 'nxos_nxapi':
+ return {'failed': True, 'msg': "Transport type 'nxapi' is not valid for '%s' module." % (self._task.action)}
+
if self._play_context.connection == 'network_cli':
provider = self._task.args.get('provider', {})
if any(provider.values()):
diff --git a/test/integration/targets/nxos_nxapi/tasks/cli.yaml b/test/integration/targets/nxos_nxapi/tasks/cli.yaml
index edbff7dfaf..5832987a51 100644
--- a/test/integration/targets/nxos_nxapi/tasks/cli.yaml
+++ b/test/integration/targets/nxos_nxapi/tasks/cli.yaml
@@ -1,5 +1,5 @@
---
-- name: collect common cli test cases
+- name: collect common test cases
find:
paths: "{{ role_path }}/tests/common"
patterns: "{{ testcase }}.yaml"
@@ -21,7 +21,7 @@
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
- name: run test cases (connection=network_cli)
- include: "{{ test_case_to_run }} ansible_connection=network_cli connection={}"
+ include: "{{ test_case_to_run }} ansible_connection=network_cli"
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run
diff --git a/test/integration/targets/nxos_nxapi/tasks/main.yaml b/test/integration/targets/nxos_nxapi/tasks/main.yaml
index 70e67b38df..4b0f8c64d9 100644
--- a/test/integration/targets/nxos_nxapi/tasks/main.yaml
+++ b/test/integration/targets/nxos_nxapi/tasks/main.yaml
@@ -1,4 +1,3 @@
---
-# Only cli tests for this module since cli is used
-# to test nxapi
- { include: cli.yaml, tags: ['cli'] }
+- { include: nxapi.yaml, tags: ['nxapi'] }
diff --git a/test/integration/targets/nxos_nxapi/tasks/nxapi.yaml b/test/integration/targets/nxos_nxapi/tasks/nxapi.yaml
new file mode 100644
index 0000000000..ab3ad41c47
--- /dev/null
+++ b/test/integration/targets/nxos_nxapi/tasks/nxapi.yaml
@@ -0,0 +1,27 @@
+---
+- name: collect common test cases
+ find:
+ paths: "{{ role_path }}/tests/common"
+ patterns: "{{ testcase }}.yaml"
+ connection: local
+ register: test_cases
+
+- name: collect nxapi test cases
+ find:
+ paths: "{{ role_path }}/tests/nxapi"
+ patterns: "{{ testcase }}.yaml"
+ connection: local
+ register: nxapi_cases
+
+- set_fact:
+ test_cases:
+ files: "{{ test_cases.files }} + {{ nxapi_cases.files }}"
+
+- name: set test_items
+ set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: run test case (connection=local)
+ include: "{{ test_case_to_run }} ansible_connection=local connection={{ nxapi }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
diff --git a/test/integration/targets/nxos_nxapi/tests/cli/badtransport.yaml b/test/integration/targets/nxos_nxapi/tests/nxapi/badtransport.yaml
index 6549aa990b..ebd5bf462c 100644
--- a/test/integration/targets/nxos_nxapi/tests/cli/badtransport.yaml
+++ b/test/integration/targets/nxos_nxapi/tests/nxapi/badtransport.yaml
@@ -1,5 +1,5 @@
---
-- debug: msg="START cli/badtransport.yaml"
+- debug: msg="START nxapi/badtransport.yaml"
- name: Sending transport other than cli should fail
nxos_nxapi:
@@ -12,6 +12,6 @@
- assert:
that:
- - result.failed and result.msg is search('transport')
+ - result.failed and result.msg is search('Transport')
-- debug: msg="END cli/badtransport.yaml"
+- debug: msg="END nxapi/badtransport.yaml"
diff --git a/test/integration/targets/nxos_smoke/tasks/cli.yaml b/test/integration/targets/nxos_smoke/tasks/cli.yaml
index edbff7dfaf..f53eac3a47 100644
--- a/test/integration/targets/nxos_smoke/tasks/cli.yaml
+++ b/test/integration/targets/nxos_smoke/tasks/cli.yaml
@@ -21,7 +21,7 @@
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
- name: run test cases (connection=network_cli)
- include: "{{ test_case_to_run }} ansible_connection=network_cli connection={}"
+ include: "{{ test_case_to_run }} ansible_connection=network_cli connection={{ cli }}"
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run
diff --git a/test/integration/targets/nxos_smoke/tests/common/misc_tests.yaml b/test/integration/targets/nxos_smoke/tests/common/misc_tests.yaml
index 27fc07a7cb..6ae0b003ea 100644
--- a/test/integration/targets/nxos_smoke/tests/common/misc_tests.yaml
+++ b/test/integration/targets/nxos_smoke/tests/common/misc_tests.yaml
@@ -22,3 +22,9 @@
- assert:
that:
- result.stdout|length == 10
+
+- name: combine with provider
+ nxos_command:
+ commands:
+ - show hostname
+ provider: "{{ connection | combine({'timeout': 500}) }}"