From 5635c50f9b2752bc9305d033b557fff2db076928 Mon Sep 17 00:00:00 2001 From: Dag Wieers Date: Wed, 21 Feb 2018 00:20:38 +0100 Subject: [PATCH] aci_iplpg: Various fixes to integration tests/module (#36460) --- .../aci_interface_policy_leaf_policy_group.py | 175 +++++++++--------- .../tasks/main.yml | 6 +- 2 files changed, 94 insertions(+), 87 deletions(-) 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 426a332ed51..8e8700a3d54 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 @@ -22,9 +22,6 @@ description: author: - Bruno Calogero (@brunocalogero) version_added: '2.5' -notes: -- When using the module please select the appropriate link_aggregation_type (lag_type). - C(link) for Port Channel(PC), C(node) for Virtual Port Channel(VPC) and C(leaf) for Leaf Access Port Policy Group. options: policy_group: description: @@ -37,7 +34,11 @@ options: lag_type: description: - Selector for the type of leaf policy group we want to create. + - C(leaf) for Leaf Access Port Policy Group + - C(link) for Port Channel (PC) + - C(node) for Virtual Port Channel (VPC) aliases: [ lag_type_name ] + choices: [ leaf, link, node ] link_level_policy: description: - Choice of link_level_policy to be used as part of the leaf policy group to be created. @@ -271,9 +272,9 @@ def main(): argument_spec.update({ 'policy_group': dict(type='str', aliases=['name', 'policy_group_name']), 'description': dict(type='str', aliases=['descr']), - # NOTE: Since this module needs to include both infra:AccBndlGrp (for PC andVPC) and infra:AccPortGrp (for leaf access port policy group): + # NOTE: Since this module needs to include both infra:AccBndlGrp (for PC and VPC) and infra:AccPortGrp (for leaf access port policy group): # NOTE: I'll allow the user to make the choice here (link(PC), node(VPC), leaf(leaf-access port policy group)) - 'lag_type': dict(type='str', aliases=['lag_type_name']), + 'lag_type': dict(type='str', aliases=['lag_type_name'], choices=['leaf', 'link', 'node']), 'link_level_policy': dict(type='str', aliases=['link_level_policy_name']), 'cdp_policy': dict(type='str', aliases=['cdp_policy_name']), 'mcp_policy': dict(type='str', aliases=['mcp_policy_name']), @@ -290,16 +291,16 @@ def main(): 'l2_interface_policy': dict(type='str', aliases=['l2_interface_policy_name']), 'port_security_policy': dict(type='str', aliases=['port_security_policy_name']), 'aep': dict(type='str', aliases=['aep_name']), - 'state': dict(type='str', default='present', choices=['absent', 'present', 'query']) + 'state': dict(type='str', default='present', choices=['absent', 'present', 'query']), }) module = AnsibleModule( argument_spec=argument_spec, supports_check_mode=True, required_if=[ - ['state', 'absent', ['policy_group', 'lag_type']], - ['state', 'present', ['policy_group', 'lag_type']] - ] + ['state', 'absent', ['lag_type', 'policy_group']], + ['state', 'present', ['lag_type', 'policy_group']], + ], ) policy_group = module.params['policy_group'] @@ -322,9 +323,6 @@ def main(): port_security_policy = module.params['port_security_policy'] aep = module.params['aep'] state = module.params['state'] - aci_class_name = '' - dn_name = '' - class_config_dict = {} if lag_type == 'leaf': aci_class_name = 'infraAccPortGrp' @@ -332,7 +330,6 @@ def main(): class_config_dict = dict( name=policy_group, descr=description, - dn='uni/infra/funcprof/{0}-{1}'.format(dn_name, policy_group) ) elif lag_type == 'link' or lag_type == 'node': aci_class_name = 'infraAccBndlGrp' @@ -341,7 +338,6 @@ def main(): name=policy_group, descr=description, lagT=lag_type, - dn='uni/infra/funcprof/{0}-{1}'.format(dn_name, policy_group) ) aci = ACIModule(module) @@ -350,15 +346,26 @@ def main(): aci_class=aci_class_name, aci_rn='infra/funcprof/{0}-{1}'.format(dn_name, policy_group), filter_target='eq({0}.name, "{1}")'.format(aci_class_name, policy_group), - module_object=policy_group + module_object=policy_group, ), child_classes=[ - 'infraRsMonIfInfraPol', 'infraRsLldpIfPol', 'infraRsFcIfPol', - 'infraRsLacpPol', 'infraRsL2PortSecurityPol', 'infraRsHIfPol', - 'infraRsQosPfcIfPol', 'infraRsStpIfPol', 'infraRsQosIngressDppIfPol', - 'infraRsStormctrlIfPol', 'infraRsQosEgressDppIfPol', 'infraRsQosSdIfPol', - 'infraRsAttEntP', 'infraRsMcpIfPol', 'infraRsCdpIfPol', 'infraRsL2IfPol' - ] + 'infraRsAttEntP', + 'infraRsCdpIfPol', + 'infraRsFcIfPol', + 'infraRsHIfPol', + 'infraRsL2IfPol', + 'infraRsL2PortSecurityPol', + 'infraRsLacpPol', + 'infraRsLldpIfPol', + 'infraRsMcpIfPol', + 'infraRsMonIfInfraPol', + 'infraRsQosEgressDppIfPol', + 'infraRsQosIngressDppIfPol', + 'infraRsQosPfcIfPol', + 'infraRsQosSdIfPol', + 'infraRsStormctrlIfPol', + 'infraRsStpIfPol', + ], ) aci.get_existing() @@ -370,117 +377,117 @@ def main(): class_config=class_config_dict, child_configs=[ dict( - infraRsMonIfInfraPol=dict( + infraRsAttEntP=dict( attributes=dict( - tnMonInfraPolName=monitoring_policy - ) - ) + tDn='uni/infra/attentp-{0}'.format(aep), + ), + ), ), dict( - infraRsLldpIfPol=dict( + infraRsCdpIfPol=dict( attributes=dict( - tnLldpIfPolName=lldp_policy - ) - ) + tnCdpIfPolName=cdp_policy, + ), + ), ), dict( infraRsFcIfPol=dict( attributes=dict( - tnFcIfPolName=fibre_channel_interface_policy - ) - ) + tnFcIfPolName=fibre_channel_interface_policy, + ), + ), ), dict( - infraRsLacpPol=dict( + infraRsHIfPol=dict( attributes=dict( - tnLacpLagPolName=port_channel_policy - ) - ) + tnFabricHIfPolName=link_level_policy, + ), + ), ), dict( - infraRsL2PortSecurityPol=dict( + infraRsL2IfPol=dict( attributes=dict( - tnL2PortSecurityPolName=port_security_policy - ) - ) + tnL2IfPolName=l2_interface_policy, + ), + ), ), dict( - infraRsHIfPol=dict( + infraRsL2PortSecurityPol=dict( attributes=dict( - tnFabricHIfPolName=link_level_policy - ) - ) + tnL2PortSecurityPolName=port_security_policy, + ), + ), ), dict( - infraRsQosPfcIfPol=dict( + infraRsLacpPol=dict( attributes=dict( - tnQosPfcIfPolName=priority_flow_control_policy - ) - ) + tnLacpLagPolName=port_channel_policy, + ), + ), ), dict( - infraRsStpIfPol=dict( + infraRsLldpIfPol=dict( attributes=dict( - tnStpIfPolName=stp_interface_policy - ) - ) + tnLldpIfPolName=lldp_policy, + ), + ), ), dict( - infraRsQosIngressDppIfPol=dict( + infraRsMcpIfPol=dict( attributes=dict( - tnQosDppPolName=ingress_data_plane_policing_policy - ) - ) + tnMcpIfPolName=mcp_policy, + ), + ), ), dict( - infraRsStormctrlIfPol=dict( + infraRsMonIfInfraPol=dict( attributes=dict( - tnStormctrlIfPolName=storm_control_interface_policy - ) - ) + tnMonInfraPolName=monitoring_policy, + ), + ), ), dict( infraRsQosEgressDppIfPol=dict( attributes=dict( - tnQosDppPolName=egress_data_plane_policing_policy - ) - ) + tnQosDppPolName=egress_data_plane_policing_policy, + ), + ), ), dict( - infraRsQosSdIfPol=dict( + infraRsQosIngressDppIfPol=dict( attributes=dict( - tnQosSdIfPolName=slow_drain_policy - ) - ) + tnQosDppPolName=ingress_data_plane_policing_policy, + ), + ), ), dict( - infraRsMcpIfPol=dict( + infraRsQosPfcIfPol=dict( attributes=dict( - tnMcpIfPolName=mcp_policy - ) - ) + tnQosPfcIfPolName=priority_flow_control_policy, + ), + ), ), dict( - infraRsCdpIfPol=dict( + infraRsQosSdIfPol=dict( attributes=dict( - tnCdpIfPolName=cdp_policy - ) - ) + tnQosSdIfPolName=slow_drain_policy, + ), + ), ), dict( - infraRsL2IfPol=dict( + infraRsStormctrlIfPol=dict( attributes=dict( - tnL2IfPolName=l2_interface_policy - ) - ) + tnStormctrlIfPolName=storm_control_interface_policy, + ), + ), ), dict( - infraRsAttEntP=dict( + infraRsStpIfPol=dict( attributes=dict( - tDn='uni/infra/attentp-{0}'.format(aep) - ) - ) - ) + tnStpIfPolName=stp_interface_policy, + ), + ), + ), ], ) 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 1466894bd0e..5d3428ab1cc 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.changed == true - intf_policy_leaf_polgrp_present.changed == true - intf_policy_leaf_polgrp_present.previous == [] - - 'intf_policy_leaf_polgrp_present.sent == {"infraAccBndlGrp": {"attributes": {"dn": "uni/infra/funcprof/accbundle-policygroupname","lagT": "link","name": "policygroupname"},"children": [{"infraRsFcIfPol": {"attributes": {"tnFcIfPolName": "fiberchannelpolicy"}}},{"infraRsHIfPol": {"attributes": {"tnFabricHIfPolName": "linklevelpolicy"}}},{"infraRsAttEntP": {"attributes": {"tDn": "uni/infra/attentp-None"}}}]}}' + - 'intf_policy_leaf_polgrp_present.sent == {"infraAccBndlGrp": {"attributes": {"lagT": "link","name": "policygroupname"},"children": [{"infraRsFcIfPol": {"attributes": {"tnFcIfPolName": "fiberchannelpolicy"}}},{"infraRsHIfPol": {"attributes": {"tnFabricHIfPolName": "linklevelpolicy"}}},{"infraRsAttEntP": {"attributes": {"tDn": "uni/infra/attentp-None"}}}]}}' - intf_policy_leaf_polgrp_idempotent.changed == false - intf_policy_leaf_polgrp_idempotent.sent == {} - intf_policy_leaf_polgrp_update.changed == true @@ -209,7 +209,7 @@ - intf_policy_leaf_polgrp_check_mode_present.changed == true - intf_policy_leaf_polgrp_present.changed == true - intf_policy_leaf_polgrp_present.previous == [] - - 'intf_policy_leaf_polgrp_present.sent == {"infraAccBndlGrp": {"attributes": {"dn": "uni/infra/funcprof/accbundle-policygroupname","lagT": "node","name": "policygroupname"},"children": [{"infraRsFcIfPol": {"attributes": {"tnFcIfPolName": "fiberchannelpolicy"}}},{"infraRsHIfPol": {"attributes": {"tnFabricHIfPolName": "linklevelpolicy"}}},{"infraRsAttEntP": {"attributes": {"tDn": "uni/infra/attentp-None"}}}]}}' + - 'intf_policy_leaf_polgrp_present.sent == {"infraAccBndlGrp": {"attributes": {"lagT": "node","name": "policygroupname"},"children": [{"infraRsFcIfPol": {"attributes": {"tnFcIfPolName": "fiberchannelpolicy"}}},{"infraRsHIfPol": {"attributes": {"tnFabricHIfPolName": "linklevelpolicy"}}},{"infraRsAttEntP": {"attributes": {"tDn": "uni/infra/attentp-None"}}}]}}' - intf_policy_leaf_polgrp_idempotent.changed == false - intf_policy_leaf_polgrp_idempotent.sent == {} - intf_policy_leaf_polgrp_update.changed == true @@ -336,7 +336,7 @@ - intf_policy_leaf_polgrp_check_mode_present.changed == true - intf_policy_leaf_polgrp_present.changed == true - intf_policy_leaf_polgrp_present.previous == [] - - 'intf_policy_leaf_polgrp_present.sent == {"infraAccPortGrp": {"attributes": {"dn": "uni/infra/funcprof/accportgrp-policygroupname","name": "policygroupname"},"children": [{"infraRsFcIfPol": {"attributes": {"tnFcIfPolName": "fiberchannelpolicy"}}},{"infraRsHIfPol": {"attributes": {"tnFabricHIfPolName": "linklevelpolicy"}}},{"infraRsAttEntP": {"attributes": {"tDn": "uni/infra/attentp-None"}}}]}}' + - 'intf_policy_leaf_polgrp_present.sent == {"infraAccPortGrp": {"attributes": {"name": "policygroupname"},"children": [{"infraRsFcIfPol": {"attributes": {"tnFcIfPolName": "fiberchannelpolicy"}}},{"infraRsHIfPol": {"attributes": {"tnFabricHIfPolName": "linklevelpolicy"}}},{"infraRsAttEntP": {"attributes": {"tDn": "uni/infra/attentp-None"}}}]}}' - intf_policy_leaf_polgrp_idempotent.changed == false - intf_policy_leaf_polgrp_idempotent.sent == {} - intf_policy_leaf_polgrp_update.changed == true