Skip to content

Commit 24526b6

Browse files
gmicollhercot
authored andcommitted
[ignore] add test case for aci_route_control_profile.
1 parent 4618fa3 commit 24526b6

File tree

3 files changed

+148
-1
lines changed

3 files changed

+148
-1
lines changed

plugins/modules/aci_route_control_profile.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ def main():
189189
auto_continue=dict(type="str", default="no", choices=["no", "yes"]),
190190
policy_type=dict(type="str", default="combinable", choices=["combinable", "global"]),
191191
name_alias=dict(type="str"),
192+
state=dict(type="str", default="present", choices=["present", "absent", "query"]),
192193
)
193194

194195
module = AnsibleModule(
@@ -219,7 +220,7 @@ def main():
219220
)
220221

221222
route_control_profile_url_config = dict(
222-
aci_class="rtcrtlProfile",
223+
aci_class="rtctrlProfile",
223224
aci_rn="prof-{0}".format(route_control_profile),
224225
module_object=route_control_profile,
225226
target_filter={"name": route_control_profile},
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# No ACI simulator yet, so not enabled
2+
# unsupported
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
# Test code for the ACI modules
2+
# Copyright: (c) 2023, Gaspard Micol (@gmicol)
3+
4+
# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
5+
6+
- name: Test that we have an ACI APIC host, ACI username and ACI password
7+
fail:
8+
msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.'
9+
when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined
10+
11+
- name: Set vars
12+
set_fact:
13+
aci_info: &aci_info
14+
host: "{{ aci_hostname }}"
15+
username: "{{ aci_username }}"
16+
password: "{{ aci_password }}"
17+
validate_certs: '{{ aci_validate_certs | default(false) }}'
18+
use_ssl: '{{ aci_use_ssl | default(true) }}'
19+
use_proxy: '{{ aci_use_proxy | default(true) }}'
20+
output_level: debug
21+
22+
# CLEAN ENVIRONMENT
23+
- name: Remove the ansible_tenant
24+
aci_tenant: &aci_tenant_absent
25+
<<: *aci_info
26+
tenant: ansible_tenant
27+
state: absent
28+
29+
- name: Verify Cloud and Non-Cloud Sites in use.
30+
include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml
31+
32+
- name: Execute tasks only for non-cloud sites
33+
when: query_cloud.current == [] # This condition will execute only non-cloud sites
34+
block: # block specifies execution of tasks within, based on conditions
35+
- name: Add a new tenant
36+
aci_tenant: &aci_tenant_present
37+
<<: *aci_info
38+
tenant: ansible_tenant
39+
description: Ansible tenant
40+
state: present
41+
42+
- name: Add a new L3Out
43+
aci_l3out:
44+
<<: *aci_info
45+
tenant: ansible_tenant
46+
l3out: ansible_l3out
47+
description: L3Out for ansible_tenant tenant
48+
domain: ansible_dom
49+
vrf: ansible_vrf
50+
state: present
51+
52+
- name: Add route control profile for l3out (check_mode)
53+
aci_route_control_profile: &aci_route_control_profile_present
54+
<<: *aci_info
55+
tenant: ansible_tenant
56+
l3out: ansible_l3out
57+
route_control_profile: ansible_rtctrl_profile_l3out
58+
description: Route Control Profile for ansible_l3out L3Out
59+
auto_continue: no
60+
policy_type: combinable
61+
state: present
62+
check_mode: true
63+
register: cm_add_route_control_profile
64+
65+
- name: Add route control profile for l3out (normal_mode)
66+
aci_route_control_profile:
67+
<<: *aci_route_control_profile_present
68+
register: nm_add_route_control_profile
69+
70+
- name: Add route control profile for l3out again - testing idempotency
71+
aci_route_control_profile:
72+
<<: *aci_route_control_profile_present
73+
register: nm_add_route_control_profile_idempotency
74+
75+
- name: Add route control profile for tenant (normal_mode)
76+
aci_route_control_profile:
77+
<<: *aci_info
78+
tenant: ansible_tenant
79+
route_control_profile: ansible_rtctrl_profile_tenant
80+
description: Route Control Profile for ansible_tenant tenant
81+
state: present
82+
register: nm_add_route_control_profile_2
83+
84+
- name: Asserts for route control profiles creation tasks
85+
assert:
86+
that:
87+
- cm_add_route_control_profile is changed
88+
- cm_add_route_control_profile.previous == []
89+
- cm_add_route_control_profile.current == []
90+
- nm_add_route_control_profile is changed
91+
- nm_add_route_control_profile_idempotency is not changed
92+
- nm_add_route_control_profile_2 is changed
93+
- nm_add_route_control_profile_2.previous == []
94+
95+
- name: Query all route control profiles
96+
aci_route_control_profile:
97+
<<: *aci_info
98+
state: query
99+
register: query_all_route_control_profile
100+
101+
- name: Query ansible_rtctrl_profile_l3out
102+
aci_route_control_profile:
103+
<<: *aci_route_control_profile_present
104+
state: query
105+
register: query_ansible_rtctrl_profile_l3out
106+
107+
- name: Asserts query tasks
108+
assert:
109+
that:
110+
- query_all_route_control_profile is not changed
111+
- query_all_route_control_profile.current|length >= 2
112+
113+
- name: Remove route control profile for l3out (check_mode)
114+
aci_route_control_profile: &route_control_profile_absent
115+
<<: *aci_route_control_profile_present
116+
state: absent
117+
check_mode: true
118+
register: cm_remove_route_control_profile
119+
120+
- name: Remove route control profile for l3out (normal_mode)
121+
aci_route_control_profile:
122+
<<: *route_control_profile_absent
123+
register: nm_remove_route_control_profile
124+
125+
- name: Remove route control profile for l3out - testing idempotency
126+
aci_route_control_profile:
127+
<<: *route_control_profile_absent
128+
register: nm_remove_route_control_profile_idempotency
129+
130+
- name: Asserts deletion tasks
131+
assert:
132+
that:
133+
- cm_remove_route_control_profile is changed
134+
- cm_remove_route_control_profile.proposed == {}
135+
- nm_remove_route_control_profile is changed
136+
- nm_remove_route_control_profile.previous != []
137+
- nm_remove_route_control_profile.method == "DELETE"
138+
- nm_remove_route_control_profile_idempotency is not changed
139+
- nm_remove_route_control_profile_idempotency.previous == []
140+
141+
- name: Remove the ansible_tenant - cleanup before ending tests
142+
aci_tenant:
143+
<<: *aci_tenant_present
144+
state: absent

0 commit comments

Comments
 (0)