diff --git a/changelogs/fragments/aci_interface_policy_leaf_policy_group-missing_aep.yaml b/changelogs/fragments/aci_interface_policy_leaf_policy_group-missing_aep.yaml new file mode 100644 index 00000000000..f58601ae279 --- /dev/null +++ b/changelogs/fragments/aci_interface_policy_leaf_policy_group-missing_aep.yaml @@ -0,0 +1,2 @@ +bugfixes: +- aci_interface_policy_leaf_policy_group - Support missing aep diff --git a/lib/ansible/modules/network/aci/aci_interface_policy_leaf_policy_group.py b/lib/ansible/modules/network/aci/aci_interface_policy_leaf_policy_group.py index 0869466815f..d043cd38c9e 100644 --- a/lib/ansible/modules/network/aci/aci_interface_policy_leaf_policy_group.py +++ b/lib/ansible/modules/network/aci/aci_interface_policy_leaf_policy_group.py @@ -370,6 +370,124 @@ def main(): lagT=lag_type, ) + child_configs = [ + dict( + infraRsCdpIfPol=dict( + attributes=dict( + tnCdpIfPolName=cdp_policy, + ), + ), + ), + dict( + infraRsFcIfPol=dict( + attributes=dict( + tnFcIfPolName=fibre_channel_interface_policy, + ), + ), + ), + dict( + infraRsHIfPol=dict( + attributes=dict( + tnFabricHIfPolName=link_level_policy, + ), + ), + ), + dict( + infraRsL2IfPol=dict( + attributes=dict( + tnL2IfPolName=l2_interface_policy, + ), + ), + ), + dict( + infraRsL2PortSecurityPol=dict( + attributes=dict( + tnL2PortSecurityPolName=port_security_policy, + ), + ), + ), + dict( + infraRsLacpPol=dict( + attributes=dict( + tnLacpLagPolName=port_channel_policy, + ), + ), + ), + dict( + infraRsLldpIfPol=dict( + attributes=dict( + tnLldpIfPolName=lldp_policy, + ), + ), + ), + dict( + infraRsMcpIfPol=dict( + attributes=dict( + tnMcpIfPolName=mcp_policy, + ), + ), + ), + dict( + infraRsMonIfInfraPol=dict( + attributes=dict( + tnMonInfraPolName=monitoring_policy, + ), + ), + ), + dict( + infraRsQosEgressDppIfPol=dict( + attributes=dict( + tnQosDppPolName=egress_data_plane_policing_policy, + ), + ), + ), + dict( + infraRsQosIngressDppIfPol=dict( + attributes=dict( + tnQosDppPolName=ingress_data_plane_policing_policy, + ), + ), + ), + dict( + infraRsQosPfcIfPol=dict( + attributes=dict( + tnQosPfcIfPolName=priority_flow_control_policy, + ), + ), + ), + dict( + infraRsQosSdIfPol=dict( + attributes=dict( + tnQosSdIfPolName=slow_drain_policy, + ), + ), + ), + dict( + infraRsStormctrlIfPol=dict( + attributes=dict( + tnStormctrlIfPolName=storm_control_interface_policy, + ), + ), + ), + dict( + infraRsStpIfPol=dict( + attributes=dict( + tnStpIfPolName=stp_interface_policy, + ), + ), + ), + ] + + # Add infraRsattEntP binding only when aep was defined + if aep is not None: + child_configs.append(dict( + infraRsAttEntP=dict( + attributes=dict( + tDn='uni/infra/attentp-{0}'.format(aep), + ), + ), + )) + aci = ACIModule(module) aci.construct_url( root_class=dict( @@ -404,120 +522,7 @@ def main(): aci.payload( aci_class=aci_class_name, class_config=class_config_dict, - child_configs=[ - dict( - infraRsAttEntP=dict( - attributes=dict( - tDn='uni/infra/attentp-{0}'.format(aep), - ), - ), - ), - dict( - infraRsCdpIfPol=dict( - attributes=dict( - tnCdpIfPolName=cdp_policy, - ), - ), - ), - dict( - infraRsFcIfPol=dict( - attributes=dict( - tnFcIfPolName=fibre_channel_interface_policy, - ), - ), - ), - dict( - infraRsHIfPol=dict( - attributes=dict( - tnFabricHIfPolName=link_level_policy, - ), - ), - ), - dict( - infraRsL2IfPol=dict( - attributes=dict( - tnL2IfPolName=l2_interface_policy, - ), - ), - ), - dict( - infraRsL2PortSecurityPol=dict( - attributes=dict( - tnL2PortSecurityPolName=port_security_policy, - ), - ), - ), - dict( - infraRsLacpPol=dict( - attributes=dict( - tnLacpLagPolName=port_channel_policy, - ), - ), - ), - dict( - infraRsLldpIfPol=dict( - attributes=dict( - tnLldpIfPolName=lldp_policy, - ), - ), - ), - dict( - infraRsMcpIfPol=dict( - attributes=dict( - tnMcpIfPolName=mcp_policy, - ), - ), - ), - dict( - infraRsMonIfInfraPol=dict( - attributes=dict( - tnMonInfraPolName=monitoring_policy, - ), - ), - ), - dict( - infraRsQosEgressDppIfPol=dict( - attributes=dict( - tnQosDppPolName=egress_data_plane_policing_policy, - ), - ), - ), - dict( - infraRsQosIngressDppIfPol=dict( - attributes=dict( - tnQosDppPolName=ingress_data_plane_policing_policy, - ), - ), - ), - dict( - infraRsQosPfcIfPol=dict( - attributes=dict( - tnQosPfcIfPolName=priority_flow_control_policy, - ), - ), - ), - dict( - infraRsQosSdIfPol=dict( - attributes=dict( - tnQosSdIfPolName=slow_drain_policy, - ), - ), - ), - dict( - infraRsStormctrlIfPol=dict( - attributes=dict( - tnStormctrlIfPolName=storm_control_interface_policy, - ), - ), - ), - dict( - infraRsStpIfPol=dict( - attributes=dict( - tnStpIfPolName=stp_interface_policy, - ), - ), - ), - ], + child_configs=child_configs, ) aci.get_diff(aci_class=aci_class_name) diff --git a/test/integration/targets/aci_interface_policy_leaf_policy_group/tasks/main.yml b/test/integration/targets/aci_interface_policy_leaf_policy_group/tasks/main.yml index 5ed87fa36a9..c9204101f08 100644 --- a/test/integration/targets/aci_interface_policy_leaf_policy_group/tasks/main.yml +++ b/test/integration/targets/aci_interface_policy_leaf_policy_group/tasks/main.yml @@ -90,7 +90,7 @@ - intf_policy_leaf_polgrp_check_mode_present is changed - intf_policy_leaf_polgrp_present is changed - intf_policy_leaf_polgrp_present.previous == [] - - 'intf_policy_leaf_polgrp_present.sent == {"infraAccBndlGrp": {"attributes": {"lagT": "link","name": "policygroupname_link"},"children": [{"infraRsAttEntP": {"attributes": {"tDn": "uni/infra/attentp-None"}}},{"infraRsFcIfPol": {"attributes": {"tnFcIfPolName": "fiberchannelpolicy"}}},{"infraRsHIfPol": {"attributes": {"tnFabricHIfPolName": "linklevelpolicy"}}}]}}' + - 'intf_policy_leaf_polgrp_present.sent == {"infraAccBndlGrp": {"attributes": {"lagT": "link","name": "policygroupname_link"},"children": [{"infraRsFcIfPol": {"attributes": {"tnFcIfPolName": "fiberchannelpolicy"}}},{"infraRsHIfPol": {"attributes": {"tnFabricHIfPolName": "linklevelpolicy"}}}]}}' - intf_policy_leaf_polgrp_idempotent is not changed - intf_policy_leaf_polgrp_idempotent.sent == {} - intf_policy_leaf_polgrp_update is changed @@ -209,7 +209,7 @@ - intf_policy_leaf_polgrp_check_mode_present is changed - intf_policy_leaf_polgrp_present is changed - intf_policy_leaf_polgrp_present.previous == [] - - 'intf_policy_leaf_polgrp_present.sent == {"infraAccBndlGrp": {"attributes": {"lagT": "node","name": "policygroupname_node"},"children": [{"infraRsAttEntP": {"attributes": {"tDn": "uni/infra/attentp-None"}}},{"infraRsFcIfPol": {"attributes": {"tnFcIfPolName": "fiberchannelpolicy"}}},{"infraRsHIfPol": {"attributes": {"tnFabricHIfPolName": "linklevelpolicy"}}}]}}' + - 'intf_policy_leaf_polgrp_present.sent == {"infraAccBndlGrp": {"attributes": {"lagT": "node","name": "policygroupname_node"},"children": [{"infraRsFcIfPol": {"attributes": {"tnFcIfPolName": "fiberchannelpolicy"}}},{"infraRsHIfPol": {"attributes": {"tnFabricHIfPolName": "linklevelpolicy"}}}]}}' - intf_policy_leaf_polgrp_idempotent is not changed - intf_policy_leaf_polgrp_idempotent.sent == {} - intf_policy_leaf_polgrp_update is changed @@ -363,7 +363,7 @@ - intf_policy_leaf_polgrp_check_mode_present is changed - intf_policy_leaf_polgrp_present is changed - intf_policy_leaf_polgrp_present.previous == [] - - 'intf_policy_leaf_polgrp_present.sent == {"infraAccPortGrp": {"attributes": {"name": "policygroupname_leaf"},"children": [{"infraRsAttEntP": {"attributes": {"tDn": "uni/infra/attentp-None"}}},{"infraRsFcIfPol": {"attributes": {"tnFcIfPolName": "fiberchannelpolicy"}}},{"infraRsHIfPol": {"attributes": {"tnFabricHIfPolName": "linklevelpolicy"}}}]}}' + - 'intf_policy_leaf_polgrp_present.sent == {"infraAccPortGrp": {"attributes": {"name": "policygroupname_leaf"},"children": [{"infraRsFcIfPol": {"attributes": {"tnFcIfPolName": "fiberchannelpolicy"}}},{"infraRsHIfPol": {"attributes": {"tnFabricHIfPolName": "linklevelpolicy"}}}]}}' - intf_policy_leaf_polgrp_idempotent is not changed - intf_policy_leaf_polgrp_idempotent.sent == {} - intf_policy_leaf_polgrp_update is changed