HTTP(S) API connection plugin (#39224)

* HTTPAPI connection

* Punt run_commands to cliconf or httpapi

* Fake enable_mode on eapi

* Pull changes to nxos

* Move load_config to edit_config for future-preparedness

* Don't fail on lldp disabled

* Re-enable check_rc on nxos' run_commands

* Reorganize nxos httpapi plugin for compatibility

* draft docs for connection: httpapi

* restores docs for connection:local for eapi

* Add _remote_is_local to httpapi
This commit is contained in:
Nathaniel Case
2018-05-17 18:47:15 -04:00
committed by GitHub
parent cc61c86049
commit e9d7fa0418
277 changed files with 1325 additions and 1676 deletions

View File

@@ -1,20 +0,0 @@
---
- debug: msg="START nxapi/bad_operator.yaml"
- name: test bad operator
nxos_command:
commands:
- show version
- show interface mgmt0
wait_for:
- "result[1].TABLE_interface.ROW_interface.state foo up"
provider: "{{ nxapi }}"
register: result
ignore_errors: yes
- assert:
that:
- "result.failed == true"
- "result.msg is defined"
- debug: msg="END nxapi/bad_operator.yaml"

View File

@@ -1,20 +0,0 @@
---
- debug: msg="START nxapi/contains.yaml"
- name: test contains operator
nxos_command:
commands:
- show version
- show interface mgmt0
wait_for:
- "result[0].header_str contains NX-OS"
- "result[1].TABLE_interface.ROW_interface.interface contains mgmt"
provider: "{{ nxapi }}"
register: result
- assert:
that:
- "result.changed == false"
- "result.stdout is defined"
- debug: msg="END nxapi/contains.yaml"

View File

@@ -1,34 +0,0 @@
---
- debug: msg="START nxapi/equal.yaml"
- name: test eq operator
nxos_command:
commands:
- show version
- show interface mgmt0
wait_for:
- "result[1].TABLE_interface.ROW_interface.state eq up"
provider: "{{ nxapi }}"
register: result
- assert:
that:
- "result.changed == false"
- "result.stdout is defined"
- name: test == operator
nxos_command:
commands:
- show version
- show interface mgmt0
wait_for:
- "result[1].TABLE_interface.ROW_interface.state == up"
provider: "{{ nxapi }}"
register: result
- assert:
that:
- "result.changed == false"
- "result.stdout is defined"
- debug: msg="END nxapi/equal.yaml"

View File

@@ -1,34 +0,0 @@
---
- debug: msg="START nxapi/greaterthan.yaml"
- name: test gt operator
nxos_command:
commands:
- show version
- show interface mgmt0
wait_for:
- "result[1].TABLE_interface.ROW_interface.eth_ip_mask gt 0"
provider: "{{ nxapi }}"
register: result
- assert:
that:
- "result.changed == false"
- "result.stdout is defined"
- name: test > operator
nxos_command:
commands:
- show version
- show interface mgmt0
wait_for:
- "result[1].TABLE_interface.ROW_interface.eth_ip_mask gt 0"
provider: "{{ nxapi }}"
register: result
- assert:
that:
- "result.changed == false"
- "result.stdout is defined"
- debug: msg="END nxapi/greaterthan.yaml"

View File

@@ -1,34 +0,0 @@
---
- debug: msg="START nxapi/greaterthanorequal.yaml"
- name: test ge operator
nxos_command:
commands:
- show version
- show interface mgmt0
wait_for:
- "result[1].TABLE_interface.ROW_interface.eth_ip_mask ge 0"
provider: "{{ nxapi }}"
register: result
- assert:
that:
- "result.changed == false"
- "result.stdout is defined"
- name: test >= operator
nxos_command:
commands:
- show version
- show interface mgmt0
wait_for:
- "result[1].TABLE_interface.ROW_interface.eth_ip_mask >= 0"
provider: "{{ nxapi }}"
register: result
- assert:
that:
- "result.changed == false"
- "result.stdout is defined"
- debug: msg="END nxapi/greaterthanorequal.yaml"

View File

@@ -1,30 +0,0 @@
---
- debug: msg="START nxapi/invalid.yaml"
- name: run invalid command
nxos_command:
commands: ['show foo']
provider: "{{ nxapi }}"
register: result
ignore_errors: yes
- assert:
that:
- "result.failed == true"
- "result.msg is defined"
- name: run commands that include invalid command
nxos_command:
commands:
- show version
- show foo
provider: "{{ nxapi }}"
register: result
ignore_errors: yes
- assert:
that:
- "result.failed == true"
- "result.msg is defined"
- debug: msg="END nxapi/invalid.yaml"

View File

@@ -1,34 +0,0 @@
---
- debug: msg="START nxapi/lessthan.yaml"
- name: test lt operator
nxos_command:
commands:
- show version
- show interface mgmt0
wait_for:
- "result[1].TABLE_interface.ROW_interface.eth_ip_mask lt 33"
provider: "{{ nxapi }}"
register: result
- assert:
that:
- "result.changed == false"
- "result.stdout is defined"
- name: test < operator
nxos_command:
commands:
- show version
- show interface mgmt0
wait_for:
- "result[1].TABLE_interface.ROW_interface.eth_ip_mask lt 33"
provider: "{{ nxapi }}"
register: result
- assert:
that:
- "result.changed == false"
- "result.stdout is defined"
- debug: msg="END nxapi/lessthan.yaml"

View File

@@ -1,34 +0,0 @@
---
- debug: msg="START nxapi/lessthanorequal.yaml"
- name: test le operator
nxos_command:
commands:
- show version
- show interface mgmt0
wait_for:
- "result[1].TABLE_interface.ROW_interface.eth_ip_mask le 32"
provider: "{{ nxapi }}"
register: result
- assert:
that:
- "result.changed == false"
- "result.stdout is defined"
- name: test <= operator
nxos_command:
commands:
- show version
- show interface mgmt0
wait_for:
- "result[1].TABLE_interface.ROW_interface.eth_ip_mask <= 32"
provider: "{{ nxapi }}"
register: result
- assert:
that:
- "result.changed == false"
- "result.stdout is defined"
- debug: msg="END nxapi/lessthanorequal.yaml"

View File

@@ -1,34 +0,0 @@
---
- debug: msg="START nxapi/notequal.yaml"
- name: test neq operator
nxos_command:
commands:
- show version
- show interface mgmt0
wait_for:
- "result[1].TABLE_interface.ROW_interface.state neq down"
provider: "{{ nxapi }}"
register: result
- assert:
that:
- "result.changed == false"
- "result.stdout is defined"
- name: test != operator
nxos_command:
commands:
- show version
- show interface mgmt0
wait_for:
- "result[1].TABLE_interface.ROW_interface.state != down"
provider: "{{ nxapi }}"
register: result
- assert:
that:
- "result.changed == false"
- "result.stdout is defined"
- debug: msg="START nxapi/notequal.yaml"

View File

@@ -1,28 +0,0 @@
---
- debug: msg="START nxapi/output.yaml"
- name: get output for single command
nxos_command:
commands: ['show version']
provider: "{{ nxapi }}"
register: result
- assert:
that:
- "result.changed == false"
- "result.stdout is defined"
- name: get output for multiple commands
nxos_command:
commands:
- show version
- show interface
provider: "{{ nxapi }}"
register: result
- assert:
that:
- "result.changed == false"
- "result.stdout is defined"
- debug: msg="END nxapi/output.yaml"

View File

@@ -1,20 +1,16 @@
---
- debug: msg="START TRANSPORT:NXAPI nxos_command sanity test"
- debug: msg="Using provider={{ connection.transport }}"
when: ansible_connection == "local"
- debug: msg="START nxapi/sanity.yaml on connection={{ ansible_connection }}"
- name: "Disable feature BGP"
nxos_feature:
feature: bgp
state: disabled
provider: "{{ nxapi }}"
- block:
- name: "Run show running-config bgp - should fail"
nxos_command:
commands:
- sh running-config bgp
provider: "{{ nxapi }}"
ignore_errors: yes
register: result
@@ -26,14 +22,12 @@
nxos_feature:
feature: bgp
state: enabled
provider: "{{ nxapi }}"
- name: "Configure BGP defaults"
nxos_bgp: &configure_default
asn: 65535
router_id: 1.1.1.1
state: present
provider: "{{ nxapi }}"
register: result
- assert: &true
@@ -43,10 +37,7 @@
- name: "Run show running-config bgp - should pass"
nxos_command:
commands:
- command: sh running-config bgp
output: text
provider: "{{ nxapi }}"
timeout: 120
- sh running-config bgp
register: result
- assert:
@@ -58,7 +49,6 @@
nxos_command:
commands:
- show interface bief
provider: "{{ nxapi }}"
ignore_errors: yes
register: result
@@ -72,6 +62,5 @@
nxos_feature:
feature: bgp
state: disabled
provider: "{{ nxapi }}"
- debug: msg="END TRANSPORT:NXAPI nxos_command sanity test"
- debug: msg="END nxapi/sanity.yaml on connection={{ ansible_connection }}"

View File

@@ -1,20 +0,0 @@
---
- debug: msg="START nxapi/timeout.yaml"
- name: test bad condition
nxos_command:
commands:
- show version
wait_for:
- "result[0].header_str contains foo"
retries: 1
provider: "{{ nxapi }}"
register: result
ignore_errors: yes
- assert:
that:
- "result.failed == true"
- "result.msg is defined"
- debug: msg="END nxapi/timeout.yaml"