Debian Codegraph @

ansible_collections/cisco/aci/plugins/modules/aci_interface_policy_leaf_policy_group.py

raw
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3
4 # Copyright: (c) 2017, Bruno Calogero <[email protected]>
5 # Copyright: (c) 2023, Anvitha Jain <[email protected]>
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": "certified"}
13
14 DOCUMENTATION = r"""
15 ---
16 module: aci_interface_policy_leaf_policy_group
17 short_description: Manage fabric interface policy leaf policy groups (infra:AccBndlGrp and infra:AccPortGrp)
18 description:
19 - Manage fabric interface policy leaf policy groups on Cisco ACI fabrics.
20 options:
21 policy_group:
22 description:
23 - The name of the leaf interface policy group.
24 type: str
25 aliases: [ name, policy_group_name ]
26 description:
27 description:
28 - The description of the leaf interface policy group.
29 type: str
30 aliases: [ descr ]
31 lag_type:
32 description:
33 - Selector for the type of leaf interface policy group.
34 - C(leaf) for Leaf Access Port Policy Group
35 - C(link) for Port Channel (PC)
36 - C(node) for Virtual Port Channel (VPC)
37 type: str
38 required: true
39 choices: [ leaf, link, node ]
40 aliases: [ lag_type_name ]
41 link_level_policy:
42 description:
43 - The name of the link level policy used by the leaf interface policy group.
44 type: str
45 aliases: [ link_level_policy_name ]
46 cdp_policy:
47 description:
48 - The name of the cdp policy used by the leaf interface policy group.
49 type: str
50 aliases: [ cdp_policy_name ]
51 mcp_policy:
52 description:
53 - The name of the mcp policy used by the leaf interface policy group.
54 type: str
55 aliases: [ mcp_policy_name ]
56 lldp_policy:
57 description:
58 - The name of the lldp policy used by the leaf interface policy group.
59 type: str
60 aliases: [ lldp_policy_name ]
61 stp_interface_policy:
62 description:
63 - The name of the stp interface policy used by the leaf interface policy group.
64 type: str
65 aliases: [ stp_interface_policy_name ]
66 egress_data_plane_policing_policy:
67 description:
68 - The name of the egress data plane policing policy used by the leaf interface policy group.
69 type: str
70 aliases: [ egress_data_plane_policing_policy_name ]
71 ingress_data_plane_policing_policy:
72 description:
73 - The name of the ingress data plane policing policy used by the leaf interface policy group.
74 type: str
75 aliases: [ ingress_data_plane_policing_policy_name ]
76 priority_flow_control_policy:
77 description:
78 - The name of the priority flow control policy used by the leaf interface policy group.
79 type: str
80 aliases: [ priority_flow_control_policy_name ]
81 fibre_channel_interface_policy:
82 description:
83 - The name of the fibre channel interface policy used by the leaf interface policy group.
84 type: str
85 aliases: [ fibre_channel_interface_policy_name ]
86 slow_drain_policy:
87 description:
88 - The name of the slow drain policy used by the leaf interface policy group.
89 type: str
90 aliases: [ slow_drain_policy_name ]
91 port_channel_policy:
92 description:
93 - The name of the port channel policy used by the leaf interface policy group.
94 type: str
95 aliases: [ port_channel_policy_name ]
96 monitoring_policy:
97 description:
98 - The name of the monitoring policy used by the leaf interface policy group.
99 type: str
100 aliases: [ monitoring_policy_name ]
101 storm_control_interface_policy:
102 description:
103 - The name of the storm control interface policy used by the leaf interface policy group.
104 type: str
105 aliases: [ storm_control_interface_policy_name ]
106 l2_interface_policy:
107 description:
108 - The name of the l2 interface policy used by the leaf interface policy group.
109 type: str
110 aliases: [ l2_interface_policy_name ]
111 port_security_policy:
112 description:
113 - The name of the port security policy used by the leaf interface policy group.
114 type: str
115 aliases: [ port_security_policy_name ]
116 link_flap_policy:
117 description:
118 - The name of the link flap policy used by the leaf interface policy group.
119 type: str
120 aliases: [ link_flap_policy_name ]
121 link_level_flow_control:
122 description:
123 - The name of the link level flow control used by the leaf interface policy group.
124 type: str
125 aliases: [ link_level_flow_control_name ]
126 mac_sec_interface_policy:
127 description:
128 - The name of the mac sec interface policy used by the leaf interface policy group.
129 type: str
130 aliases: [ mac_sec_interface_policy_name ]
131 copp_policy:
132 description:
133 - The name of the copp policy used by the leaf interface policy group.
134 type: str
135 aliases: [ copp_policy_name ]
136 sync_e_interface_policy:
137 description:
138 - The name of the syncE interface policy used by the leaf interface policy group.
139 - Only availavle in APIC version 5.2 or later.
140 type: str
141 aliases: [ sync_e_interface_policy_name ]
142 port_authentication:
143 description:
144 - The name of the port authentication used by the leaf interface policy group.
145 type: str
146 aliases: [ port_authentication_name ]
147 dwdm:
148 description:
149 - The name of the dwdm used by the leaf interface policy group.
150 type: str
151 aliases: [ dwdm_name ]
152 poe_interface_policy:
153 description:
154 - The name of the poe interface policy used by the leaf interface policy group.
155 type: str
156 aliases: [ poe_interface_policy_name ]
157 transceiver_policy:
158 description:
159 - The name of the transceiver policy used by the leaf interface policy group.
160 - Only availavle in APIC version 6.0(2h) or later.
161 type: dict
162 suboptions:
163 type:
164 description:
165 - The type of the transceiver policy.
166 type: str
167 required: true
168 aliases: [ transceiver_policy_type ]
169 choices: [ zr, zrp]
170 name:
171 description:
172 - The name of the transceiver policy.
173 type: str
174 required: true
175 aliases: [ transceiver_policy_name ]
176 aep:
177 description:
178 - The name of the attached entity profile (AEP) used by the leaf interface policy group.
179 type: str
180 aliases: [ aep_name ]
181 state:
182 description:
183 - Use C(present) or C(absent) for adding or removing.
184 - Use C(query) for listing an object or multiple objects.
185 type: str
186 choices: [ absent, present, query ]
187 default: present
188 name_alias:
189 description:
190 - The alias for the current object. This relates to the nameAlias field in ACI.
191 type: str
192 extends_documentation_fragment:
193 - cisco.aci.aci
194 - cisco.aci.annotation
195 - cisco.aci.owner
196
197 notes:
198 - When using the module please select the appropriate link_aggregation_type (lag_type).
199 - C(link) for Port Channel(PC), C(node) for Virtual Port Channel(VPC) and C(leaf) for Leaf Access Port Policy Group.
200 seealso:
201 - name: APIC Management Information Model reference
202 description: More information about the internal APIC classes B(infra:AccBndlGrp) and B(infra:AccPortGrp).
203 link: https://developer.cisco.com/docs/apic-mim-ref/
204 author:
205 - Bruno Calogero (@brunocalogero)
206 """
207
208 EXAMPLES = r"""
209 - name: Create a Port Channel (PC) Interface Policy Group
210 cisco.aci.aci_interface_policy_leaf_policy_group:
211 host: apic
212 username: admin
213 password: SomeSecretPassword
214 lag_type: link
215 policy_group: policygroupname
216 description: policygroupname description
217 link_level_policy: linklevelpolicy
218 cdp_policy: cdppolicy
219 lldp_policy: lldppolicy
220 port_channel_policy: lacppolicy
221 state: present
222 delegate_to: localhost
223
224 - name: Create a Virtual Port Channel (VPC) Interface Policy Group
225 cisco.aci.aci_interface_policy_leaf_policy_group:
226 host: apic
227 username: admin
228 password: SomeSecretPassword
229 lag_type: node
230 policy_group: policygroupname
231 link_level_policy: linklevelpolicy
232 cdp_policy: cdppolicy
233 lldp_policy: lldppolicy
234 port_channel_policy: lacppolicy
235 state: present
236 delegate_to: localhost
237
238 - name: Create a Leaf Access Port Policy Group
239 cisco.aci.aci_interface_policy_leaf_policy_group:
240 host: apic
241 username: admin
242 password: SomeSecretPassword
243 lag_type: leaf
244 policy_group: policygroupname
245 link_level_policy: linklevelpolicy
246 cdp_policy: cdppolicy
247 lldp_policy: lldppolicy
248 state: present
249 delegate_to: localhost
250
251 - name: Query all Leaf Access Port Policy Groups of type link
252 cisco.aci.aci_interface_policy_leaf_policy_group:
253 host: apic
254 username: admin
255 password: SomeSecretPassword
256 lag_type: link
257 state: query
258 delegate_to: localhost
259 register: query_result
260
261 - name: Query a specific Lead Access Port Policy Group
262 cisco.aci.aci_interface_policy_leaf_policy_group:
263 host: apic
264 username: admin
265 password: SomeSecretPassword
266 lag_type: leaf
267 policy_group: policygroupname
268 state: query
269 delegate_to: localhost
270 register: query_result
271
272 - name: Delete an Interface policy Leaf Policy Group
273 cisco.aci.aci_interface_policy_leaf_policy_group:
274 host: apic
275 username: admin
276 password: SomeSecretPassword
277 lag_type: leaf
278 policy_group: policygroupname
279 state: absent
280 delegate_to: localhost
281 """
282
283 RETURN = r"""
284 current:
285 description: The existing configuration from the APIC after the module has finished
286 returned: success
287 type: list
288 sample:
289 [
290 {
291 "fvTenant": {
292 "attributes": {
293 "descr": "Production environment",
294 "dn": "uni/tn-production",
295 "name": "production",
296 "nameAlias": "",
297 "ownerKey": "",
298 "ownerTag": ""
299 }
300 }
301 }
302 ]
303 error:
304 description: The error information as returned from the APIC
305 returned: failure
306 type: dict
307 sample:
308 {
309 "code": "122",
310 "text": "unknown managed object class foo"
311 }
312 raw:
313 description: The raw output returned by the APIC REST API (xml or json)
314 returned: parse error
315 type: str
316 sample: '<?xml version="1.0" encoding="UTF-8"?><imdata totalCount="1"><error code="122" text="unknown managed object class foo"/></imdata>'
317 sent:
318 description: The actual/minimal configuration pushed to the APIC
319 returned: info
320 type: list
321 sample:
322 {
323 "fvTenant": {
324 "attributes": {
325 "descr": "Production environment"
326 }
327 }
328 }
329 previous:
330 description: The original configuration from the APIC before the module has started
331 returned: info
332 type: list
333 sample:
334 [
335 {
336 "fvTenant": {
337 "attributes": {
338 "descr": "Production",
339 "dn": "uni/tn-production",
340 "name": "production",
341 "nameAlias": "",
342 "ownerKey": "",
343 "ownerTag": ""
344 }
345 }
346 }
347 ]
348 proposed:
349 description: The assembled configuration from the user-provided parameters
350 returned: info
351 type: dict
352 sample:
353 {
354 "fvTenant": {
355 "attributes": {
356 "descr": "Production environment",
357 "name": "production"
358 }
359 }
360 }
361 filter_string:
362 description: The filter string used for the request
363 returned: failure or debug
364 type: str
365 sample: ?rsp-prop-include=config-only
366 method:
367 description: The HTTP method used for the request to the APIC
368 returned: failure or debug
369 type: str
370 sample: POST
371 response:
372 description: The HTTP response from the APIC
373 returned: failure or debug
374 type: str
375 sample: OK (30 bytes)
376 status:
377 description: The HTTP status from the APIC
378 returned: failure or debug
379 type: int
380 sample: 200
381 url:
382 description: The HTTP url used for the request to the APIC
383 returned: failure or debug
384 type: str
385 sample: https://10.11.12.13/api/mo/uni/tn-production.json
386 """
387
388 from ansible.module_utils.basic import AnsibleModule
389 from ansible_collections.cisco.aci.plugins.module_utils.aci import ACIModule, aci_argument_spec, aci_annotation_spec, aci_owner_spec
390
391
392 def main():
393 argument_spec = aci_argument_spec()
394 argument_spec.update(aci_annotation_spec())
395 argument_spec.update(aci_owner_spec())
396 argument_spec.update(
397 # NOTE: Since this module needs to include both infra:AccBndlGrp (for PC and VPC) and infra:AccPortGrp (for leaf access port policy group):
398 # NOTE: The user(s) can make the choice between (link(PC), node(VPC), leaf(leaf-access port policy group))
399 lag_type=dict(type="str", required=True, aliases=["lag_type_name"], choices=["leaf", "link", "node"]),
400 policy_group=dict(type="str", aliases=["name", "policy_group_name"]), # Not required for querying all objects
401 description=dict(type="str", aliases=["descr"]),
402 link_level_policy=dict(type="str", aliases=["link_level_policy_name"]),
403 cdp_policy=dict(type="str", aliases=["cdp_policy_name"]),
404 mcp_policy=dict(type="str", aliases=["mcp_policy_name"]),
405 lldp_policy=dict(type="str", aliases=["lldp_policy_name"]),
406 stp_interface_policy=dict(type="str", aliases=["stp_interface_policy_name"]),
407 egress_data_plane_policing_policy=dict(type="str", aliases=["egress_data_plane_policing_policy_name"]),
408 ingress_data_plane_policing_policy=dict(type="str", aliases=["ingress_data_plane_policing_policy_name"]),
409 priority_flow_control_policy=dict(type="str", aliases=["priority_flow_control_policy_name"]),
410 fibre_channel_interface_policy=dict(type="str", aliases=["fibre_channel_interface_policy_name"]),
411 slow_drain_policy=dict(type="str", aliases=["slow_drain_policy_name"]),
412 port_channel_policy=dict(type="str", aliases=["port_channel_policy_name"]),
413 monitoring_policy=dict(type="str", aliases=["monitoring_policy_name"]),
414 storm_control_interface_policy=dict(type="str", aliases=["storm_control_interface_policy_name"]),
415 l2_interface_policy=dict(type="str", aliases=["l2_interface_policy_name"]),
416 port_security_policy=dict(type="str", aliases=["port_security_policy_name"]),
417 link_flap_policy=dict(type="str", aliases=["link_flap_policy_name"]),
418 link_level_flow_control=dict(type="str", aliases=["link_level_flow_control_name"]),
419 mac_sec_interface_policy=dict(type="str", aliases=["mac_sec_interface_policy_name"]),
420 copp_policy=dict(type="str", aliases=["copp_policy_name"]),
421 aep=dict(type="str", aliases=["aep_name"]),
422 sync_e_interface_policy=dict(type="str", aliases=["sync_e_interface_policy_name"]),
423 transceiver_policy=dict(
424 type="dict",
425 options=dict(
426 name=dict(type="str", required=True, aliases=["transceiver_policy_name"]),
427 type=dict(type="str", required=True, choices=["zr", "zrp"], aliases=["transceiver_policy_type"]),
428 ),
429 ),
430 poe_interface_policy=dict(type="str", aliases=["poe_interface_policy_name"]),
431 port_authentication=dict(type="str", aliases=["port_authentication_name"]),
432 dwdm=dict(type="str", aliases=["dwdm_name"]),
433 state=dict(type="str", default="present", choices=["absent", "present", "query"]),
434 name_alias=dict(type="str"),
435 )
436
437 module = AnsibleModule(
438 argument_spec=argument_spec,
439 supports_check_mode=True,
440 required_if=[
441 ["state", "absent", ["policy_group"]],
442 ["state", "present", ["policy_group"]],
443 ],
444 )
445
446 policy_group = module.params.get("policy_group")
447 description = module.params.get("description")
448 lag_type = module.params.get("lag_type")
449 link_level_policy = module.params.get("link_level_policy")
450 cdp_policy = module.params.get("cdp_policy")
451 mcp_policy = module.params.get("mcp_policy")
452 lldp_policy = module.params.get("lldp_policy")
453 stp_interface_policy = module.params.get("stp_interface_policy")
454 egress_data_plane_policing_policy = module.params.get("egress_data_plane_policing_policy")
455 ingress_data_plane_policing_policy = module.params.get("ingress_data_plane_policing_policy")
456 priority_flow_control_policy = module.params.get("priority_flow_control_policy")
457 fibre_channel_interface_policy = module.params.get("fibre_channel_interface_policy")
458 slow_drain_policy = module.params.get("slow_drain_policy")
459 port_channel_policy = module.params.get("port_channel_policy")
460 monitoring_policy = module.params.get("monitoring_policy")
461 storm_control_interface_policy = module.params.get("storm_control_interface_policy")
462 l2_interface_policy = module.params.get("l2_interface_policy")
463 port_security_policy = module.params.get("port_security_policy")
464 link_flap_policy = module.params.get("link_flap_policy")
465 link_level_flow_control = module.params.get("link_level_flow_control")
466 mac_sec_interface_policy = module.params.get("mac_sec_interface_policy")
467 copp_policy = module.params.get("copp_policy")
468 poe_interface_policy = module.params.get("poe_interface_policy")
469 port_authentication = module.params.get("port_authentication")
470 dwdm = module.params.get("dwdm")
471 aep = module.params.get("aep")
472 transceiver_policy = module.params.get("transceiver_policy")
473 sync_e_interface_policy = module.params.get("sync_e_interface_policy")
474
475 state = module.params.get("state")
476 name_alias = module.params.get("name_alias")
477
478 aci = ACIModule(module)
479 if lag_type == "leaf" and port_channel_policy is not None:
480 aci.fail_json(
481 "port_channel_policy is not a valid parameter for leaf\
482 (leaf access port policy group), if used\
483 assign null to it (port_channel_policy: null)."
484 )
485 invalid_parameters = {
486 "transceiver_policy": "transceiver_policy is not a valid parameter for link/node (Port Channel, Virtual Port Channel),\
487 if used assign null to it (transceiver_policy: null).",
488 "port_authentication": "port_authentication is not a valid parameter for link/node (Port Channel, Virtual Port Channel),\
489 if used assign null to it (port_authentication: null).",
490 "dwdm": "dwdm is not a valid parameter for link/node (Port Channel, Virtual Port Channel),\
491 if used assign null to it (dwdm: null).",
492 "poe_interface_policy": "poe_interface_policy is not a valid parameter for link/node (Port Channel, Virtual Port Channel),\
493 if used assign null to it (poe_interface_policy: null).",
494 }
495
496 if lag_type in ["link", "node"]:
497 for param, message in invalid_parameters.items():
498 if locals().get(param) is not None:
499 aci.fail_json(message)
500
501 if lag_type == "leaf":
502 aci_class_name = "infraAccPortGrp"
503 dn_name = "accportgrp"
504 class_config_dict = dict(
505 name=policy_group,
506 descr=description,
507 nameAlias=name_alias,
508 )
509 # Reset for target_filter
510 lag_type = None
511 else:
512 aci_class_name = "infraAccBndlGrp"
513 dn_name = "accbundle"
514 class_config_dict = dict(
515 name=policy_group,
516 descr=description,
517 lagT=lag_type,
518 nameAlias=name_alias,
519 )
520
521 child_configs = [
522 dict(
523 infraRsCdpIfPol=dict(
524 attributes=dict(
525 tnCdpIfPolName=cdp_policy,
526 ),
527 ),
528 ),
529 dict(
530 infraRsFcIfPol=dict(
531 attributes=dict(
532 tnFcIfPolName=fibre_channel_interface_policy,
533 ),
534 ),
535 ),
536 dict(
537 infraRsHIfPol=dict(
538 attributes=dict(
539 tnFabricHIfPolName=link_level_policy,
540 ),
541 ),
542 ),
543 dict(
544 infraRsL2IfPol=dict(
545 attributes=dict(
546 tnL2IfPolName=l2_interface_policy,
547 ),
548 ),
549 ),
550 dict(
551 infraRsL2PortSecurityPol=dict(
552 attributes=dict(
553 tnL2PortSecurityPolName=port_security_policy,
554 ),
555 ),
556 ),
557 dict(
558 infraRsLacpPol=dict(
559 attributes=dict(
560 tnLacpLagPolName=port_channel_policy,
561 ),
562 ),
563 ),
564 dict(
565 infraRsLldpIfPol=dict(
566 attributes=dict(
567 tnLldpIfPolName=lldp_policy,
568 ),
569 ),
570 ),
571 dict(
572 infraRsMcpIfPol=dict(
573 attributes=dict(
574 tnMcpIfPolName=mcp_policy,
575 ),
576 ),
577 ),
578 dict(
579 infraRsMonIfInfraPol=dict(
580 attributes=dict(
581 tnMonInfraPolName=monitoring_policy,
582 ),
583 ),
584 ),
585 dict(
586 infraRsQosEgressDppIfPol=dict(
587 attributes=dict(
588 tnQosDppPolName=egress_data_plane_policing_policy,
589 ),
590 ),
591 ),
592 dict(
593 infraRsQosIngressDppIfPol=dict(
594 attributes=dict(
595 tnQosDppPolName=ingress_data_plane_policing_policy,
596 ),
597 ),
598 ),
599 dict(
600 infraRsQosPfcIfPol=dict(
601 attributes=dict(
602 tnQosPfcIfPolName=priority_flow_control_policy,
603 ),
604 ),
605 ),
606 dict(
607 infraRsQosSdIfPol=dict(
608 attributes=dict(
609 tnQosSdIfPolName=slow_drain_policy,
610 ),
611 ),
612 ),
613 dict(
614 infraRsStormctrlIfPol=dict(
615 attributes=dict(
616 tnStormctrlIfPolName=storm_control_interface_policy,
617 ),
618 ),
619 ),
620 dict(
621 infraRsStpIfPol=dict(
622 attributes=dict(
623 tnStpIfPolName=stp_interface_policy,
624 ),
625 ),
626 ),
627 ]
628
629 child_classes = [
630 "infraRsAttEntP",
631 "infraRsCdpIfPol",
632 "infraRsFcIfPol",
633 "infraRsHIfPol",
634 "infraRsL2IfPol",
635 "infraRsL2PortSecurityPol",
636 "infraRsLacpPol",
637 "infraRsLldpIfPol",
638 "infraRsMcpIfPol",
639 "infraRsMonIfInfraPol",
640 "infraRsQosEgressDppIfPol",
641 "infraRsQosIngressDppIfPol",
642 "infraRsQosPfcIfPol",
643 "infraRsQosSdIfPol",
644 "infraRsStormctrlIfPol",
645 "infraRsStpIfPol",
646 ]
647
648 # Add infraRsattEntP binding only when aep is defined
649 if aep is not None:
650 child_configs.append(
651 dict(
652 infraRsAttEntP=dict(
653 attributes=dict(
654 tDn="uni/infra/attentp-{0}".format(aep),
655 ),
656 ),
657 )
658 )
659
660 # Add infraRsSynceEthIfPol/infraRsSynceEthIfPolBndlGrp binding only when sync_e_interface_policy is defined
661 if sync_e_interface_policy is not None:
662 if lag_type is None:
663 child_configs.append(
664 dict(
665 infraRsSynceEthIfPol=dict(
666 attributes=dict(
667 tnSynceEthIfPolName=sync_e_interface_policy,
668 ),
669 ),
670 )
671 )
672 child_classes.append("infraRsSynceEthIfPol")
673 elif lag_type == "node" or lag_type == "link":
674 child_configs.append(
675 dict(
676 infraRsSynceEthIfPolBndlGrp=dict(
677 attributes=dict(
678 tnSynceEthIfPolName=sync_e_interface_policy,
679 ),
680 ),
681 )
682 )
683 child_classes.append("infraRsSynceEthIfPolBndlGrp")
684
685 # Add the children only when lag_type == leaf (Leaf Interface specific policies).
686 if lag_type is None:
687 # Add infraRsOpticsIfPol binding only when transceiver_policy was defined
688 if transceiver_policy is not None:
689 child_configs.append(
690 dict(
691 infraRsOpticsIfPol=dict(
692 attributes=dict(
693 tDn="uni/infra/{0}-{1}".format(transceiver_policy.get("type"), transceiver_policy.get("name")),
694 ),
695 ),
696 )
697 )
698 child_classes.append("infraRsOpticsIfPol")
699
700 if dwdm is not None:
701 child_configs.append(
702 dict(
703 infraRsDwdmIfPol=dict(
704 attributes=dict(
705 tnDwdmIfPolName=dwdm,
706 ),
707 ),
708 )
709 )
710 child_classes.append("infraRsDwdmIfPol")
711
712 if port_authentication is not None:
713 child_configs.append(
714 dict(
715 infraRsL2PortAuthPol=dict(
716 attributes=dict(
717 tnL2PortAuthPolName=port_authentication,
718 ),
719 ),
720 )
721 )
722 child_classes.append("infraRsL2PortAuthPol")
723
724 if poe_interface_policy is not None:
725 child_configs.append(
726 dict(
727 infraRsPoeIfPol=dict(
728 attributes=dict(
729 tnPoeIfPolName=poe_interface_policy,
730 ),
731 ),
732 )
733 )
734 child_classes.append("infraRsPoeIfPol")
735
736 if link_flap_policy is not None:
737 child_configs.append(
738 dict(
739 infraRsLinkFlapPol=dict(
740 attributes=dict(
741 tnFabricLinkFlapPolName=link_flap_policy,
742 ),
743 ),
744 ),
745 )
746 child_classes.append("infraRsLinkFlapPol")
747
748 if link_level_flow_control is not None:
749 child_configs.append(
750 dict(
751 infraRsQosLlfcIfPol=dict(
752 attributes=dict(
753 tnQosLlfcIfPolName=link_level_flow_control,
754 ),
755 ),
756 ),
757 )
758 child_classes.append("infraRsQosLlfcIfPol")
759
760 if mac_sec_interface_policy is not None:
761 child_configs.append(
762 dict(
763 infraRsMacsecIfPol=dict(
764 attributes=dict(
765 tnMacsecIfPolName=mac_sec_interface_policy,
766 ),
767 ),
768 ),
769 )
770 child_classes.append("infraRsMacsecIfPol")
771
772 if copp_policy is not None:
773 child_configs.append(
774 dict(
775 infraRsCoppIfPol=dict(
776 attributes=dict(
777 tnCoppIfPolName=copp_policy,
778 ),
779 ),
780 ),
781 )
782 child_classes.append("infraRsCoppIfPol")
783
784 aci.construct_url(
785 root_class=dict(
786 aci_class=aci_class_name,
787 aci_rn="infra/funcprof/{0}-{1}".format(dn_name, policy_group),
788 module_object=policy_group,
789 target_filter={"name": policy_group, "lagT": lag_type},
790 ),
791 child_classes=child_classes,
792 )
793
794 aci.get_existing()
795
796 if state == "present":
797 aci.payload(
798 aci_class=aci_class_name,
799 class_config=class_config_dict,
800 child_configs=child_configs,
801 )
802
803 aci.get_diff(aci_class=aci_class_name)
804
805 aci.post_config()
806
807 elif state == "absent":
808 aci.delete_config()
809
810 aci.exit_json()
811
812
813 if __name__ == "__main__":
814 main()