1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

aci_switch_policy_vpc_protection_group: Fix idempotency (#45091)

This commit is contained in:
Dag Wieers 2018-09-03 16:39:39 +02:00 committed by GitHub
parent aeac8fe141
commit 6faf400621
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 13 deletions

View file

@ -808,11 +808,15 @@ class ACIModule(object):
proposed_config = proposed_child[key]['attributes']
existing_config = None
# FIXME: Design causes issues for repeated child_classes
# get existing dictionary from the list of existing to use for comparison
for child in existing_children:
if child.get(child_class):
existing_config = child[key]['attributes']
break
# NOTE: This is an ugly fix
# Return the one that is a subset match
if set(proposed_config.items()).issubset(set(existing_config.items())):
break
return child_class, proposed_config, existing_config

View file

@ -255,14 +255,12 @@ def main():
class_config=dict(
name=protection_group,
id=protection_group_id,
rn='expgep-{0}'.format(protection_group),
),
child_configs=[
dict(
fabricNodePEp=dict(
attributes=dict(
id='{0}'.format(switch_1_id),
rn='nodepep-{0}'.format(switch_1_id),
),
),
),
@ -270,7 +268,6 @@ def main():
fabricNodePEp=dict(
attributes=dict(
id='{0}'.format(switch_2_id),
rn='nodepep-{0}'.format(switch_2_id),
),
),
),

View file

@ -58,9 +58,8 @@
that:
- cm_add_vpc_prot_grp is changed
- nm_add_vpc_prot_grp is changed
# FIXME: Not idempotent !
#- cm_add_vpc_prot_grp_again is not changed
#- nm_add_vpc_prot_grp_again is not changed
- cm_add_vpc_prot_grp_again is not changed
- nm_add_vpc_prot_grp_again is not changed
# CHANGE VPC PROTECTION GROUP
@ -95,9 +94,8 @@
that:
- cm_add_vpc_prot_grp_pol is changed
- nm_add_vpc_prot_grp_pol is changed
# FIXME: Not idempotent !!
#- cm_add_vpc_prot_grp_pol_again is not changed
#- nm_add_vpc_prot_grp_pol_again is not changed
- cm_add_vpc_prot_grp_pol_again is not changed
- nm_add_vpc_prot_grp_pol_again is not changed
# ADD FABRIC NODE AGAIN
@ -113,9 +111,8 @@
- name: Verify add_vpc_prot_grp_again_no_pol
assert:
that:
# FIXME: Not idempoten !!
#- cm_add_vpc_prot_grp_again_no_pol is not changed
#- nm_add_vpc_prot_grp_again_no_pol is not changed
- cm_add_vpc_prot_grp_again_no_pol is not changed
- nm_add_vpc_prot_grp_again_no_pol is not changed
# QUERY ALL VPC PROTECTION GROUPS