Skip to content

Commit ef3845b

Browse files
committed
[ignore] Added accidentally removed test file
1 parent 434f044 commit ef3845b

File tree

2 files changed

+323
-0
lines changed

2 files changed

+323
-0
lines changed
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: 321 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,321 @@
1+
# Test code for the ACI modules
2+
# Copyright: (c) 2025, Tim Cragg (@timcragg)
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+
# GET Credentials from the inventory
12+
- name: Set vars
13+
set_fact:
14+
aci_info: &aci_info
15+
host: "{{ aci_hostname }}"
16+
username: "{{ aci_username }}"
17+
password: "{{ aci_password }}"
18+
validate_certs: '{{ aci_validate_certs | default(false) }}'
19+
use_ssl: '{{ aci_use_ssl | default(true) }}'
20+
use_proxy: '{{ aci_use_proxy | default(true) }}'
21+
output_level: '{{ aci_output_level | default("info") }}'
22+
23+
- name: Query system information
24+
cisco.aci.aci_system:
25+
<<: *aci_info
26+
id: 1
27+
state: query
28+
register: version
29+
30+
# CLEAN ENVIRONMENT
31+
- name: Remove ansible_tenant if it already exists
32+
cisco.aci.aci_tenant:
33+
<<: *aci_info
34+
name: ansible_tenant
35+
state: absent
36+
37+
# CREATE TENANT
38+
- name: Create ansible_tenant
39+
cisco.aci.aci_tenant:
40+
<<: *aci_info
41+
name: ansible_tenant
42+
state: present
43+
44+
# CREATE ICMP SLA POLICY
45+
- name: Create ICMP SLA policy in check_mode
46+
cisco.aci.aci_ip_sla_monitoring_policy: &create_sla
47+
<<: *aci_info
48+
tenant: ansible_tenant
49+
sla_policy: ansible_sla
50+
sla_type: icmp
51+
frequency: 40
52+
multiplier: 6
53+
state: present
54+
check_mode: true
55+
register: create_icmp_sla_cm
56+
57+
- name: Verify SLA creation for check mode
58+
ansible.builtin.assert:
59+
that:
60+
- create_icmp_sla_cm is changed
61+
- create_icmp_sla_cm.proposed.fvIPSLAMonitoringPol.attributes.dn == "uni/tn-ansible_tenant/ipslaMonitoringPol-ansible_sla"
62+
- create_icmp_sla_cm.proposed.fvIPSLAMonitoringPol.attributes.name == "ansible_sla"
63+
- create_icmp_sla_cm.proposed.fvIPSLAMonitoringPol.attributes.slaDetectMultiplier == "6"
64+
- create_icmp_sla_cm.proposed.fvIPSLAMonitoringPol.attributes.slaFrequency == "40"
65+
- create_icmp_sla_cm.proposed.fvIPSLAMonitoringPol.attributes.slaPort == "0"
66+
- create_icmp_sla_cm.proposed.fvIPSLAMonitoringPol.attributes.slaType == "icmp"
67+
68+
# CREATE ICMP SLA POLICY
69+
- name: Create ICMP SLA policy
70+
cisco.aci.aci_ip_sla_monitoring_policy:
71+
<<: *create_sla
72+
register: create_icmp_sla
73+
74+
- name: Verify SLA creation
75+
ansible.builtin.assert:
76+
that:
77+
- create_icmp_sla is changed
78+
- create_icmp_sla.previous == []
79+
- create_icmp_sla.current.0.fvIPSLAMonitoringPol.attributes.dn == "uni/tn-ansible_tenant/ipslaMonitoringPol-ansible_sla"
80+
- create_icmp_sla.current.0.fvIPSLAMonitoringPol.attributes.name == "ansible_sla"
81+
- create_icmp_sla.current.0.fvIPSLAMonitoringPol.attributes.slaDetectMultiplier == "6"
82+
- create_icmp_sla.current.0.fvIPSLAMonitoringPol.attributes.slaFrequency == "40"
83+
- create_icmp_sla.current.0.fvIPSLAMonitoringPol.attributes.slaPort == "0"
84+
- create_icmp_sla.current.0.fvIPSLAMonitoringPol.attributes.slaType == "icmp"
85+
86+
# CREATE ICMP SLA POLICY AGAIN TO TEST IDEMPOTENCE
87+
- name: Create ICMP SLA policy again
88+
cisco.aci.aci_ip_sla_monitoring_policy:
89+
<<: *create_sla
90+
register: create_icmp_sla_again
91+
92+
- name: Verify SLA creation idempotence
93+
ansible.builtin.assert:
94+
that:
95+
- create_icmp_sla_again is not changed
96+
- create_icmp_sla_again.current == create_icmp_sla.current == create_icmp_sla_again.previous
97+
98+
# CREATE SECOND SLA POLICY
99+
- name: Create Second SLA policy
100+
cisco.aci.aci_ip_sla_monitoring_policy:
101+
<<: *aci_info
102+
tenant: ansible_tenant
103+
sla_policy: second_ansible_sla
104+
sla_type: icmp
105+
frequency: 40
106+
multiplier: 6
107+
state: present
108+
109+
# CREATE HTTP SLA POLICY
110+
- name: Create HTTP SLA policy
111+
cisco.aci.aci_ip_sla_monitoring_policy:
112+
<<: *aci_info
113+
tenant: ansible_tenant
114+
sla_policy: ansible_http_sla
115+
sla_type: http
116+
frequency: 40
117+
multiplier: 6
118+
http_version: 1.1
119+
http_uri: /test
120+
request_data_size: 100
121+
operation_timeout: 2100
122+
threshold: 2000
123+
type_of_service: 1
124+
traffic_class: 1
125+
state: present
126+
when: version.current.0.topSystem.attributes.version is version('5.2', '>=')
127+
register: http_sla
128+
129+
- name: Verify HTTP SLA creation
130+
ansible.builtin.assert:
131+
that:
132+
- http_sla is changed
133+
- http_sla.previous == []
134+
- http_sla.current.0.fvIPSLAMonitoringPol.attributes.dn == "uni/tn-ansible_tenant/ipslaMonitoringPol-ansible_http_sla"
135+
- http_sla.current.0.fvIPSLAMonitoringPol.attributes.name == "ansible_http_sla"
136+
- http_sla.current.0.fvIPSLAMonitoringPol.attributes.slaDetectMultiplier == "6"
137+
- http_sla.current.0.fvIPSLAMonitoringPol.attributes.slaFrequency == "40"
138+
- http_sla.current.0.fvIPSLAMonitoringPol.attributes.slaPort == "80"
139+
- http_sla.current.0.fvIPSLAMonitoringPol.attributes.slaType == "http"
140+
- http_sla.current.0.fvIPSLAMonitoringPol.attributes.reqDataSize == "100"
141+
- http_sla.current.0.fvIPSLAMonitoringPol.attributes.timeout == "2100"
142+
- http_sla.current.0.fvIPSLAMonitoringPol.attributes.threshold == "2000"
143+
- http_sla.current.0.fvIPSLAMonitoringPol.attributes.httpVersion == "HTTP11"
144+
- http_sla.current.0.fvIPSLAMonitoringPol.attributes.httpUri == "/test"
145+
- http_sla.current.0.fvIPSLAMonitoringPol.attributes.ipv6TrfClass == "1"
146+
- http_sla.current.0.fvIPSLAMonitoringPol.attributes.ipv4Tos == "1"
147+
- http_sla.current.0.fvIPSLAMonitoringPol.attributes.httpMethod == "get"
148+
when: version.current.0.topSystem.attributes.version is version('5.2', '>=')
149+
150+
# TEST ERROR CHECKING
151+
- name: Create ICMP Monitoring Policy with sla_port
152+
cisco.aci.aci_ip_sla_monitoring_policy:
153+
<<: *aci_info
154+
tenant: ansible_tenant
155+
sla_policy: ansible_http_sla
156+
sla_type: icmp
157+
sla_port: 8080
158+
state: present
159+
ignore_errors: true
160+
register: icmp_with_sla_port
161+
162+
- name: Create ICMP Monitoring Policy with request_data_size
163+
cisco.aci.aci_ip_sla_monitoring_policy:
164+
<<: *aci_info
165+
tenant: ansible_tenant
166+
sla_policy: ansible_http_sla
167+
sla_type: tcp
168+
request_data_size: 2000
169+
state: present
170+
ignore_errors: true
171+
register: icmp_with_request_data_size
172+
173+
- name: Verify Errors
174+
ansible.builtin.assert:
175+
that:
176+
- icmp_with_sla_port is failed
177+
- icmp_with_request_data_size is failed
178+
- icmp_with_sla_port.msg == "Setting 'sla_port' is not allowed when 'sla_type' is not set to 'tcp'."
179+
- icmp_with_request_data_size.msg == "Setting 'request_data_size' is not allowed when 'sla_type' is set to 'tcp'."
180+
181+
# MODIFY SLA POLICY
182+
- name: Convert ICMP SLA policy to TCP
183+
cisco.aci.aci_ip_sla_monitoring_policy: &convert_icmp
184+
<<: *aci_info
185+
tenant: ansible_tenant
186+
sla_policy: ansible_sla
187+
sla_type: tcp
188+
sla_port: 8080
189+
frequency: 20
190+
multiplier: 5
191+
state: present
192+
check_mode: true
193+
register: update_tcp_sla_cm
194+
195+
- name: Convert ICMP SLA policy to TCP
196+
cisco.aci.aci_ip_sla_monitoring_policy:
197+
<<: *convert_icmp
198+
register: update_tcp_sla
199+
200+
- name: Verify SLA update
201+
ansible.builtin.assert:
202+
that:
203+
- update_tcp_sla_cm is changed
204+
- update_tcp_sla is changed
205+
- update_tcp_sla_cm.previous == create_icmp_sla.current == update_tcp_sla.previous
206+
- update_tcp_sla_cm.proposed.fvIPSLAMonitoringPol.attributes.dn == "uni/tn-ansible_tenant/ipslaMonitoringPol-ansible_sla"
207+
- update_tcp_sla_cm.proposed.fvIPSLAMonitoringPol.attributes.name == "ansible_sla"
208+
- update_tcp_sla_cm.proposed.fvIPSLAMonitoringPol.attributes.slaDetectMultiplier == "5"
209+
- update_tcp_sla_cm.proposed.fvIPSLAMonitoringPol.attributes.slaFrequency == "20"
210+
- update_tcp_sla_cm.proposed.fvIPSLAMonitoringPol.attributes.slaPort == "8080"
211+
- update_tcp_sla_cm.proposed.fvIPSLAMonitoringPol.attributes.slaType == "tcp"
212+
- update_tcp_sla.current.0.fvIPSLAMonitoringPol.attributes.dn == "uni/tn-ansible_tenant/ipslaMonitoringPol-ansible_sla"
213+
- update_tcp_sla.current.0.fvIPSLAMonitoringPol.attributes.name == "ansible_sla"
214+
- update_tcp_sla.current.0.fvIPSLAMonitoringPol.attributes.slaDetectMultiplier == "5"
215+
- update_tcp_sla.current.0.fvIPSLAMonitoringPol.attributes.slaFrequency == "20"
216+
- update_tcp_sla.current.0.fvIPSLAMonitoringPol.attributes.slaPort == "8080"
217+
- update_tcp_sla.current.0.fvIPSLAMonitoringPol.attributes.slaType == "tcp"
218+
219+
# CREATE ICMP SLA POLICY WITH DEFAULT
220+
- name: Create ICMP SLA policy with default values
221+
cisco.aci.aci_ip_sla_monitoring_policy:
222+
<<: *aci_info
223+
tenant: ansible_tenant
224+
sla_policy: ansible_sla_default
225+
sla_type: icmp
226+
state: present
227+
register: create_icmp_sla_default
228+
229+
- name: Verify SLA creation for check mode
230+
ansible.builtin.assert:
231+
that:
232+
- create_icmp_sla_default.current.0.fvIPSLAMonitoringPol.attributes.dn == "uni/tn-ansible_tenant/ipslaMonitoringPol-ansible_sla_default"
233+
- create_icmp_sla_default.current.0.fvIPSLAMonitoringPol.attributes.name == "ansible_sla_default"
234+
- create_icmp_sla_default.current.0.fvIPSLAMonitoringPol.attributes.slaDetectMultiplier == "3"
235+
- create_icmp_sla_default.current.0.fvIPSLAMonitoringPol.attributes.slaFrequency == "60"
236+
- create_icmp_sla_default.current.0.fvIPSLAMonitoringPol.attributes.slaPort == "0"
237+
- create_icmp_sla_default.current.0.fvIPSLAMonitoringPol.attributes.slaType == "icmp"
238+
239+
# QUERY IP SLA POLICY
240+
- name: Query IP SLA monitor
241+
cisco.aci.aci_ip_sla_monitoring_policy:
242+
<<: *aci_info
243+
tenant: ansible_tenant
244+
sla_policy: ansible_sla
245+
state: query
246+
register: query_tcp_sla
247+
248+
- name: Verify SLA query
249+
ansible.builtin.assert:
250+
that:
251+
- query_tcp_sla is not changed
252+
- query_tcp_sla.current.0.fvIPSLAMonitoringPol.attributes.dn == "uni/tn-ansible_tenant/ipslaMonitoringPol-ansible_sla"
253+
- query_tcp_sla.current.0.fvIPSLAMonitoringPol.attributes.name == "ansible_sla"
254+
- query_tcp_sla.current.0.fvIPSLAMonitoringPol.attributes.slaDetectMultiplier == "5"
255+
- query_tcp_sla.current.0.fvIPSLAMonitoringPol.attributes.slaFrequency == "20"
256+
- query_tcp_sla.current.0.fvIPSLAMonitoringPol.attributes.slaPort == "8080"
257+
- query_tcp_sla.current.0.fvIPSLAMonitoringPol.attributes.slaType == "tcp"
258+
259+
# QUERY ALL SLA POLICIES
260+
- name: Query all IP SLA monitor policies
261+
cisco.aci.aci_ip_sla_monitoring_policy:
262+
<<: *aci_info
263+
state: query
264+
register: query_sla_all
265+
266+
- name: Verify all SLA query
267+
ansible.builtin.assert:
268+
that:
269+
- query_sla_all is not changed
270+
- query_sla_all.current | length >= 2
271+
- "'uni/tn-ansible_tenant/ipslaMonitoringPol-second_ansible_sla' in query_sla_all.current | map(attribute='fvIPSLAMonitoringPol.attributes.dn') | list"
272+
- "'uni/tn-ansible_tenant/ipslaMonitoringPol-ansible_sla' in query_sla_all.current | map(attribute='fvIPSLAMonitoringPol.attributes.dn') | list"
273+
274+
# DELETE SLA POLICY
275+
- name: Remove IP SLA monitor
276+
cisco.aci.aci_ip_sla_monitoring_policy: &remove_sla
277+
<<: *aci_info
278+
tenant: ansible_tenant
279+
sla_policy: ansible_sla
280+
state: absent
281+
check_mode: true
282+
register: remove_tcp_sla_cm
283+
284+
- name: Remove IP SLA monitor
285+
cisco.aci.aci_ip_sla_monitoring_policy:
286+
<<: *remove_sla
287+
register: remove_tcp_sla
288+
289+
- name: Verify IP SLA deletion
290+
ansible.builtin.assert:
291+
that:
292+
- remove_tcp_sla_cm is changed
293+
- remove_tcp_sla_cm.proposed == {}
294+
- remove_tcp_sla_cm.previous.0.fvIPSLAMonitoringPol.attributes.dn == "uni/tn-ansible_tenant/ipslaMonitoringPol-ansible_sla"
295+
- remove_tcp_sla_cm.previous.0.fvIPSLAMonitoringPol.attributes.name == "ansible_sla"
296+
- remove_tcp_sla is changed
297+
- remove_tcp_sla.current == []
298+
- remove_tcp_sla.previous.0.fvIPSLAMonitoringPol.attributes.dn == "uni/tn-ansible_tenant/ipslaMonitoringPol-ansible_sla"
299+
- remove_tcp_sla.previous.0.fvIPSLAMonitoringPol.attributes.name == "ansible_sla"
300+
301+
# DELETE IP SLA POLICY AGAIN TO TEST IDEMPOTENCE
302+
- name: Remove IP SLA monitor again
303+
cisco.aci.aci_ip_sla_monitoring_policy:
304+
<<: *aci_info
305+
tenant: ansible_tenant
306+
sla_policy: ansible_sla
307+
state: absent
308+
register: remove_tcp_sla_cm_again
309+
310+
- name: Verify IP SLA deletion
311+
ansible.builtin.assert:
312+
that:
313+
- remove_tcp_sla_cm_again is not changed
314+
- remove_tcp_sla_cm_again.current == []
315+
316+
# CLEAN UP
317+
- name: remove ansible_tenant
318+
cisco.aci.aci_tenant:
319+
<<: *aci_info
320+
name: ansible_tenant
321+
state: absent

0 commit comments

Comments
 (0)