mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
d8ba8c03f3
This functionality was not considered when the module was written, but there's no reason why it shouldn't be supported. We had to rework the query string construction and object filtering. This new functionality allows to filter on arbitrary keys and supports None values. This PR fixes various issues with the existing framework, including querying specific objects using construct_url_4 (i.e. aci_epg_to_contract and aci_static_binding_to_epg)
94 lines
3.1 KiB
YAML
94 lines
3.1 KiB
YAML
# Test code for the ACI modules
|
|
# Copyright: (c) 2017, Jacob McGill (@jmcgill298)
|
|
|
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
|
|
- name: Test that we have an ACI APIC host, ACI username and ACI password
|
|
fail:
|
|
msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.'
|
|
when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined
|
|
|
|
- name: ensure tenant does not exist for tests to kick off
|
|
aci_tenant: &aci_tenant_absent
|
|
host: "{{ aci_hostname }}"
|
|
username: "{{ aci_username }}"
|
|
password: "{{ aci_password }}"
|
|
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: absent
|
|
tenant: anstest
|
|
|
|
- name: create a snapshot
|
|
aci_config_snapshot: &create_snapshot
|
|
<<: *aci_tenant_absent
|
|
state: present
|
|
tenant: "{{ fakevar | default(omit) }}"
|
|
export_policy: anstest
|
|
|
|
- name: create a tenant - use for rollback
|
|
aci_tenant: &aci_tenant
|
|
<<: *create_snapshot
|
|
export_policy: "{{ fakevar | default(omit) }}"
|
|
tenant: anstest
|
|
register: tenant_present
|
|
|
|
- name: create a new snapshot
|
|
aci_config_snapshot:
|
|
<<: *create_snapshot
|
|
|
|
- name: get snapshots
|
|
aci_config_snapshot:
|
|
<<: *create_snapshot
|
|
state: query
|
|
register: snapshots
|
|
|
|
- name: compare snapshots
|
|
aci_config_rollback: &preview_rollback
|
|
<<: *create_snapshot
|
|
state: preview
|
|
compare_export_policy: anstest
|
|
compare_snapshot: "{{ snapshots.current.0.configSnapshotCont.children[-1].configSnapshot.attributes.name }}"
|
|
snapshot: "{{ snapshots.current.0.configSnapshotCont.children[-2].configSnapshot.attributes.name }}"
|
|
register: rollback_preview
|
|
|
|
- name: rollback to snapshot
|
|
aci_config_rollback: &aci_rollback
|
|
<<: *create_snapshot
|
|
state: rollback
|
|
snapshot: "{{ snapshots.current.0.configSnapshotCont.children[-1].configSnapshot.attributes.name }}"
|
|
ignore_errors: yes
|
|
register: rollback_missing_param
|
|
|
|
- name: rollback to snapshot
|
|
aci_config_rollback:
|
|
<<: *aci_rollback
|
|
import_policy: anstest
|
|
import_type: replace
|
|
import_mode: atomic
|
|
register: rollback_rollback
|
|
|
|
- name: pause execution to let rollback take effect
|
|
pause:
|
|
seconds: 15
|
|
|
|
- name: ensure tenant doesn't exist after rollback
|
|
aci_tenant:
|
|
<<: *aci_tenant_absent
|
|
register: tenant_removed
|
|
|
|
- name: rollback assertions
|
|
assert:
|
|
that:
|
|
- rollback_preview is not changed
|
|
- '"<fvTenant name=\"anstest\" rn=\"tn-anstest\" status=\"deleted\">" in rollback_preview.diff'
|
|
- '"snapshots.diff.xml" in rollback_preview.url'
|
|
- rollback_missing_param is failed
|
|
- 'rollback_missing_param.msg == "state is rollback but all of the following are missing: import_policy"'
|
|
- rollback_rollback is changed
|
|
- '"ce2_" in rollback_rollback.sent.configImportP.attributes.fileName'
|
|
- '".tar.gz" in rollback_rollback.sent.configImportP.attributes.fileName'
|
|
- '"fabric/configimp-anstest.json" in rollback_rollback.url'
|
|
- tenant_removed is not changed
|
|
- tenant_removed.previous == []
|