Skip to content

Commit 52ec596

Browse files
timcragglhercot
authored andcommitted
[ignore] Modified aci_ip_sla_monitoring_policy to include ranges of values for certain options
1 parent 392c418 commit 52ec596

File tree

2 files changed

+120
-34
lines changed

2 files changed

+120
-34
lines changed

plugins/modules/aci_ip_sla_monitoring_policy.py

Lines changed: 37 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
description:
3636
- The type of monitoring.
3737
- The APIC defaults to C(icmp) when unset during creation.
38+
- I(sla_type=http) is only supported in APIC v5.0 and above.
3839
type: str
3940
choices: [ icmp, tcp, l2ping, http ]
4041
sla_port:
@@ -46,51 +47,66 @@
4647
description:
4748
- Defines the interval at which probes are conducted.
4849
- The APIC defaults to C(60) when unset during creation.
50+
- Permitted values are in the range of [1, 300].
4951
type: int
5052
multiplier:
5153
description:
5254
- Specifies the number of consecutive probe failures required to determine the SLA as down.
5355
- The APIC defaults to C(3) when unset during creation.
56+
- Permitted values are in the range of [1, 100].
5457
type: int
5558
aliases: [ detect_multiplier ]
5659
request_data_size:
5760
description:
5861
- The number of bytes to send in the request.
59-
- Only used if I(sla_type) is set to C(http).
62+
- Only used if I(sla_type=http).
6063
- The APIC defaults to C(28) when unset during creation.
64+
- Permitted values are in the range of [0, 17512]
65+
- This is only supported in APIC v5.1 and above.
6166
type: int
6267
type_of_service:
6368
description:
6469
- The Type of Service (ToS) value to set in the IPv4 header.
6570
- The APIC defaults to C(0) when unset during creation.
71+
- Permitted values are in the range of [0, 255].
72+
- This is only supported in APIC v5.1 and above.
6673
type: int
6774
aliases: [ tos ]
6875
operation_timeout:
6976
description:
7077
- The amount of time in milliseconds that the IP SLA operation waits for a response from its request packet.
7178
- The APIC defaults to C(900) when unset during creation.
79+
- Permitted values are in the range of [0, 604800000].
80+
- This is only supported in APIC v5.1 and above.
7281
type: int
7382
threshold:
7483
description:
7584
- The upper threshold value in milliseconds for calculating network monitoring statistics created by the IP SLA operation.
76-
- The value specified for this property must not exceed the value specified for operation_timeout.
85+
- The value specified for this property must not exceed the value specified for I(operation_timeout).
7786
- The APIC defaults to C(900) when unset during creation.
87+
- Permitted values are in the range of [0, 604800000].
88+
- This is only supported in APIC v5.1 and above.
7889
type: int
7990
traffic_class:
8091
description:
8192
- Sets the Traffic Class value in the IPv6 header.
8293
- The APIC defaults to C(0) when unset during creation.
94+
- Permitted values are in the range of [0, 255].
95+
- This is only supported in APIC v5.1 and above.
8396
type: int
97+
aliases: ["traffic_class_value"]
8498
http_version:
8599
description:
86100
- The HTTP version to use.
87101
- The APIC defaults to C(1.0) when unset during creation.
102+
- This is only supported in APIC v5.0 and above.
88103
type: str
89104
choices: [ "1.0", "1.1" ]
90105
http_uri:
91106
description:
92107
- The HTTP URI to use as the SLA destination.
93108
- The APIC defaults to C(/) when unset during creation.
109+
- This is only supported in APIC v5.0 and above.
94110
type: str
95111
state:
96112
description:
@@ -129,7 +145,7 @@
129145
state: present
130146
delegate_to: localhost
131147
132-
- name: Add a new TCP SLA monitoring policy
148+
- name: Update to TCP SLA monitoring policy
133149
cisco.aci.aci_ip_sla_monitoring_policy:
134150
host: apic
135151
username: admin
@@ -143,35 +159,35 @@
143159
state: present
144160
delegate_to: localhost
145161
146-
- name: Delete an SLA monitoring policy
162+
- name: Query an SLA monitoring policy
147163
cisco.aci.aci_ip_sla_monitoring_policy:
148164
host: apic
149165
username: admin
150166
password: SomeSecretPassword
151167
tenant: my_tenant
152168
name: my_policy
153-
state: absent
169+
state: query
154170
delegate_to: localhost
171+
register: query_result
155172
156-
- name: Query an SLA monitoring policy
173+
- name: Query all SLA monitoring policies
157174
cisco.aci.aci_ip_sla_monitoring_policy:
158175
host: apic
159176
username: admin
160177
password: SomeSecretPassword
161-
tenant: my_tenant
162-
name: my_policy
163178
state: query
164179
delegate_to: localhost
165180
register: query_result
166181
167-
- name: Query all SLA monitoring policies
182+
- name: Delete an SLA monitoring policy
168183
cisco.aci.aci_ip_sla_monitoring_policy:
169184
host: apic
170185
username: admin
171186
password: SomeSecretPassword
172-
state: query
187+
tenant: my_tenant
188+
name: my_policy
189+
state: absent
173190
delegate_to: localhost
174-
register: query_result
175191
"""
176192

177193
RETURN = r"""
@@ -302,8 +318,8 @@ def main():
302318
type_of_service=dict(type="int", aliases=["tos"]),
303319
operation_timeout=dict(type="int"),
304320
threshold=dict(type="int"),
305-
traffic_class=dict(type="int"),
306-
http_version=dict(type="str", choices=["1.0", "1.1"]),
321+
traffic_class=dict(type="int", aliases=["traffic_class_value"]),
322+
http_version=dict(type="str", choices=list(HTTP_VERSIONS_MAPPING)),
307323
http_uri=dict(type="str"),
308324
)
309325

@@ -341,15 +357,20 @@ def main():
341357
module_object=tenant,
342358
target_filter={"name": tenant},
343359
),
344-
subclass_1=dict(aci_class="fvIPSLAMonitoringPol", aci_rn="ipslaMonitoringPol-{0}".format(name), module_object=name, target_filter={"name": name}),
360+
subclass_1=dict(
361+
aci_class="fvIPSLAMonitoringPol",
362+
aci_rn="ipslaMonitoringPol-{0}".format(name),
363+
module_object=name,
364+
target_filter={"name": name},
365+
),
345366
)
346367
aci.get_existing()
347368

348369
if state == "present":
349370
if sla_port is not None and sla_type != "tcp":
350371
aci.fail_json("Setting 'sla_port' is not allowed when 'sla_type' is not set to 'tcp'.")
351-
if sla_type != "http" and request_data_size is not None:
352-
aci.fail_json("Setting 'request_data_size' is not allowed when 'sla_type' is not set to 'http.")
372+
if sla_type == "tcp" and request_data_size is not None:
373+
aci.fail_json("Setting 'request_data_size' is not allowed when 'sla_type' is set to 'tcp'.")
353374

354375
if sla_type == "http":
355376
sla_port = 80

tests/integration/targets/aci_ip_sla_monitoring_policy/tasks/main.yml

Lines changed: 83 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Test code for the ACI modules
2-
# Copyright: (c) 2021, Tim Cragg (@timcragg)
2+
# Copyright: (c) 2025, Tim Cragg (@timcragg)
33

44
# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
55

@@ -42,20 +42,40 @@
4242
state: present
4343

4444
# CREATE ICMP SLA POLICY
45-
- name: Create ICMP SLA policy
46-
cisco.aci.aci_ip_sla_monitoring_policy:
45+
- name: Create ICMP SLA policy in check_mode
46+
cisco.aci.aci_ip_sla_monitoring_policy: &create_sla
4747
<<: *aci_info
4848
tenant: ansible_tenant
4949
sla_policy: ansible_sla
5050
sla_type: icmp
5151
frequency: 40
5252
multiplier: 6
5353
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
5472
register: create_icmp_sla
5573

5674
- name: Verify SLA creation
5775
ansible.builtin.assert:
5876
that:
77+
- create_icmp_sla is changed
78+
- create_icmp_sla.previous == []
5979
- create_icmp_sla.current.0.fvIPSLAMonitoringPol.attributes.dn == "uni/tn-ansible_tenant/ipslaMonitoringPol-ansible_sla"
6080
- create_icmp_sla.current.0.fvIPSLAMonitoringPol.attributes.name == "ansible_sla"
6181
- create_icmp_sla.current.0.fvIPSLAMonitoringPol.attributes.slaDetectMultiplier == "6"
@@ -66,22 +86,17 @@
6686
# CREATE ICMP SLA POLICY AGAIN TO TEST IDEMPOTENCE
6787
- name: Create ICMP SLA policy again
6888
cisco.aci.aci_ip_sla_monitoring_policy:
69-
<<: *aci_info
70-
tenant: ansible_tenant
71-
sla_policy: ansible_sla
72-
sla_type: icmp
73-
frequency: 40
74-
multiplier: 6
75-
state: present
89+
<<: *create_sla
7690
register: create_icmp_sla_again
7791

7892
- name: Verify SLA creation idempotence
7993
ansible.builtin.assert:
8094
that:
8195
- create_icmp_sla_again is not changed
96+
- create_icmp_sla_again.current == create_icmp_sla.current == create_icmp_sla_again.previous
8297

8398
# CREATE SECOND SLA POLICY
84-
- name: Create Second SLA policy again
99+
- name: Create Second SLA policy
85100
cisco.aci.aci_ip_sla_monitoring_policy:
86101
<<: *aci_info
87102
tenant: ansible_tenant
@@ -114,6 +129,8 @@
114129
- name: Verify HTTP SLA creation
115130
ansible.builtin.assert:
116131
that:
132+
- http_sla is changed
133+
- http_sla.previous == []
117134
- http_sla.current.0.fvIPSLAMonitoringPol.attributes.dn == "uni/tn-ansible_tenant/ipslaMonitoringPol-ansible_http_sla"
118135
- http_sla.current.0.fvIPSLAMonitoringPol.attributes.name == "ansible_http_sla"
119136
- http_sla.current.0.fvIPSLAMonitoringPol.attributes.slaDetectMultiplier == "6"
@@ -147,7 +164,7 @@
147164
<<: *aci_info
148165
tenant: ansible_tenant
149166
sla_policy: ansible_http_sla
150-
sla_type: icmp
167+
sla_type: tcp
151168
request_data_size: 2000
152169
state: present
153170
ignore_errors: true
@@ -159,11 +176,11 @@
159176
- icmp_with_sla_port is failed
160177
- icmp_with_request_data_size is failed
161178
- icmp_with_sla_port.msg == "Setting 'sla_port' is not allowed when 'sla_type' is not set to 'tcp'."
162-
- icmp_with_request_data_size.msg == "Setting 'request_data_size' is not allowed when 'sla_type' is not set to 'http."
179+
- icmp_with_request_data_size.msg == "Setting 'request_data_size' is not allowed when 'sla_type' is set to 'tcp'."
163180

164181
# MODIFY SLA POLICY
165182
- name: Convert ICMP SLA policy to TCP
166-
cisco.aci.aci_ip_sla_monitoring_policy:
183+
cisco.aci.aci_ip_sla_monitoring_policy: &convert_icmp
167184
<<: *aci_info
168185
tenant: ansible_tenant
169186
sla_policy: ansible_sla
@@ -172,18 +189,53 @@
172189
frequency: 20
173190
multiplier: 5
174191
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
175198
register: update_tcp_sla
176199

177200
- name: Verify SLA update
178201
ansible.builtin.assert:
179202
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"
180212
- update_tcp_sla.current.0.fvIPSLAMonitoringPol.attributes.dn == "uni/tn-ansible_tenant/ipslaMonitoringPol-ansible_sla"
181213
- update_tcp_sla.current.0.fvIPSLAMonitoringPol.attributes.name == "ansible_sla"
182214
- update_tcp_sla.current.0.fvIPSLAMonitoringPol.attributes.slaDetectMultiplier == "5"
183215
- update_tcp_sla.current.0.fvIPSLAMonitoringPol.attributes.slaFrequency == "20"
184216
- update_tcp_sla.current.0.fvIPSLAMonitoringPol.attributes.slaPort == "8080"
185217
- update_tcp_sla.current.0.fvIPSLAMonitoringPol.attributes.slaType == "tcp"
186218

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+
187239
# QUERY IP SLA POLICY
188240
- name: Query IP SLA monitor
189241
cisco.aci.aci_ip_sla_monitoring_policy:
@@ -215,20 +267,32 @@
215267
ansible.builtin.assert:
216268
that:
217269
- query_sla_all is not changed
218-
- query_sla_all.current | length > 1
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"
219273

220274
# DELETE SLA POLICY
221275
- name: Remove IP SLA monitor
222-
cisco.aci.aci_ip_sla_monitoring_policy:
276+
cisco.aci.aci_ip_sla_monitoring_policy: &remove_sla
223277
<<: *aci_info
224278
tenant: ansible_tenant
225279
sla_policy: ansible_sla
226280
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
227287
register: remove_tcp_sla
228288

229289
- name: Verify IP SLA deletion
230290
ansible.builtin.assert:
231291
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"
232296
- remove_tcp_sla is changed
233297
- remove_tcp_sla.current == []
234298
- remove_tcp_sla.previous.0.fvIPSLAMonitoringPol.attributes.dn == "uni/tn-ansible_tenant/ipslaMonitoringPol-ansible_sla"
@@ -241,12 +305,13 @@
241305
tenant: ansible_tenant
242306
sla_policy: ansible_sla
243307
state: absent
244-
register: remove_tcp_sla_again
308+
register: remove_tcp_sla_cm_again
245309

246310
- name: Verify IP SLA deletion
247311
ansible.builtin.assert:
248312
that:
249-
- remove_tcp_sla_again is not changed
313+
- remove_tcp_sla_cm_again is not changed
314+
- remove_tcp_sla_cm_again.current == []
250315

251316
# CLEAN UP
252317
- name: remove ansible_tenant

0 commit comments

Comments
 (0)