Debian Codegraph @

ansible_collections/cisco/aci/tests/integration/targets/aci_rest/tasks/xml_file.yml

raw symbols SCIP
1 # Test code for the ACI modules
2 # Copyright: (c) 2022, Sabari Jaganathan (@sajagana) <[email protected]>
3
4 # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
5
6 # SET VARS
7 - name: Set vars
8 ansible.builtin.set_fact:
9 aci_info: &aci_info
10 host: '{{ aci_hostname }}'
11 username: '{{ aci_username }}'
12 password: '{{ aci_password }}'
13 validate_certs: '{{ aci_validate_certs | default(false) }}'
14 use_ssl: '{{ aci_use_ssl | default(true) }}'
15 use_proxy: '{{ aci_use_proxy | default(true) }}'
16 output_level: '{{ aci_output_level | default("debug") }}'
17 output_path: "/tmp/ansible_output_file.log"
18
19 - name: Ensure tenant does not exists using ans_test_delete xml template
20 cisco.aci.aci_rest: &tenant_delete
21 <<: *aci_info
22 path: /api/mo/uni.xml
23 src: "./targets/aci_rest/tasks/xml_files/tn-ans_test_delete.xml"
24 method: post
25
26 - name: Add tenant using ans_test_create xml template file with check mode
27 cisco.aci.aci_rest:
28 <<: *aci_info
29 path: /api/mo/uni.xml
30 src: "./targets/aci_rest/tasks/xml_files/tn-ans_test_create.xml"
31 method: post
32 check_mode: true
33 register: cm_add_tenant
34
35 - name: Verify checkmode did not create tenant
36 cisco.aci.aci_tenant:
37 host: '{{ aci_hostname }}'
38 username: '{{ aci_username }}'
39 password: '{{ aci_password }}'
40 validate_certs: '{{ aci_validate_certs | default(false) }}'
41 use_ssl: '{{ aci_use_ssl | default(true) }}'
42 use_proxy: '{{ aci_use_proxy | default(true) }}'
43 output_level: '{{ aci_output_level | default("info") }}'
44 name: ans_test_create
45 state: query
46 register: cm_verify_checkmode_tenant
47
48 - name: Assertions check for add tenant using ans_test_create xml template file with check mode
49 ansible.builtin.assert:
50 that:
51 - cm_add_tenant is changed
52 - '"ans_test_create" in cm_add_tenant.proposed'
53 - '"orchestrator:ansible" in cm_add_tenant.proposed'
54 - cm_verify_checkmode_tenant.current == []
55
56 - name: Add tenant using ans_test_create xml template file with normal mode
57 cisco.aci.aci_rest:
58 <<: *aci_info
59 path: /api/mo/uni.xml
60 src: "./targets/aci_rest/tasks/xml_files/tn-ans_test_create.xml"
61 method: post
62 register: nm_add_tenant
63
64 - name: Assertions check for add tenant using ans_test_create xml template file with normal mode
65 ansible.builtin.assert:
66 that:
67 - nm_add_tenant is changed
68 - nm_add_tenant.imdata.0.fvTenant.attributes.name == "ans_test_create"
69 - nm_add_tenant.imdata.0.fvTenant.attributes.descr == "ans_test_create tenant created successfully"
70 - nm_add_tenant.imdata.0.fvTenant.attributes.dn == "uni/tn-ans_test_create"
71 - nm_add_tenant.imdata.0.fvTenant.attributes.annotation == "orchestrator:ansible"
72 - nm_add_tenant.imdata.0.fvTenant.children != []
73
74 - name: Add tenant using ans_test_create xml template file with normal mode - idempotency works
75 cisco.aci.aci_rest:
76 <<: *aci_info
77 path: /api/mo/uni.xml
78 src: "./targets/aci_rest/tasks/xml_files/tn-ans_test_create.xml"
79 method: post
80 register: idempotency_nm_add_tenant
81
82 - name: Idempotency assertions check for add tenant using ans_test_create xml template file with normal mode
83 ansible.builtin.assert:
84 that:
85 - idempotency_nm_add_tenant is not changed
86
87 - name: Query ans_test_create tenant using query string after the create
88 cisco.aci.aci_rest:
89 <<: *aci_info
90 path: "/api/node/mo/uni/tn-ans_test_create.json?query-target=self"
91 method: get
92 register: query_ans_test_create
93
94 - name: Assertions check for querying ans_test_create tenant using query string after the create
95 ansible.builtin.assert:
96 that:
97 - query_ans_test_create is not changed
98 - query_ans_test_create.imdata != []
99 - query_ans_test_create.imdata.0.fvTenant.attributes.name == "ans_test_create"
100 - query_ans_test_create.imdata.0.fvTenant.attributes.descr == "ans_test_create tenant created successfully"
101 - query_ans_test_create.imdata.0.fvTenant.attributes.dn == "uni/tn-ans_test_create"
102
103 - name: Update tenant description using ans_test_update xml template file with check mode
104 cisco.aci.aci_rest:
105 <<: *aci_info
106 path: /api/mo/uni.xml
107 src: "./targets/aci_rest/tasks/xml_files/tn-ans_test_update.xml"
108 method: post
109 check_mode: true
110 register: cm_update_tenant
111
112 - name: Assertions check for update tenant description using ans_test_update xml template file with check mode
113 ansible.builtin.assert:
114 that:
115 - cm_update_tenant is changed
116
117 - name: Update tenant description using ans_test_update xml template file with normal mode
118 cisco.aci.aci_rest:
119 <<: *aci_info
120 path: /api/mo/uni.xml
121 src: "./targets/aci_rest/tasks/xml_files/tn-ans_test_update.xml"
122 method: post
123 register: nm_update_tenant
124
125 - name: Assertions check for update tenant description using ans_test_update xml template file with normal mode
126 ansible.builtin.assert:
127 that:
128 - nm_update_tenant is changed
129 - nm_update_tenant.imdata.0.fvTenant.attributes.name == "ans_test_create"
130 - nm_update_tenant.imdata.0.fvTenant.attributes.descr == "ans_test_create tenant updated successfully"
131 - nm_update_tenant.imdata.0.fvTenant.attributes.dn == "uni/tn-ans_test_create"
132
133 - name: Update tenant description using ans_test_update xml template file with normal mode - idempotency works
134 cisco.aci.aci_rest:
135 <<: *aci_info
136 path: /api/mo/uni.xml
137 src: "./targets/aci_rest/tasks/xml_files/tn-ans_test_update.xml"
138 method: post
139 register: idempotency_nm_update_tenant
140
141 - name: Idempotency assertions check for update tenant description using ans_test_update xml template file with normal mode
142 ansible.builtin.assert:
143 that:
144 - idempotency_nm_update_tenant is not changed
145
146 - name: Query ans_test_create tenant using query string after the update
147 cisco.aci.aci_rest:
148 <<: *aci_info
149 path: "/api/node/mo/uni/tn-ans_test_create.json?query-target=self"
150 method: get
151 register: query_ans_test_update
152
153 - name: Assertions check for querying ans_test_create tenant using query string after the update
154 ansible.builtin.assert:
155 that:
156 - query_ans_test_update is not changed
157 - query_ans_test_update.imdata != []
158 - query_ans_test_update.imdata.0.fvTenant.attributes.name == "ans_test_create"
159 - query_ans_test_update.imdata.0.fvTenant.attributes.descr == "ans_test_create tenant updated successfully"
160 - query_ans_test_update.imdata.0.fvTenant.attributes.dn == "uni/tn-ans_test_create"
161
162 - name: Update tenant name using ans_test_negative_update_check xml template file with normal mode
163 cisco.aci.aci_rest:
164 <<: *aci_info
165 path: /api/mo/uni.xml
166 src: "./targets/aci_rest/tasks/xml_files/tn-ans_test_negative_update_check.xml"
167 method: post
168 register: negative_update_tenant_check
169 ignore_errors: true
170
171 - name: Assertions check for update tenant name using ans_test_negative_update_check xml template file with normal mode
172 ansible.builtin.assert:
173 that:
174 - negative_update_tenant_check is failed
175
176 - name: Delete tenant using ans_test_delete xml template file with check mode
177 cisco.aci.aci_rest:
178 <<: *aci_info
179 path: /api/mo/uni.xml
180 src: "./targets/aci_rest/tasks/xml_files/tn-ans_test_delete.xml"
181 method: post
182 check_mode: true
183 register: cm_delete_tenant
184
185 - name: Assertions check for delete tenant using ans_test_delete xml template file with check mode
186 ansible.builtin.assert:
187 that:
188 - cm_delete_tenant is changed
189
190 - name: Delete tenant using ans_test_delete xml template file with normal mode
191 cisco.aci.aci_rest:
192 <<: *aci_info
193 path: /api/mo/uni.xml
194 src: "./targets/aci_rest/tasks/xml_files/tn-ans_test_delete.xml"
195 method: post
196 register: nm_delete_tenant
197
198 - name: Assertions check for delete tenant using ans_test_delete xml template file with normal mode
199 ansible.builtin.assert:
200 that:
201 - nm_delete_tenant is changed
202 - nm_delete_tenant.imdata.0.fvTenant.attributes.name == "ans_test_create"
203 - nm_delete_tenant.imdata.0.fvTenant.attributes.descr == "ans_test_create tenant updated successfully"
204 - nm_delete_tenant.imdata.0.fvTenant.attributes.dn == "uni/tn-ans_test_create"
205
206 - name: Delete tenant using ans_test_delete xml template file with normal mode - idempotency works
207 cisco.aci.aci_rest:
208 <<: *aci_info
209 path: /api/mo/uni.xml
210 src: "./targets/aci_rest/tasks/xml_files/tn-ans_test_delete.xml"
211 method: post
212 register: idempotency_nm_delete_tenant
213
214 - name: Idempotency assertions check for delete tenant using ans_test_delete xml template file with normal mode
215 ansible.builtin.assert:
216 that:
217 - idempotency_nm_delete_tenant is not changed
218 - idempotency_nm_delete_tenant.imdata == {}
219
220 - name: Query ans_test_create tenant using query string after the delete
221 cisco.aci.aci_rest:
222 <<: *aci_info
223 path: "/api/node/mo/uni/tn-ans_test_create.json?query-target=self"
224 method: get
225 register: query_ans_test_delete
226
227 - name: Assertions check for querying ans_test_create tenant using query string after the delete
228 ansible.builtin.assert:
229 that:
230 - query_ans_test_delete is not changed
231 - query_ans_test_delete.imdata == []
232
233 # VERIFY ANNOTATION SUPPORT
234 - name: Add tenant with annotation option
235 cisco.aci.aci_rest:
236 host: '{{ aci_hostname }}'
237 username: '{{ aci_username }}'
238 password: '{{ aci_password }}'
239 validate_certs: '{{ aci_validate_certs | default(false) }}'
240 use_ssl: '{{ aci_use_ssl | default(true) }}'
241 use_proxy: '{{ aci_use_proxy | default(true) }}'
242 output_level: '{{ aci_output_level | default("info") }}'
243 path: /api/mo/uni.xml
244 method: post
245 annotation: test:inoption
246 src: "./targets/aci_rest/tasks/xml_files/tn-ans_test_create.xml"
247 register: nm_add_tenant_annotation_option
248
249 - name: Add tenant with annotation in content
250 cisco.aci.aci_rest:
251 host: '{{ aci_hostname }}'
252 username: '{{ aci_username }}'
253 password: '{{ aci_password }}'
254 validate_certs: '{{ aci_validate_certs | default(false) }}'
255 use_ssl: '{{ aci_use_ssl | default(true) }}'
256 use_proxy: '{{ aci_use_proxy | default(true) }}'
257 output_level: '{{ aci_output_level | default("info") }}'
258 path: /api/mo/uni.xml
259 method: post
260 src: "./targets/aci_rest/tasks/xml_files/tn-ans_test_annotation.xml"
261 register: nm_add_tenant_annotation_content
262
263 - name: Remove tenant
264 cisco.aci.aci_rest: *tenant_delete
265
266 - name: Add tenant with annotation in content and option
267 cisco.aci.aci_rest:
268 host: '{{ aci_hostname }}'
269 username: '{{ aci_username }}'
270 password: '{{ aci_password }}'
271 validate_certs: '{{ aci_validate_certs | default(false) }}'
272 use_ssl: '{{ aci_use_ssl | default(true) }}'
273 use_proxy: '{{ aci_use_proxy | default(true) }}'
274 output_level: '{{ aci_output_level | default("info") }}'
275 path: /api/mo/uni.xml
276 method: post
277 annotation: test:inoption
278 src: "./targets/aci_rest/tasks/xml_files/tn-ans_test_annotation.xml"
279 register: nm_add_tenant_annotation_option_content
280
281 - name: Add tag to tenant with annotation unsupported
282 cisco.aci.aci_rest:
283 host: '{{ aci_hostname }}'
284 username: '{{ aci_username }}'
285 password: '{{ aci_password }}'
286 validate_certs: '{{ aci_validate_certs | default(false) }}'
287 use_ssl: '{{ aci_use_ssl | default(true) }}'
288 use_proxy: '{{ aci_use_proxy | default(true) }}'
289 output_level: '{{ aci_output_level | default("info") }}'
290 path: /api/mo/uni/tn-ans_test_create/tagKey-foo.xml
291 method: post
292 annotation: test:inoption
293 src: "./targets/aci_rest/tasks/xml_files/tag.xml"
294 register: nm_add_tag_no_annotation
295
296 - name: Remove tenant
297 cisco.aci.aci_rest: *tenant_delete
298
299 - name: Add tenant with children objects including annotation
300 cisco.aci.aci_rest:
301 host: '{{ aci_hostname }}'
302 username: '{{ aci_username }}'
303 password: '{{ aci_password }}'
304 validate_certs: '{{ aci_validate_certs | default(false) }}'
305 use_ssl: '{{ aci_use_ssl | default(true) }}'
306 use_proxy: '{{ aci_use_proxy | default(true) }}'
307 output_level: '{{ aci_output_level | default("info") }}'
308 path: /api/mo/uni.xml
309 method: post
310 annotation: test:inoption
311 src: "./targets/aci_rest/tasks/xml_files/tn-ans_test_annotation_children.xml"
312 register: nm_add_tenant_annotation_children
313
314 - name: Verify annotation support
315 assert:
316 that:
317 - nm_add_tenant_annotation_option.imdata.0.fvTenant.attributes.annotation == "test:inoption"
318 - nm_add_tenant_annotation_content.imdata.0.fvTenant.attributes.annotation == "test:optionincontent"
319 - nm_add_tenant_annotation_option_content.imdata.0.fvTenant.attributes.annotation == "test:optionincontent"
320 - nm_add_tag_no_annotation.imdata.0.tagTag.attributes.annotation is undefined
321 - nm_add_tenant_annotation_children.imdata.0.fvTenant.attributes.annotation == "test:inoption"
322 - nm_add_tenant_annotation_children.imdata.0.fvTenant.children.0.fvAp.attributes.annotation == "test:inoption"
323 - nm_add_tenant_annotation_children.imdata.0.fvTenant.children.0.fvAp.children.0.fvAEPg.attributes.annotation == "test:inchild"
324 - nm_add_tenant_annotation_children.imdata.0.fvTenant.children.1.fvCtx.attributes.annotation == "test:inoption"