Skip to content

Commit

Permalink
aci_iplpg: Various fixes to integration tests/module (#36460)
Browse files Browse the repository at this point in the history
  • Loading branch information
dagwieers committed Feb 20, 2018
1 parent 6402a3e commit 5635c50
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 87 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@
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:
Expand All @@ -37,7 +34,11 @@
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.
Expand Down Expand Up @@ -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']),
Expand All @@ -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']
Expand All @@ -322,17 +323,13 @@ 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'
dn_name = 'accportgrp'
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'
Expand All @@ -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)
Expand All @@ -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()
Expand All @@ -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,
),
),
),
],
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5635c50

Please sign in to comment.