Debian Codegraph @

ansible_collections/cisco/mso/plugins/modules/ndo_l3out_interface_routing_policy.py

raw
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3
4 # Copyright: (c) 2024, Sabari Jaganathan (@sajagana) <[email protected]>
5
6 # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
7
8 from __future__ import absolute_import, division, print_function
9
10 __metaclass__ = type
11
12 ANSIBLE_METADATA = {"metadata_version": "1.1", "status": ["preview"], "supported_by": "community"}
13
14 DOCUMENTATION = r"""
15 ---
16 module: ndo_l3out_interface_routing_policy
17 short_description: Manage L3Out Interface Routing Policies on Cisco Nexus Dashboard Orchestrator (NDO).
18 description:
19 - Manage L3Out Interface Routing Policies on Cisco Nexus Dashboard Orchestrator (NDO).
20 - This module is only supported on ND v3.1 (NDO v4.3) and later.
21 author:
22 - Sabari Jaganathan (@sajagana)
23 options:
24 template:
25 description:
26 - The name of the template.
27 - The template must be a Tenant Policy Template.
28 type: str
29 required: true
30 name:
31 description:
32 - The name of the L3Out Interface Routing Policy.
33 type: str
34 aliases: [ l3out_interface_routing_policy_name ]
35 uuid:
36 description:
37 - The UUID of the L3Out Interface Routing Policy.
38 - This parameter is required when the O(name) needs to be updated.
39 type: str
40 aliases: [ l3out_interface_routing_policy_uuid ]
41 description:
42 description:
43 - The description of the L3Out Interface Routing Policy.
44 type: str
45 bfd_multi_hop_settings:
46 description:
47 - The Bidirectional Forwarding Detection (BFD) multi-hop configuration of the L3Out Interface Routing Policy.
48 type: dict
49 suboptions:
50 state:
51 description:
52 - Use C(enabled) to configure the BFD MultiHop Settings.
53 - Use C(disabled) to remove the BFD MultiHop Settings.
54 type: str
55 choices: [ enabled, disabled ]
56 admin_state:
57 description:
58 - The administrative state of the BFD MultiHop Settings.
59 - Defaults to C(enabled) when unset during creation.
60 type: str
61 choices: [ enabled, disabled ]
62 detection_multiplier:
63 description:
64 - The detection multiplier of the BFD MultiHop Settings.
65 - Defaults to 3 when unset during creation.
66 - The value must be between 1 and 50.
67 type: int
68 min_receive_interval:
69 description:
70 - The minimum receive interval of the BFD MultiHop Settings.
71 - Defaults to 250 when unset during creation.
72 - The value must be between 250 and 999 microseconds.
73 type: int
74 min_transmit_interval:
75 description:
76 - The minimum transmit interval of the BFD MultiHop Settings.
77 - Defaults to 250 when unset during creation.
78 - The value must be between 250 and 999 microseconds.
79 type: int
80 bfd_settings:
81 description:
82 - The BFD Settings of the L3Out Interface Routing Policy.
83 type: dict
84 suboptions:
85 state:
86 description:
87 - Use C(enabled) to configure the BFD Settings.
88 - Use C(disabled) to remove the BFD Settings.
89 type: str
90 choices: [ enabled, disabled ]
91 admin_state:
92 description:
93 - The administrative state of the BFD Settings.
94 - Defaults to C(enabled) when unset during creation.
95 type: str
96 choices: [ enabled, disabled ]
97 detection_multiplier:
98 description:
99 - The detection multiplier of the BFD Settings.
100 - Defaults to 3 when unset during creation.
101 - The value must be between 1 and 50.
102 type: int
103 min_receive_interval:
104 description:
105 - The minimum receive interval in microseconds of the BFD Settings.
106 - Defaults to 50 when unset during creation.
107 - The value must be between 50 and 999.
108 type: int
109 min_transmit_interval:
110 description:
111 - The minimum transmit interval in microseconds of the BFD Settings.
112 - Defaults to 50 when unset during creation.
113 - The value must be between 50 and 999.
114 type: int
115 echo_receive_interval:
116 description:
117 - The echo receive interval in microseconds of the BFD Settings
118 - Defaults to 50 when unset during creation.
119 - The value must be between 50 and 999.
120 type: int
121 echo_admin_state:
122 description:
123 - The echo administrative state of the BFD Settings.
124 - Defaults to C(enabled) when unset during creation.
125 type: str
126 choices: [ enabled, disabled ]
127 interface_control:
128 description:
129 - The interface control of the BFD Settings.
130 - Defaults to C(disabled) when unset during creation.
131 type: str
132 choices: [ enabled, disabled ]
133 ospf_interface_settings:
134 description:
135 - The Open Shortest Path First (OSPF) Interface Settings of the L3Out Interface Routing Policy.
136 type: dict
137 suboptions:
138 state:
139 description:
140 - Use C(enabled) to configure the OSPF Interface Settings.
141 - Use C(disabled) to remove the OSPF Interface Settings.
142 type: str
143 choices: [ enabled, disabled ]
144 network_type:
145 description:
146 - The network type of the OSPF Interface Settings.
147 - Defaults to C(broadcast) when unset during creation.
148 type: str
149 choices: [ broadcast, point_to_point ]
150 priority:
151 description:
152 - The priority of the OSPF Interface Settings.
153 - Defaults to 1 when unset during creation.
154 - The value must be between 0 and 255.
155 type: int
156 cost_of_interface:
157 description:
158 - The cost of the OSPF Interface Settings.
159 - Defaults to 0 when unset during creation.
160 - The value must be between 0 and 65535.
161 type: int
162 hello_interval:
163 description:
164 - The hello interval in seconds of the OSPF Interface Settings.
165 - Defaults to 10 when unset during creation.
166 - The value must be between 1 and 65535.
167 type: int
168 dead_interval:
169 description:
170 - The dead interval in seconds of the OSPF Interface Settings.
171 - Defaults to 40 when unset during creation.
172 - The value must be between 1 and 65535.
173 type: int
174 retransmit_interval:
175 description:
176 - The retransmit interval in seconds of the OSPF Interface Settings.
177 - Defaults to 5 when unset during creation.
178 - The value must be between 1 and 65535.
179 type: int
180 transmit_delay:
181 description:
182 - The transmit delay in seconds of the OSPF Interface Settings.
183 - Defaults to 1 when unset during creation.
184 - The value must be between 1 and 450.
185 type: int
186 advertise_subnet:
187 description:
188 - The advertise subnet of the OSPF Interface Settings.
189 - Defaults to C(disabled) when unset during creation.
190 type: str
191 choices: [ enabled, disabled ]
192 bfd:
193 description:
194 - Enables or disables BFD in the OSPF Interface Settings.
195 - Defaults to C(disabled) when unset during creation.
196 type: str
197 choices: [ enabled, disabled ]
198 mtu_ignore:
199 description:
200 - Enables or disables ignoring the Maximum Transmission Unit (MTU) in the OSPF Interface Settings.
201 - Defaults to C(disabled) when unset during creation.
202 type: str
203 choices: [ enabled, disabled ]
204 passive_participation:
205 description:
206 - Enables or disables passive participation in the OSPF Interface Settings.
207 - Defaults to C(disabled) when unset during creation.
208 type: str
209 choices: [ enabled, disabled ]
210 state:
211 description:
212 - Use C(absent) for removing.
213 - Use C(query) for listing an object or multiple objects.
214 - Use C(present) for creating or updating.
215 type: str
216 choices: [ absent, query, present ]
217 default: query
218 notes:
219 - The O(template) must exist before using this module in your playbook.
220 Use M(cisco.mso.ndo_template) to create the Tenant Policy Template.
221 seealso:
222 - module: cisco.mso.ndo_template
223 extends_documentation_fragment: cisco.mso.modules
224 """
225
226 EXAMPLES = r"""
227 - name: Create a new L3Out Interface Routing Policy with default values
228 cisco.mso.ndo_l3out_interface_routing_policy:
229 host: mso_host
230 username: admin
231 password: SomeSecretPassword
232 template: ansible_tenant_template
233 name: irp_1
234 bfd_settings:
235 state: enabled
236 bfd_multi_hop_settings:
237 state: enabled
238 state: present
239 register: irp_1_present
240
241 - name: Update an existing L3Out Interface Routing Policy with UUID
242 cisco.mso.ndo_l3out_interface_routing_policy:
243 host: mso_host
244 username: admin
245 password: SomeSecretPassword
246 template: ansible_tenant_template
247 uuid: "{{ irp_1_present.current.uuid }}"
248 name: irp_1_updated
249 bfd_multi_hop_settings:
250 admin_state: disabled
251 detection_multiplier: 10
252 min_receive_interval: 255
253 min_transmit_interval: 255
254 bfd_settings:
255 admin_state: disabled
256 detection_multiplier: 10
257 min_receive_interval: 266
258 min_transmit_interval: 266
259 echo_receive_interval: 60
260 echo_admin_state: disabled
261 interface_control: enabled
262 ospf_interface_settings:
263 network_type: point_to_point
264 priority: 10
265 cost_of_interface: 100
266 advertise_subnet: enabled
267 bfd: enabled
268 mtu_ignore: enabled
269 passive_participation: enabled
270 hello_interval: 20
271 dead_interval: 30
272 retransmit_interval: 20
273 transmit_delay: 10
274 state: present
275 register: irp_1_present
276
277 - name: Clear an existing L3Out Interface Routing Policy BFD and OSPF interface settings
278 cisco.mso.ndo_l3out_interface_routing_policy:
279 host: mso_host
280 username: admin
281 password: SomeSecretPassword
282 template: ansible_tenant_template
283 uuid: "{{ irp_1_present.current.uuid }}"
284 bfd_settings:
285 state: disabled
286 ospf_interface_settings:
287 state: disabled
288 state: present
289
290 - name: Query an L3Out Interface Routing Policy with name
291 cisco.mso.ndo_l3out_interface_routing_policy:
292 host: mso_host
293 username: admin
294 password: SomeSecretPassword
295 template: ansible_tenant_template
296 name: irp_1_updated
297 state: query
298 register: query_with_name
299
300 - name: Query an L3Out Interface Routing Policy with UUID
301 cisco.mso.ndo_l3out_interface_routing_policy:
302 host: mso_host
303 username: admin
304 password: SomeSecretPassword
305 template: ansible_tenant_template
306 uuid: "{{ irp_1_present.current.uuid }}"
307 state: query
308 register: query_with_uuid
309
310 - name: Query all L3Out Interface Routing Policies
311 cisco.mso.ndo_l3out_interface_routing_policy:
312 host: mso_host
313 username: admin
314 password: SomeSecretPassword
315 template: ansible_tenant_template
316 state: query
317 register: query_all
318
319 - name: Delete an L3Out Interface Routing Policy
320 cisco.mso.ndo_l3out_interface_routing_policy:
321 host: mso_host
322 username: admin
323 password: SomeSecretPassword
324 template: ansible_tenant_template
325 name: irp_1_updated
326 state: absent
327
328 - name: Delete an L3Out Interface Routing Policy using UUID
329 cisco.mso.ndo_l3out_interface_routing_policy:
330 host: mso_host
331 username: admin
332 password: SomeSecretPassword
333 template: ansible_tenant_template
334 uuid: "{{ irp_1_present.current.uuid }}"
335 state: absent
336 """
337
338 RETURN = r"""
339 """
340
341 import copy
342 from ansible.module_utils.basic import AnsibleModule
343 from ansible_collections.cisco.mso.plugins.module_utils.mso import MSOModule, mso_argument_spec, ndo_bfd_multi_hop_settings_spec
344 from ansible_collections.cisco.mso.plugins.module_utils.template import MSOTemplate
345 from ansible_collections.cisco.mso.plugins.module_utils.constants import ENABLED_OR_DISABLED_TO_BOOL_STRING_MAP
346 from ansible_collections.cisco.mso.plugins.module_utils.utils import append_update_ops_data
347
348
349 def main():
350 argument_spec = mso_argument_spec()
351 argument_spec.update(
352 template=dict(type="str", required=True),
353 uuid=dict(type="str", aliases=["l3out_interface_routing_policy_uuid"]),
354 name=dict(type="str", aliases=["l3out_interface_routing_policy_name"]),
355 description=dict(type="str"),
356 bfd_settings=dict(
357 type="dict",
358 options=dict(
359 state=dict(type="str", choices=["enabled", "disabled"]),
360 admin_state=dict(type="str", choices=["enabled", "disabled"]),
361 detection_multiplier=dict(type="int"),
362 min_receive_interval=dict(type="int"),
363 min_transmit_interval=dict(type="int"),
364 echo_receive_interval=dict(type="int"),
365 echo_admin_state=dict(type="str", choices=["enabled", "disabled"]),
366 interface_control=dict(type="str", choices=["enabled", "disabled"]),
367 ),
368 ),
369 bfd_multi_hop_settings=ndo_bfd_multi_hop_settings_spec(),
370 ospf_interface_settings=dict(
371 type="dict",
372 options=dict(
373 state=dict(type="str", choices=["enabled", "disabled"]),
374 network_type=dict(type="str", choices=["broadcast", "point_to_point"]),
375 priority=dict(type="int"),
376 cost_of_interface=dict(type="int"),
377 advertise_subnet=dict(type="str", choices=["enabled", "disabled"]),
378 bfd=dict(type="str", choices=["enabled", "disabled"]),
379 mtu_ignore=dict(type="str", choices=["enabled", "disabled"]),
380 passive_participation=dict(type="str", choices=["enabled", "disabled"]),
381 hello_interval=dict(type="int"),
382 dead_interval=dict(type="int"),
383 retransmit_interval=dict(type="int"),
384 transmit_delay=dict(type="int"),
385 ),
386 ),
387 state=dict(type="str", default="query", choices=["absent", "query", "present"]),
388 )
389
390 module = AnsibleModule(
391 argument_spec=argument_spec,
392 supports_check_mode=True,
393 required_if=[
394 ["state", "absent", ["name", "uuid"], True],
395 ["state", "present", ["name", "uuid"], True],
396 ],
397 )
398
399 mso = MSOModule(module)
400
401 template = module.params.get("template")
402 name = module.params.get("name")
403 uuid = module.params.get("uuid")
404 description = module.params.get("description")
405 bfd_settings = module.params.get("bfd_settings")
406 bfd_multi_hop_settings = module.params.get("bfd_multi_hop_settings")
407 ospf_interface_settings = module.params.get("ospf_interface_settings")
408 state = module.params.get("state")
409
410 mso_template = MSOTemplate(mso, "tenant", template)
411 mso_template.validate_template("tenantPolicy")
412
413 l3out_interface_routing_policy = mso_template.get_l3out_interface_routing_policy_object(uuid, name)
414
415 if (uuid or name) and l3out_interface_routing_policy:
416 mso.existing = mso.previous = copy.deepcopy(l3out_interface_routing_policy.details) # Query a specific object
417 elif l3out_interface_routing_policy:
418 mso.existing = l3out_interface_routing_policy # Query all objects
419
420 if state != "query":
421 interface_routing_policy_path = "/tenantPolicyTemplate/template/l3OutIntfPolGroups/{0}".format(
422 l3out_interface_routing_policy.index if l3out_interface_routing_policy else "-"
423 )
424
425 ops = []
426 if state == "present":
427 if mso.existing:
428 proposed_payload = copy.deepcopy(mso.existing)
429 mso_values = dict()
430 mso_values_remove = list()
431
432 mso_values["name"] = name
433 mso_values["description"] = description
434
435 # BFD MultiHop Settings
436 if bfd_multi_hop_settings is not None:
437 if bfd_multi_hop_settings.get("state") == "disabled" and proposed_payload.get("bfdMultiHopPol"):
438 mso_values_remove.append("bfdMultiHopPol")
439
440 elif bfd_multi_hop_settings.get("state") != "disabled":
441 if not proposed_payload.get("bfdMultiHopPol"):
442 mso_values["bfdMultiHopPol"] = dict()
443
444 mso_values[("bfdMultiHopPol", "adminState")] = bfd_multi_hop_settings.get("admin_state")
445 mso_values[("bfdMultiHopPol", "detectionMultiplier")] = bfd_multi_hop_settings.get("detection_multiplier")
446 mso_values[("bfdMultiHopPol", "minRxInterval")] = bfd_multi_hop_settings.get("min_receive_interval")
447 mso_values[("bfdMultiHopPol", "minTxInterval")] = bfd_multi_hop_settings.get("min_transmit_interval")
448
449 # BFD Settings
450 if bfd_settings is not None:
451 if bfd_settings.get("state") == "disabled" and proposed_payload.get("bfdPol"):
452 mso_values_remove.append("bfdPol")
453
454 elif bfd_settings.get("state") != "disabled":
455 if not proposed_payload.get("bfdPol"):
456 mso_values["bfdPol"] = dict()
457
458 mso_values[("bfdPol", "adminState")] = bfd_settings.get("admin_state")
459 mso_values[("bfdPol", "detectionMultiplier")] = bfd_settings.get("detection_multiplier")
460 mso_values[("bfdPol", "minRxInterval")] = bfd_settings.get("min_receive_interval")
461 mso_values[("bfdPol", "minTxInterval")] = bfd_settings.get("min_transmit_interval")
462 mso_values[("bfdPol", "echoRxInterval")] = bfd_settings.get("echo_receive_interval")
463 mso_values[("bfdPol", "echoAdminState")] = bfd_settings.get("echo_admin_state")
464 mso_values[("bfdPol", "ifControl")] = ENABLED_OR_DISABLED_TO_BOOL_STRING_MAP.get(bfd_settings.get("interface_control"))
465
466 # OSPF Interface Settings
467 if ospf_interface_settings is not None:
468 if ospf_interface_settings.get("state") == "disabled" and proposed_payload.get("ospfIntfPol"):
469 mso_values_remove.append(("ospfIntfPol",))
470
471 elif ospf_interface_settings.get("state") != "disabled":
472 if not proposed_payload.get("ospfIntfPol"):
473 mso_values[("ospfIntfPol")] = dict()
474 mso_values[("ospfIntfPol", "ifControl")] = dict()
475
476 mso_values[("ospfIntfPol", "networkType")] = (
477 "pointToPoint" if ospf_interface_settings.get("network_type") == "point_to_point" else ospf_interface_settings.get("network_type")
478 )
479 mso_values[("ospfIntfPol", "prio")] = ospf_interface_settings.get("priority")
480 mso_values[("ospfIntfPol", "cost")] = ospf_interface_settings.get("cost_of_interface")
481 mso_values[("ospfIntfPol", "helloInterval")] = ospf_interface_settings.get("hello_interval")
482 mso_values[("ospfIntfPol", "deadInterval")] = ospf_interface_settings.get("dead_interval")
483 mso_values[("ospfIntfPol", "retransmitInterval")] = ospf_interface_settings.get("retransmit_interval")
484 mso_values[("ospfIntfPol", "transmitDelay")] = ospf_interface_settings.get("transmit_delay")
485 mso_values[("ospfIntfPol", "ifControl", "advertiseSubnet")] = ENABLED_OR_DISABLED_TO_BOOL_STRING_MAP.get(
486 ospf_interface_settings.get("advertise_subnet")
487 )
488 mso_values[("ospfIntfPol", "ifControl", "bfd")] = ENABLED_OR_DISABLED_TO_BOOL_STRING_MAP.get(ospf_interface_settings.get("bfd"))
489 mso_values[("ospfIntfPol", "ifControl", "ignoreMtu")] = ENABLED_OR_DISABLED_TO_BOOL_STRING_MAP.get(
490 ospf_interface_settings.get("mtu_ignore")
491 )
492 mso_values[("ospfIntfPol", "ifControl", "passiveParticipation")] = ENABLED_OR_DISABLED_TO_BOOL_STRING_MAP.get(
493 ospf_interface_settings.get("passive_participation")
494 )
495
496 append_update_ops_data(ops, proposed_payload, interface_routing_policy_path, mso_values, mso_values_remove)
497 mso.sanitize(proposed_payload)
498 else:
499 mso_values = dict(name=name, description=description)
500
501 # OSPF Interface Settings
502 if ospf_interface_settings is not None:
503 ospf_interface_pol = dict()
504 interface_controls = dict()
505
506 if ospf_interface_settings.get("advertise_subnet"):
507 interface_controls["advertiseSubnet"] = ENABLED_OR_DISABLED_TO_BOOL_STRING_MAP.get(ospf_interface_settings.get("advertise_subnet"))
508
509 if ospf_interface_settings.get("bfd"):
510 interface_controls["bfd"] = ENABLED_OR_DISABLED_TO_BOOL_STRING_MAP.get(ospf_interface_settings.get("bfd"))
511
512 if ospf_interface_settings.get("mtu_ignore"):
513 interface_controls["ignoreMtu"] = ENABLED_OR_DISABLED_TO_BOOL_STRING_MAP.get(ospf_interface_settings.get("mtu_ignore"))
514
515 if ospf_interface_settings.get("passive_participation"):
516 interface_controls["passiveParticipation"] = ENABLED_OR_DISABLED_TO_BOOL_STRING_MAP.get(
517 ospf_interface_settings.get("passive_participation")
518 )
519
520 if interface_controls:
521 ospf_interface_pol["ifControl"] = interface_controls
522
523 if ospf_interface_settings.get("network_type"):
524 ospf_interface_pol["networkType"] = (
525 "pointToPoint" if ospf_interface_settings.get("network_type") == "point_to_point" else ospf_interface_settings.get("network_type")
526 )
527
528 if ospf_interface_settings.get("priority"):
529 ospf_interface_pol["prio"] = ospf_interface_settings.get("priority")
530
531 if ospf_interface_settings.get("cost_of_interface"):
532 ospf_interface_pol["cost"] = ospf_interface_settings.get("cost_of_interface")
533
534 if ospf_interface_settings.get("hello_interval"):
535 ospf_interface_pol["helloInterval"] = ospf_interface_settings.get("hello_interval")
536
537 if ospf_interface_settings.get("dead_interval"):
538 ospf_interface_pol["deadInterval"] = ospf_interface_settings.get("dead_interval")
539
540 if ospf_interface_settings.get("retransmit_interval"):
541 ospf_interface_pol["retransmitInterval"] = ospf_interface_settings.get("retransmit_interval")
542
543 if ospf_interface_settings.get("transmit_delay"):
544 ospf_interface_pol["transmitDelay"] = ospf_interface_settings.get("transmit_delay")
545
546 if ospf_interface_pol or ospf_interface_settings.get("state") == "enabled":
547 mso_values["ospfIntfPol"] = ospf_interface_pol
548
549 # BFD MultiHop Settings
550 if bfd_multi_hop_settings is not None:
551 bfd_multi_hop_pol = dict()
552 if bfd_multi_hop_settings.get("admin_state"):
553 bfd_multi_hop_pol["adminState"] = bfd_multi_hop_settings.get("admin_state")
554
555 if bfd_multi_hop_settings.get("detection_multiplier"):
556 bfd_multi_hop_pol["detectionMultiplier"] = bfd_multi_hop_settings.get("detection_multiplier")
557
558 if bfd_multi_hop_settings.get("min_receive_interval"):
559 bfd_multi_hop_pol["minRxInterval"] = bfd_multi_hop_settings.get("min_receive_interval")
560
561 if bfd_multi_hop_settings.get("min_transmit_interval"):
562 bfd_multi_hop_pol["minTxInterval"] = bfd_multi_hop_settings.get("min_transmit_interval")
563
564 if bfd_multi_hop_pol or bfd_multi_hop_settings.get("state") == "enabled":
565 mso_values["bfdMultiHopPol"] = bfd_multi_hop_pol
566
567 # BFD Settings
568 if bfd_settings is not None:
569 bfd_settings_map = dict()
570
571 if bfd_settings.get("admin_state"):
572 bfd_settings_map["adminState"] = bfd_settings.get("admin_state")
573
574 if bfd_settings.get("detection_multiplier"):
575 bfd_settings_map["detectionMultiplier"] = bfd_settings.get("detection_multiplier")
576
577 if bfd_settings.get("min_receive_interval"):
578 bfd_settings_map["minRxInterval"] = bfd_settings.get("min_receive_interval")
579
580 if bfd_settings.get("min_transmit_interval"):
581 bfd_settings_map["minTxInterval"] = bfd_settings.get("min_transmit_interval")
582
583 if bfd_settings.get("echo_receive_interval"):
584 bfd_settings_map["echoRxInterval"] = bfd_settings.get("echo_receive_interval")
585
586 if bfd_settings.get("echo_admin_state"):
587 bfd_settings_map["echoAdminState"] = bfd_settings.get("echo_admin_state")
588
589 if bfd_settings.get("interface_control"):
590 bfd_settings_map["ifControl"] = ENABLED_OR_DISABLED_TO_BOOL_STRING_MAP.get(bfd_settings.get("interface_control"))
591
592 if bfd_settings_map or bfd_settings.get("state") == "enabled":
593 mso_values["bfdPol"] = bfd_settings_map
594
595 ops.append(dict(op="add", path=interface_routing_policy_path, value=copy.deepcopy(mso_values)))
596
597 mso.sanitize(mso_values)
598 elif state == "absent":
599 if mso.existing:
600 ops.append(dict(op="remove", path=interface_routing_policy_path))
601
602 if not module.check_mode and ops:
603 mso_template.template = mso.request(mso_template.template_path, method="PATCH", data=ops)
604 l3out_interface_routing_policy = mso_template.get_l3out_interface_routing_policy_object(uuid, name)
605 if l3out_interface_routing_policy:
606 mso.existing = l3out_interface_routing_policy.details # When the state is present
607 else:
608 mso.existing = {} # When the state is absent
609 elif module.check_mode and state != "query": # When the state is present/absent with check mode
610 mso.existing = mso.proposed if state == "present" else {}
611
612 mso.exit_json()
613
614
615 if __name__ == "__main__":
616 main()