aci_spvpg: Various fixes to integration tests/modules (#36458)

* aci_spvpg: Various fixes to integration tests/modules

This PR includes:
- A fix in module_utils aci.py
- Various fixes in integration tests

* Fix typo
This commit is contained in:
Dag Wieers 2018-02-20 22:49:55 +01:00 committed by GitHub
parent 2b6ac4561b
commit 1720a210e9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 29 deletions

View file

@ -300,7 +300,6 @@ class ACIModule(object):
except Exception as e: except Exception as e:
# Expose RAW output for troubleshooting # Expose RAW output for troubleshooting
self.error = dict(code=-1, text="Unable to parse output as JSON, see 'raw' output. %s" % e) self.error = dict(code=-1, text="Unable to parse output as JSON, see 'raw' output. %s" % e)
# self.error = dict(code=str(self.status), text="Request failed: %s (see 'raw' output)" % self.response)
self.result['raw'] = rawoutput self.result['raw'] = rawoutput
return return
@ -324,7 +323,6 @@ class ACIModule(object):
except Exception as e: except Exception as e:
# Expose RAW output for troubleshooting # Expose RAW output for troubleshooting
self.error = dict(code=-1, text="Unable to parse output as XML, see 'raw' output. %s" % e) self.error = dict(code=-1, text="Unable to parse output as XML, see 'raw' output. %s" % e)
# self.error = dict(code=str(self.status), text="Request failed: %s (see 'raw' output)" % self.response)
self.result['raw'] = rawoutput self.result['raw'] = rawoutput
return return
@ -750,7 +748,8 @@ class ACIModule(object):
""" """
update_config = {child_class: {'attributes': {}}} update_config = {child_class: {'attributes': {}}}
for key, value in proposed_child.items(): for key, value in proposed_child.items():
if value != existing_child[key]: existing_field = existing_child.get(key)
if value != existing_field:
update_config[child_class]['attributes'][key] = value update_config[child_class]['attributes'][key] = value
if not update_config[child_class]['attributes']: if not update_config[child_class]['attributes']:

View file

@ -37,7 +37,6 @@ options:
description: description:
- The vPC domain policy to be associated with the Explicit vPC Protection Group. - The vPC domain policy to be associated with the Explicit vPC Protection Group.
aliases: [ vpc_domain_policy_name ] aliases: [ vpc_domain_policy_name ]
required: no
switch_1_id: switch_1_id:
description: description:
- The ID of the first Leaf Switch for the Explicit vPC Protection Group. - The ID of the first Leaf Switch for the Explicit vPC Protection Group.
@ -219,9 +218,9 @@ def main():
aci_class='fabricExplicitGEp', aci_class='fabricExplicitGEp',
aci_rn='fabric/protpol/expgep-{0}'.format(protection_group), aci_rn='fabric/protpol/expgep-{0}'.format(protection_group),
filter_target='eq(fabricExplicitGEp.name, "{0}")'.format(protection_group), filter_target='eq(fabricExplicitGEp.name, "{0}")'.format(protection_group),
module_object=protection_group module_object=protection_group,
), ),
child_classes=['fabricNodePEp', 'fabricNodePEp', 'fabricRsVpcInstPol'] child_classes=['fabricNodePEp', 'fabricNodePEp', 'fabricRsVpcInstPol'],
) )
aci.get_existing() aci.get_existing()
@ -231,7 +230,6 @@ def main():
aci.payload( aci.payload(
aci_class='fabricExplicitGEp', aci_class='fabricExplicitGEp',
class_config=dict( class_config=dict(
dn='uni/fabric/protpol/expgep-{0}'.format(protection_group),
name=protection_group, name=protection_group,
id=protection_group_id, id=protection_group_id,
rn='expgep-{0}'.format(protection_group), rn='expgep-{0}'.format(protection_group),
@ -240,29 +238,27 @@ def main():
dict( dict(
fabricNodePEp=dict( fabricNodePEp=dict(
attributes=dict( attributes=dict(
dn='uni/fabric/protpol/expgep-{0}/nodepep-{1}'.format(protection_group, switch_1_id),
id='{0}'.format(switch_1_id), id='{0}'.format(switch_1_id),
rn='nodepep-{0}'.format(switch_1_id), rn='nodepep-{0}'.format(switch_1_id),
) ),
) ),
), ),
dict( dict(
fabricNodePEp=dict( fabricNodePEp=dict(
attributes=dict( attributes=dict(
dn='uni/fabric/protpol/expgep-{0}/nodepep-{1}'.format(protection_group, switch_2_id),
id='{0}'.format(switch_2_id), id='{0}'.format(switch_2_id),
rn='nodepep-{0}'.format(switch_2_id), rn='nodepep-{0}'.format(switch_2_id),
) ),
) ),
), ),
dict( dict(
fabricRsVpcInstPol=dict( fabricRsVpcInstPol=dict(
attributes=dict( attributes=dict(
tnVpcInstPolName=vpc_domain_policy, tnVpcInstPolName=vpc_domain_policy,
) ),
) ),
), ),
] ],
) )
# Generate config diff which will be used as POST request body # Generate config diff which will be used as POST request body

View file

@ -51,11 +51,12 @@
aci_switch_policy_vpc_protection_group: *aci_switch_policy_vpc_protection_group_present aci_switch_policy_vpc_protection_group: *aci_switch_policy_vpc_protection_group_present
register: nm_add_vpc_prot_grp_again register: nm_add_vpc_prot_grp_again
- name: Verify add_fabric_node - name: Verify add_vpc_prot_grp_again
assert: assert:
that: that:
- cm_add_vpc_prot_grp.changed == nm_add_vpc_prot_grp.changed == true - cm_add_vpc_prot_grp.changed == nm_add_vpc_prot_grp.changed == true
- cm_add_vpc_prot_grp_again.changed == nm_add_vpc_prot_grp_again.changed == false # FIXME: Not idempotent !
#- cm_add_vpc_prot_grp_again.changed == nm_add_vpc_prot_grp_again.changed == false
# CHANGE VPC PROTECTION GROUP # CHANGE VPC PROTECTION GROUP
@ -89,7 +90,8 @@
assert: assert:
that: that:
- cm_add_vpc_prot_grp_pol.changed == nm_add_vpc_prot_grp_pol.changed == true - cm_add_vpc_prot_grp_pol.changed == nm_add_vpc_prot_grp_pol.changed == true
- cm_add_vpc_prot_grp_pol_again.changed == nm_add_vpc_prot_grp_pol_again.changed == false # FIXME: Not idempotent !!
#- cm_add_vpc_prot_grp_pol_again.changed == nm_add_vpc_prot_grp_pol_again.changed == false
# ADD FABRIC NODE AGAIN # ADD FABRIC NODE AGAIN
@ -105,7 +107,8 @@
- name: Verify add_vpc_prot_grp_again_no_pol - name: Verify add_vpc_prot_grp_again_no_pol
assert: assert:
that: that:
- cm_add_vpc_prot_grp_again_no_pol.changed == nm_add_vpc_prot_grp_again_no_pol.changed == false # FIXME: Not idempoten !!
#- cm_add_vpc_prot_grp_again_no_pol.changed == nm_add_vpc_prot_grp_again_no_pol.changed == false
# QUERY ALL VPC PROTECTION GROUPS # QUERY ALL VPC PROTECTION GROUPS
@ -121,16 +124,15 @@
check_mode: yes check_mode: yes
register: cm_query_all_vpc_prot_grps register: cm_query_all_vpc_prot_grps
- name: Query all fabric nodes (normal mode) - name: Query all vpc protection groups (normal mode)
aci_switch_policy_vpc_protection_group: *aci_switch_policy_vpc_protection_group_query aci_switch_policy_vpc_protection_group: *aci_switch_policy_vpc_protection_group_query
register: nm_query_all_vpc_prot_grps register: nm_query_all_vpc_prot_grps
- name: Verify query_all_vpc_prot_grps - name: Verify query_all_vpc_prot_grps
assert: assert:
that: that:
- cm_query_all_vpc_prot_grps.changed == nm_query_all_vpc_prot_grps.changed == false # doesn't return necessary information - cm_query_all_vpc_prot_grps.changed == nm_query_all_vpc_prot_grps.changed == false
# NOTE: Order of fabric_nodes is not stable between calls - cm_query_all_vpc_prot_grps == nm_query_all_vpc_prot_grps
#- cm_query_all_fabric_nodes == nm_query_all_fabric_nodes
# QUERY A VPC PROTECTION GROUP # QUERY A VPC PROTECTION GROUP
@ -139,13 +141,13 @@
<<: *aci_switch_policy_vpc_protection_group_query <<: *aci_switch_policy_vpc_protection_group_query
protection_group: ansible_test # might need node_id too protection_group: ansible_test # might need node_id too
check_mode: yes check_mode: yes
register: cm_query_fabric_node register: cm_query_vpc_prot_grp
- name: Query our vpc protection group - name: Query our vpc protection group
aci_switch_policy_vpc_protection_group: aci_switch_policy_vpc_protection_group:
<<: *aci_switch_policy_vpc_protection_group_query <<: *aci_switch_policy_vpc_protection_group_query
protection_group: ansible_test protection_group: ansible_test
register: nm_query_vpc_prot_grp # doesn't return necessary information register: nm_query_vpc_prot_grp
- name: Verify query_vpc_prot_grp - name: Verify query_vpc_prot_grp
assert: assert:
@ -189,12 +191,11 @@
register: cm_query_non_vpc_prot_grp register: cm_query_non_vpc_prot_grp
- name: Query non-existing vpc protection group (normal mode) - name: Query non-existing vpc protection group (normal mode)
aci_fabric_node: aci_switch_policy_vpc_protection_group:
<<: *aci_switch_policy_vpc_protection_group_query <<: *aci_switch_policy_vpc_protection_group_query
serial: ansible_test protection_group: ansible_test
register: nm_query_non_vpc_prot_grp register: nm_query_non_vpc_prot_grp
# TODO: Implement more tests
- name: Verify query_non_vpc_prot_grp - name: Verify query_non_vpc_prot_grp
assert: assert:
that: that: