mirror of https://github.com/ansible/ansible.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
136 lines
6.3 KiB
YAML
136 lines
6.3 KiB
YAML
# Test code for the ACI modules
|
|
# Copyright: (c) 2017, Bruno Calogero <brunocalogero@hotmail.com>
|
|
|
|
# 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: Ensuring bindings do not already exist
|
|
aci_access_port_to_interface_policy_leaf_profile:
|
|
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) }}'
|
|
leaf_interface_profile: leafintprftest
|
|
access_port_selector: anstest_accessportselector
|
|
state: absent
|
|
|
|
- name: Ensuring Interface Policy Leaf profile exists for kick off
|
|
aci_interface_policy_leaf_profile: &aci_interface_policy_leaf_profile_present
|
|
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: present
|
|
leaf_interface_profile: leafintprftest
|
|
register: leaf_profile_present
|
|
|
|
# TODO: Ensure that leaf Policy Group Exists (module missing) (infra:AccPortGrp)
|
|
|
|
- name: Bind an Interface Access Port Selector to an Interface Policy Leaf Profile with a Policy Group - check mode works
|
|
aci_access_port_to_interface_policy_leaf_profile: &aci_access_port_to_interface_policy_leaf_profile_present
|
|
<<: *aci_interface_policy_leaf_profile_present
|
|
access_port_selector: anstest_accessportselector
|
|
check_mode: yes
|
|
register: accessport_to_intf_check_mode_present
|
|
|
|
- name: Bind an Interface Access Port Selector to an Interface Policy Leaf Profile with a Policy Group - creation works
|
|
aci_access_port_to_interface_policy_leaf_profile:
|
|
<<: *aci_access_port_to_interface_policy_leaf_profile_present
|
|
register: accessport_to_intf_present
|
|
|
|
- name: Bind an Interface Access Port Selector to an Interface Policy Leaf Profile with a Policy Group - idempotency works
|
|
aci_access_port_to_interface_policy_leaf_profile:
|
|
<<: *aci_access_port_to_interface_policy_leaf_profile_present
|
|
register: accessport_to_intf_idempotent
|
|
|
|
- name: Bind an Interface Access Port Selector to an Interface Policy Leaf Profile with a Policy Group - update works
|
|
aci_access_port_to_interface_policy_leaf_profile:
|
|
<<: *aci_access_port_to_interface_policy_leaf_profile_present
|
|
policy_group: anstest_policygroupname
|
|
register: accessport_to_intf_update
|
|
|
|
# TODO: also test for errors
|
|
- name: present assertions
|
|
assert:
|
|
that:
|
|
- accessport_to_intf_check_mode_present is changed
|
|
- accessport_to_intf_present is changed
|
|
- accessport_to_intf_present.previous == []
|
|
- 'accessport_to_intf_present.sent == {"infraHPortS": {"attributes": {"name": "anstest_accessportselector"}}}'
|
|
- accessport_to_intf_idempotent is not changed
|
|
- accessport_to_intf_idempotent.sent == {}
|
|
- accessport_to_intf_update is changed
|
|
- 'accessport_to_intf_update.sent == {"infraHPortS": {"attributes": {},"children": [{"infraRsAccBaseGrp": {"attributes": {"tDn": "uni/infra/funcprof/accportgrp-anstest_policygroupname"}}}]}}'
|
|
|
|
- name: Query Specific access_port_selector and leaf_interface_profile binding
|
|
aci_access_port_to_interface_policy_leaf_profile:
|
|
<<: *aci_interface_policy_leaf_profile_present
|
|
access_port_selector: anstest_accessportselector # "{{ fake_var | default(omit) }}" ?
|
|
state: query
|
|
register: binding_query
|
|
|
|
- name: present assertions
|
|
assert:
|
|
that:
|
|
- binding_query is not changed
|
|
- binding_query.current | length >= 1
|
|
- '"api/mo/uni/infra/accportprof-leafintprftest/hports-anstest_accessportselector-typ-range.json" in binding_query.url'
|
|
|
|
- name: Remove binding of interface access port selector and Interface Policy Leaf Profile - check mode
|
|
aci_access_port_to_interface_policy_leaf_profile: &aci_access_port_to_interface_policy_leaf_profile_absent
|
|
<<: *aci_interface_policy_leaf_profile_present
|
|
access_port_selector: anstest_accessportselector
|
|
state: absent
|
|
check_mode: yes
|
|
register: accessport_to_intf_check_mode_absent
|
|
|
|
- name: Remove binding of interface access port selector and Interface Policy Leaf Profile - delete works
|
|
aci_access_port_to_interface_policy_leaf_profile:
|
|
<<: *aci_access_port_to_interface_policy_leaf_profile_absent
|
|
register: accessport_to_intf_absent
|
|
|
|
- name: Remove binding of interface access port selector and Interface Policy Leaf Profile - idempotency works
|
|
aci_access_port_to_interface_policy_leaf_profile:
|
|
<<: *aci_access_port_to_interface_policy_leaf_profile_absent
|
|
register: accessport_to_intf_absent_idempotent
|
|
|
|
- name: Remove binding of interface access port selector and Interface Policy Leaf Profile - check mode
|
|
aci_access_port_to_interface_policy_leaf_profile:
|
|
<<: *aci_interface_policy_leaf_profile_present
|
|
#access_port_selector: anstest_accessportselector
|
|
state: absent
|
|
ignore_errors: yes
|
|
register: accessport_to_intf_absent_missing_param
|
|
|
|
- name: absent assertions
|
|
assert:
|
|
that:
|
|
- accessport_to_intf_check_mode_absent is changed
|
|
- accessport_to_intf_check_mode_absent.previous != []
|
|
- accessport_to_intf_absent is changed
|
|
- accessport_to_intf_absent.previous == accessport_to_intf_check_mode_absent.previous
|
|
- accessport_to_intf_absent_idempotent is not changed
|
|
- accessport_to_intf_absent_idempotent.previous == []
|
|
- accessport_to_intf_absent_missing_param is failed
|
|
- 'accessport_to_intf_absent_missing_param.msg == "state is absent but all of the following are missing: access_port_selector"'
|
|
|
|
|
|
- name: Remove an interface access port selector associated with an Interface Policy Leaf Profile - Clean up
|
|
aci_access_port_to_interface_policy_leaf_profile:
|
|
<<: *aci_access_port_to_interface_policy_leaf_profile_absent
|
|
state: absent
|
|
|
|
- name: Remove Interface policy leaf profile - Cleanup
|
|
aci_interface_policy_leaf_profile:
|
|
<<: *aci_interface_policy_leaf_profile_present
|
|
state: absent
|