ACI: Change RETURN output as discussed (#35617)

* ACI: Change result output as discussed

* Update all modules to use new aci.exit_json()

* Update output_level spec and docs

* Fix integration tests

* Small PEP8 fix

* Asorted fixes to tests and aci_rest

* More test fixes and support for ANSIBLE_DEBUG

* Fix another PEP8 issues

* Move response handling inside ACI module

* Reform of ACI error handling and error output

* Diff multiline json output

* Fix a few more tests

* Revert aci_bd tests

* Small correction

* UI change: existing->current, original->previous

* UI change: config->sent

* Update all modules with RETURN values

* Fix a few more tests

* Improve docstring and add 'raw' return value

* Fix thinko

* Fix sanity/pep8 issues

* Rewrite unit tests to comply with new design
This commit is contained in:
Dag Wieers 2018-02-03 00:41:56 +01:00 committed by GitHub
commit bee765fa6b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
73 changed files with 5733 additions and 747 deletions

View file

@ -20,6 +20,7 @@
validate_certs: '{{ aci_validate_certs | default(false) }}'
use_ssl: '{{ aci_use_ssl | default(true) }}'
use_proxy: '{{ aci_use_proxy | default(true) }}'
output_level: debug
state: present
pool: anstest
pool_type: vlan
@ -44,7 +45,7 @@
assert:
that:
- range_present_check_mode.changed == true
- 'range_present_check_mode.config == {"fvnsEncapBlk": {"attributes": {"allocMode": "inherit", "descr": "Ansible Test", "from": "vlan-20", "name": "anstest", "to": "vlan-40"}}}'
- 'range_present_check_mode.sent == {"fvnsEncapBlk": {"attributes": {"allocMode": "inherit", "descr": "Ansible Test", "from": "vlan-20", "name": "anstest", "to": "vlan-40"}}}'
- name: create vlan pool range - creation works
aci_encap_pool_range:
@ -55,9 +56,9 @@
assert:
that:
- range_present.changed == true
- range_present.existing == []
- range_present.config == range_present_check_mode.config
- range_present.config == range_present.proposed
- range_present.previous == []
- range_present.sent == range_present_check_mode.sent
- range_present.sent == range_present.proposed
- name: create vlan pool range - idempotency works
aci_encap_pool_range:
@ -68,7 +69,7 @@
assert:
that:
- range_present_idempotent.changed == false
- 'range_present_idempotent.existing.0.fvnsEncapBlk.attributes.name == "anstest"'
- 'range_present_idempotent.previous.0.fvnsEncapBlk.attributes.name == "anstest"'
- name: update vlan pool range - update works
aci_encap_pool_range:
@ -81,8 +82,8 @@
assert:
that:
- range_present_update.changed == true
- range_present_update.existing != []
- range_present_update.config != range_present.config
- range_present_update.previous != []
- range_present_update.sent != range_present.sent
- name: create vlan pool range - used for query
aci_encap_pool_range: &aci_range_present_2
@ -96,7 +97,7 @@
assert:
that:
- range_present_2.changed == true
- range_present_2.existing == []
- range_present_2.previous == []
- name: invalid range_start - error message works
aci_encap_pool_range:
@ -212,8 +213,8 @@
that:
- range_query.changed == false
- range_query.url.endswith("infra/vlanns-[anstest]-static/from-[vlan-20]-to-[vlan-40].json")
- range_query.existing | length == 1
- 'range_query.existing.0.fvnsEncapBlk.attributes.name == "anstest"'
- range_query.previous | length == 1
- 'range_query.previous.0.fvnsEncapBlk.attributes.name == "anstest"'
- name: query vlan pool range - from, to, and name are filtered
aci_encap_pool_range: &aci_range_query_filter
@ -227,9 +228,9 @@
- range_query_from_to_name.changed == false
- 'range_query_from_to_name.url.endswith("class/fvnsEncapBlk.json")'
- '"query-target-filter=and(eq(fvnsEncapBlk.from, \"vlan-20\"),eq(fvnsEncapBlk.to, \"vlan-40\"),eq(fvnsEncapBlk.name, \"anstest\"))" in range_query_from_to_name.filter_string'
- 'range_query_from_to_name.existing.0.fvnsEncapBlk.attributes.name == "anstest"'
- 'range_query_from_to_name.existing.0.fvnsEncapBlk.attributes.from == "vlan-20"'
- 'range_query_from_to_name.existing.0.fvnsEncapBlk.attributes.to == "vlan-40"'
- 'range_query_from_to_name.previous.0.fvnsEncapBlk.attributes.name == "anstest"'
- 'range_query_from_to_name.previous.0.fvnsEncapBlk.attributes.from == "vlan-20"'
- 'range_query_from_to_name.previous.0.fvnsEncapBlk.attributes.to == "vlan-40"'
- name: query vlan pool range - from and name are filtered
aci_encap_pool_range:
@ -243,8 +244,8 @@
- range_query_from_name.changed == false
- 'range_query_from_name.url.endswith("class/fvnsEncapBlk.json")'
- '"query-target-filter=and(eq(fvnsEncapBlk.from, \"vlan-20\"),eq(fvnsEncapBlk.name, \"anstest\"))" in range_query_from_name.filter_string'
- 'range_query_from_name.existing.0.fvnsEncapBlk.attributes.name == "anstest"'
- 'range_query_from_name.existing.0.fvnsEncapBlk.attributes.from == "vlan-20"'
- 'range_query_from_name.previous.0.fvnsEncapBlk.attributes.name == "anstest"'
- 'range_query_from_name.previous.0.fvnsEncapBlk.attributes.from == "vlan-20"'
- name: query vlan pool range - to and name are filtered
aci_encap_pool_range:
@ -258,8 +259,8 @@
- range_query_to_name.changed == false
- 'range_query_to_name.url.endswith("class/fvnsEncapBlk.json")'
- '"query-target-filter=and(eq(fvnsEncapBlk.to, \"vlan-40\"),eq(fvnsEncapBlk.name, \"anstest\"))" in range_query_to_name.filter_string'
- 'range_query_to_name.existing.0.fvnsEncapBlk.attributes.name == "anstest"'
- 'range_query_to_name.existing.0.fvnsEncapBlk.attributes.to == "vlan-40"'
- 'range_query_to_name.previous.0.fvnsEncapBlk.attributes.name == "anstest"'
- 'range_query_to_name.previous.0.fvnsEncapBlk.attributes.to == "vlan-40"'
- name: query vlan pool range - name is filtered
aci_encap_pool_range:
@ -274,7 +275,7 @@
- range_query_name.changed == false
- 'range_query_name.url.endswith("class/fvnsEncapBlk.json")'
- '"query-target-filter=eq(fvnsEncapBlk.name, \"anstest\")" in range_query_name.filter_string'
- 'range_query_name.existing.0.fvnsEncapBlk.attributes.name == "anstest"'
- 'range_query_name.previous.0.fvnsEncapBlk.attributes.name == "anstest"'
- name: query vlan pool range - from and to are filtered
aci_encap_pool_range:
@ -288,8 +289,8 @@
- range_query_from_to.changed == false
- 'range_query_from_to.url.endswith("class/fvnsEncapBlk.json")'
- '"query-target-filter=and(eq(fvnsEncapBlk.from, \"vlan-20\"),eq(fvnsEncapBlk.to, \"vlan-40\"))" in range_query_from_to.filter_string'
- 'range_query_from_to.existing.0.fvnsEncapBlk.attributes.from == "vlan-20"'
- 'range_query_from_to.existing.0.fvnsEncapBlk.attributes.to == "vlan-40"'
- 'range_query_from_to.previous.0.fvnsEncapBlk.attributes.from == "vlan-20"'
- 'range_query_from_to.previous.0.fvnsEncapBlk.attributes.to == "vlan-40"'
- name: query all ranges in a vlan pool
aci_encap_pool_range:
@ -301,9 +302,9 @@
- name: query assertions
assert:
that:
- range_query_pool.existing | length == 1
- 'range_query_pool.existing.0.fvnsVlanInstP.attributes.name == "anstest"'
- range_query_pool.existing.0.fvnsVlanInstP.children | length > 1
- range_query_pool.previous | length == 1
- 'range_query_pool.previous.0.fvnsVlanInstP.attributes.name == "anstest"'
- range_query_pool.previous.0.fvnsVlanInstP.children | length > 1
- 'range_query_pool.url.endswith("infra/vlanns-[anstest]-static.json")'
- name: query all ranges
@ -317,8 +318,8 @@
assert:
that:
- range_query_all.changed == false
- range_query_all.existing | length > 1
- range_query_all.existing.0.fvnsEncapBlk is defined
- range_query_all.previous | length > 1
- range_query_all.previous.0.fvnsEncapBlk is defined
- 'range_query_all.url.endswith("class/fvnsEncapBlk.json")'
- name: delete vlan pool range - deletion works
@ -332,7 +333,7 @@
that:
- delete_range.changed == true
- delete_range.proposed == {}
- 'delete_range.existing.0.fvnsEncapBlk.attributes.name == "anstest"'
- 'delete_range.previous.0.fvnsEncapBlk.attributes.name == "anstest"'
- name: delete vlan pool range - check mode works
aci_encap_pool_range: &aci_range_absent
@ -345,7 +346,7 @@
assert:
that:
- delete_check_mode.changed == true
- delete_check_mode.existing != []
- delete_check_mode.previous != []
- name: delete vlan pool range - deletion works
aci_encap_pool_range:
@ -356,7 +357,7 @@
assert:
that:
- delete_range_2.changed == true
- delete_range_2.existing == delete_check_mode.existing
- delete_range_2.previous == delete_check_mode.previous
- name: delete vlan pool range again - idempotency works
aci_encap_pool_range:
@ -367,7 +368,7 @@
assert:
that:
- delete_idempotent.changed == false
- delete_idempotent.existing == []
- delete_idempotent.previous == []
- name: cleanup vlan pool
aci_encap_pool: