From 859430076a9e06f3a36801cd37aa67e014fb24d4 Mon Sep 17 00:00:00 2001 From: Gaspard Micol Date: Mon, 6 Nov 2023 13:02:43 -0500 Subject: [PATCH] [ignore] Modify conditions to add missing child classes and add FQCN notation in all test cases for aci_tenant_action_rule_profile. --- .../modules/aci_tenant_action_rule_profile.py | 14 +++--- .../tasks/main.yml | 26 +++++------ .../tasks/main.yml | 26 +++++------ .../tasks/main.yml | 28 ++++++------ .../tasks/main.yml | 44 +++++++++---------- 5 files changed, 71 insertions(+), 67 deletions(-) diff --git a/plugins/modules/aci_tenant_action_rule_profile.py b/plugins/modules/aci_tenant_action_rule_profile.py index 25b692843..84841a2a1 100644 --- a/plugins/modules/aci_tenant_action_rule_profile.py +++ b/plugins/modules/aci_tenant_action_rule_profile.py @@ -76,12 +76,14 @@ description: - The set action rule based on nexthop unchanged configuration. - Can not be configured along with C(set_route_tag). + - Can not be configured for APIC version 4.2 and prior. - The APIC defaults to C(false) when unset. type: bool multipath: description: - Set action rule based on set redistribute multipath configuration. - Can not be configured along with C(set_route_tag). + - Can not be configured for APIC version 4.2 and prior. - The APIC defaults to C(false) when unset. type: bool set_preference: @@ -381,9 +383,7 @@ def main(): rtctrlSetComm=dict(attribute_input=module.params.get("set_community")), rtctrlSetDamp=dict(attribute_input=module.params.get("set_dampening")), rtctrlSetNh=dict(attribute_input=module.params.get("set_next_hop"), attribute_name="addr"), - rtctrlSetNhUnchanged=dict(attribute_input=module.params.get("next_hop_propagation")), rtctrlSetPref=dict(attribute_input=module.params.get("set_preference"), attribute_name="localPref"), - rtctrlSetRedistMultipath=dict(attribute_input=module.params.get("multipath")), rtctrlSetRtMetric=dict(attribute_input=module.params.get("set_metric"), attribute_name="metric"), rtctrlSetRtMetricType=dict( attribute_input=MATCH_ACTION_RULE_SET_METRIC_TYPE_MAPPING.get(module.params.get("set_metric_type")), attribute_name="metricType" @@ -393,9 +393,13 @@ def main(): ) # This condition deal with child classes which do not exist in APIC version 4.2 and prior. - for class_name in ["rtctrlSetNhUnchanged", "rtctrlSetRedistMultipath"]: - if child_classes[class_name].get("attribute_input") is None: - child_classes.pop(class_name) + additional_child_classes = dict( + rtctrlSetNhUnchanged=dict(attribute_input=module.params.get("next_hop_propagation")), + rtctrlSetRedistMultipath=dict(attribute_input=module.params.get("multipath")), + ) + for class_name, attribute in additional_child_classes.items(): + if attribute.get("attribute_input") is not None: + child_classes[class_name] = attribute aci.construct_url( root_class=dict( diff --git a/tests/integration/targets/aci_action_rule_additional_communities/tasks/main.yml b/tests/integration/targets/aci_action_rule_additional_communities/tasks/main.yml index 2bf0d8bbe..8c43e9823 100644 --- a/tests/integration/targets/aci_action_rule_additional_communities/tasks/main.yml +++ b/tests/integration/targets/aci_action_rule_additional_communities/tasks/main.yml @@ -21,7 +21,7 @@ # CLEAN ENVIRONMENT - name: Remove the ansible_tenant - aci_tenant: &aci_tenant_absent + cisco.aci.aci_tenant: &aci_tenant_absent <<: *aci_info tenant: ansible_tenant state: absent @@ -33,14 +33,14 @@ when: query_cloud.current == [] # This condition will execute only non-cloud sites block: # block specifies execution of tasks within, based on conditions - name: Add a new tenant - aci_tenant: &aci_tenant_present + cisco.aci.aci_tenant: &aci_tenant_present <<: *aci_info tenant: ansible_tenant description: Ansible tenant state: present - name: Add a new action rule profile - aci_tenant_action_rule_profile: &aci_action_rule_present + cisco.aci.aci_tenant_action_rule_profile: &aci_action_rule_present <<: *aci_info tenant: ansible_tenant action_rule: ansible_action_rule @@ -48,7 +48,7 @@ state: present - name: Add a additional communities action rule (check_mode) - aci_action_rule_additional_communities: &aci_action_rule_additional_communities_present + cisco.aci.aci_action_rule_additional_communities: &aci_action_rule_additional_communities_present <<: *aci_info tenant: ansible_tenant action_rule: ansible_action_rule @@ -59,17 +59,17 @@ register: cm_add_action_rule_add_comm - name: Add a additional communities action rule again (normal_mode) - aci_action_rule_additional_communities: + cisco.aci.aci_action_rule_additional_communities: <<: *aci_action_rule_additional_communities_present register: nm_add_action_rule_add_comm - name: Add a additional communities action rule again - testing idempotency - aci_action_rule_additional_communities: + cisco.aci.aci_action_rule_additional_communities: <<: *aci_action_rule_additional_communities_present register: nm_add_action_rule_add_comm_idempotency - name: Add a additional communities action rule - aci_action_rule_additional_communities: + cisco.aci.aci_action_rule_additional_communities: <<: *aci_info tenant: ansible_tenant action_rule: ansible_action_rule @@ -93,13 +93,13 @@ - nm_add_action_rule_add_comm_2.current.0.rtctrlSetAddComm.attributes.setCriteria == "append" - name: Query all additional communities action rules - aci_action_rule_additional_communities: + cisco.aci.aci_action_rule_additional_communities: <<: *aci_info state: query register: query_all_action_rule_add_comm - name: Query ansible_action_rule_add_comm additional communities action rule - aci_action_rule_additional_communities: + cisco.aci.aci_action_rule_additional_communities: <<: *aci_action_rule_additional_communities_present state: query register: query_action_rule_add_comm @@ -114,19 +114,19 @@ - query_action_rule_add_comm.current.0.rtctrlSetAddComm.attributes.setCriteria == "append" - name: Remove additional communities action rule (check_mode) - aci_action_rule_additional_communities: &aci_action_rule_additional_communities_absent + cisco.aci.aci_action_rule_additional_communities: &aci_action_rule_additional_communities_absent <<: *aci_action_rule_additional_communities_present state: absent check_mode: true register: cm_remove_action_rule_add_comm - name: Remove additional communities action rule (normal_mode) - aci_action_rule_additional_communities: + cisco.aci.aci_action_rule_additional_communities: <<: *aci_action_rule_additional_communities_absent register: nm_remove_remove_action_rule_add_comm - name: Remove additional communities action rule again - testing previous Removal - aci_action_rule_additional_communities: + cisco.aci.aci_action_rule_additional_communities: <<: *aci_action_rule_additional_communities_absent register: nm_remove_action_rule_add_comm_idempotency @@ -142,6 +142,6 @@ - nm_remove_action_rule_add_comm_idempotency.previous == [] - name: Remove the ansible_tenant - cleanup before ending tests - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_tenant_present state: absent diff --git a/tests/integration/targets/aci_action_rule_set_as_path/tasks/main.yml b/tests/integration/targets/aci_action_rule_set_as_path/tasks/main.yml index 8a049fcaf..841f12530 100644 --- a/tests/integration/targets/aci_action_rule_set_as_path/tasks/main.yml +++ b/tests/integration/targets/aci_action_rule_set_as_path/tasks/main.yml @@ -21,7 +21,7 @@ # CLEAN ENVIRONMENT - name: Remove the ansible_tenant - aci_tenant: &aci_tenant_absent + cisco.aci.aci_tenant: &aci_tenant_absent <<: *aci_info tenant: ansible_tenant state: absent @@ -33,14 +33,14 @@ when: query_cloud.current == [] # This condition will execute only non-cloud sites block: # block specifies execution of tasks within, based on conditions - name: Add a new tenant - aci_tenant: &aci_tenant_present + cisco.aci.aci_tenant: &aci_tenant_present <<: *aci_info tenant: ansible_tenant description: Ansible tenant state: present - name: Add a new action rule profile - aci_tenant_action_rule_profile: &aci_action_rule_present + cisco.aci.aci_tenant_action_rule_profile: &aci_action_rule_present <<: *aci_info tenant: ansible_tenant action_rule: ansible_action_rule @@ -48,7 +48,7 @@ state: present - name: Add a set AS path action rule (check_mode) - aci_action_rule_set_as_path: &aci_action_rule_set_as_path_present + cisco.aci.aci_action_rule_set_as_path: &aci_action_rule_set_as_path_present <<: *aci_info tenant: ansible_tenant action_rule: ansible_action_rule @@ -59,17 +59,17 @@ register: cm_add_action_rule_set_as_path - name: Add a set AS path action rule again (normal_mode) - aci_action_rule_set_as_path: + cisco.aci.aci_action_rule_set_as_path: <<: *aci_action_rule_set_as_path_present register: nm_add_action_rule_set_as_path - name: Add a set AS path action rule again - testing idempotency - aci_action_rule_set_as_path: + cisco.aci.aci_action_rule_set_as_path: <<: *aci_action_rule_set_as_path_present register: nm_add_action_rule_set_as_path_idempotency - name: Add a set AS path action rule - aci_action_rule_set_as_path: + cisco.aci.aci_action_rule_set_as_path: <<: *aci_info tenant: ansible_tenant action_rule: ansible_action_rule @@ -94,13 +94,13 @@ - nm_add_action_rule_set_as_path_2.current.0.rtctrlSetASPath.attributes.criteria == "prepend-last-as" - name: Query all set AS path action rules - aci_action_rule_set_as_path: + cisco.aci.aci_action_rule_set_as_path: <<: *aci_info state: query register: query_all_action_rule_set_as_path - name: Query ansible_action_rule_set_as_path set AS path action rule - aci_action_rule_set_as_path: + cisco.aci.aci_action_rule_set_as_path: <<: *aci_action_rule_set_as_path_present state: query register: query_action_rule_set_as_path @@ -115,19 +115,19 @@ - query_action_rule_set_as_path.current.0.rtctrlSetASPath.attributes.criteria == "prepend" - name: Remove set AS path action rule (check_mode) - aci_action_rule_set_as_path: &aci_action_rule_set_as_path_absent + cisco.aci.aci_action_rule_set_as_path: &aci_action_rule_set_as_path_absent <<: *aci_action_rule_set_as_path_present state: absent check_mode: true register: cm_remove_action_rule_set_as_path - name: Remove set AS path action rule (normal_mode) - aci_action_rule_set_as_path: + cisco.aci.aci_action_rule_set_as_path: <<: *aci_action_rule_set_as_path_absent register: nm_remove_remove_action_rule_set_as_path - name: Remove set AS path action rule again - testing previous Removal - aci_action_rule_set_as_path: + cisco.aci.aci_action_rule_set_as_path: <<: *aci_action_rule_set_as_path_absent register: nm_remove_action_rule_set_as_path_idempotency @@ -143,6 +143,6 @@ - nm_remove_action_rule_set_as_path_idempotency.previous == [] - name: Remove the ansible_tenant - cleanup before ending tests - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_tenant_present state: absent diff --git a/tests/integration/targets/aci_action_rule_set_as_path_asn/tasks/main.yml b/tests/integration/targets/aci_action_rule_set_as_path_asn/tasks/main.yml index 2e2634010..c0cfc4df0 100644 --- a/tests/integration/targets/aci_action_rule_set_as_path_asn/tasks/main.yml +++ b/tests/integration/targets/aci_action_rule_set_as_path_asn/tasks/main.yml @@ -21,7 +21,7 @@ # CLEAN ENVIRONMENT - name: Remove the ansible_tenant - aci_tenant: &aci_tenant_absent + cisco.aci.aci_tenant: &aci_tenant_absent <<: *aci_info tenant: ansible_tenant state: absent @@ -33,14 +33,14 @@ when: query_cloud.current == [] # This condition will execute only non-cloud sites block: # block specifies execution of tasks within, based on conditions - name: Add a new tenant - aci_tenant: &aci_tenant_present + cisco.aci.aci_tenant: &aci_tenant_present <<: *aci_info tenant: ansible_tenant description: Ansible tenant state: present - name: Add a new action rule profile - aci_tenant_action_rule_profile: &aci_action_rule_present + cisco.aci.aci_tenant_action_rule_profile: &aci_action_rule_present <<: *aci_info tenant: ansible_tenant action_rule: ansible_action_rule @@ -48,7 +48,7 @@ state: present - name: Add a set AS path action rule - aci_action_rule_set_as_path: &aci_action_rule_set_as_path_present + cisco.aci.aci_action_rule_set_as_path: &aci_action_rule_set_as_path_present <<: *aci_info tenant: ansible_tenant action_rule: ansible_action_rule @@ -56,7 +56,7 @@ state: present - name: Add a set AS path ASN action rule (check_mode) - aci_action_rule_set_as_path_asn: &aci_action_rule_set_as_path_asn_present + cisco.aci.aci_action_rule_set_as_path_asn: &aci_action_rule_set_as_path_asn_present <<: *aci_info tenant: ansible_tenant action_rule: ansible_action_rule @@ -67,17 +67,17 @@ register: cm_add_action_rule_set_as_path_asn - name: Add a set AS path ASN action rule again (normal_mode) - aci_action_rule_set_as_path_asn: + cisco.aci.aci_action_rule_set_as_path_asn: <<: *aci_action_rule_set_as_path_asn_present register: nm_add_action_rule_set_as_path_asn - name: Add a set AS path ASN action rule again - testing idempotency - aci_action_rule_set_as_path_asn: + cisco.aci.aci_action_rule_set_as_path_asn: <<: *aci_action_rule_set_as_path_asn_present register: nm_add_action_rule_set_as_path_asn_idempotency - name: Add a set AS path ASN action rule - aci_action_rule_set_as_path_asn: + cisco.aci.aci_action_rule_set_as_path_asn: <<: *aci_info tenant: ansible_tenant action_rule: ansible_action_rule @@ -102,13 +102,13 @@ - nm_add_action_rule_set_as_path_asn_2.current.0.rtctrlSetASPathASN.attributes.order == "2" - name: Query all set AS path ASN action rules - aci_action_rule_set_as_path_asn: + cisco.aci.aci_action_rule_set_as_path_asn: <<: *aci_info state: query register: query_all_action_rule_set_as_path_asn - name: Query ansible_action_rule_set_as_path_asn set AS path ASN action rule - aci_action_rule_set_as_path_asn: + cisco.aci.aci_action_rule_set_as_path_asn: <<: *aci_action_rule_set_as_path_asn_present state: query register: query_action_rule_set_as_path_asn @@ -123,19 +123,19 @@ - query_action_rule_set_as_path_asn.current.0.rtctrlSetASPathASN.attributes.order == "1" - name: Remove set AS path ASN action rule (check_mode) - aci_action_rule_set_as_path_asn: &aci_action_rule_set_as_path_asn_absent + cisco.aci.aci_action_rule_set_as_path_asn: &aci_action_rule_set_as_path_asn_absent <<: *aci_action_rule_set_as_path_asn_present state: absent check_mode: true register: cm_remove_action_rule_set_as_path_asn - name: Remove set AS path ASN action rule (normal_mode) - aci_action_rule_set_as_path_asn: + cisco.aci.aci_action_rule_set_as_path_asn: <<: *aci_action_rule_set_as_path_asn_absent register: nm_remove_remove_action_rule_set_as_path_asn - name: Remove set AS path ASN action rule again - testing previous Removal - aci_action_rule_set_as_path_asn: + cisco.aci.aci_action_rule_set_as_path_asn: <<: *aci_action_rule_set_as_path_asn_absent register: nm_remove_action_rule_set_as_path_asn_idempotency @@ -151,6 +151,6 @@ - nm_remove_action_rule_set_as_path_asn_idempotency.previous == [] - name: Remove the ansible_tenant - cleanup before ending tests - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_tenant_present state: absent diff --git a/tests/integration/targets/aci_tenant_action_rule_profile/tasks/main.yml b/tests/integration/targets/aci_tenant_action_rule_profile/tasks/main.yml index 577567bd3..d3c28e2ea 100644 --- a/tests/integration/targets/aci_tenant_action_rule_profile/tasks/main.yml +++ b/tests/integration/targets/aci_tenant_action_rule_profile/tasks/main.yml @@ -29,13 +29,13 @@ block: # block specifies execution of tasks within, based on conditions # Clean Environment - name: create tenant - aci_tenant: &aci_tenant_present + cisco.aci.aci_tenant: &aci_tenant_present <<: *aci_info tenant: ansible_test state: present - name: Ensure first action rule profile does not exist - aci_tenant_action_rule_profile: &aci_tenant_action_rule_profile_absent + cisco.aci.aci_tenant_action_rule_profile: &aci_tenant_action_rule_profile_absent <<: *aci_tenant_present name: anstest description: test for action rule profile @@ -57,7 +57,7 @@ - name: Ensure second action rule profile does not exist - APIC version >= 5.0 when: version.current.0.topSystem.attributes.version is version('5', '>=') - aci_tenant_action_rule_profile: &aci_tenant_action_rule_profile_2_5_absent + cisco.aci.aci_tenant_action_rule_profile: &aci_tenant_action_rule_profile_2_5_absent <<: *aci_tenant_present name: anstest_2 set_next_hop: 1.1.1.2 @@ -67,39 +67,39 @@ - name: Ensure second action rule profile does not exist - APIC version < 5.0 when: version.current.0.topSystem.attributes.version is version('5', '<') - aci_tenant_action_rule_profile: &aci_tenant_action_rule_profile_2_absent + cisco.aci.aci_tenant_action_rule_profile: &aci_tenant_action_rule_profile_2_absent <<: *aci_tenant_present name: anstest_2 set_next_hop: 1.1.1.2 state: absent - name: Create first action rule profile (check_mode) - aci_tenant_action_rule_profile: &aci_tenant_action_rule_profile_present + cisco.aci.aci_tenant_action_rule_profile: &aci_tenant_action_rule_profile_present <<: *aci_tenant_action_rule_profile_absent state: present check_mode: true register: cm_add_tenant_action_rule_profile_1 - name: Create first action rule profile (normal_mode) - aci_tenant_action_rule_profile: + cisco.aci.aci_tenant_action_rule_profile: <<: *aci_tenant_action_rule_profile_present register: nm_add_tenant_action_rule_profile_1 - name: Create first action rule profile again - testing idempotency - aci_tenant_action_rule_profile: + cisco.aci.aci_tenant_action_rule_profile: <<: *aci_tenant_action_rule_profile_present register: idempotency_add_tenant_action_rule_profile_1 - name: Create second action rule profile - APIC version >= 5.0 when: version.current.0.topSystem.attributes.version is version('5', '>=') - aci_tenant_action_rule_profile: &aci_tenant_action_rule_profile_2_5_present + cisco.aci.aci_tenant_action_rule_profile: &aci_tenant_action_rule_profile_2_5_present <<: *aci_tenant_action_rule_profile_2_5_absent state: present register: nm_add_tenant_action_rule_profile_2_5 - name: Create second action rule profile - APIC version < 5.0 when: version.current.0.topSystem.attributes.version is version('5', '<') - aci_tenant_action_rule_profile: &aci_tenant_action_rule_profile_2_present + cisco.aci.aci_tenant_action_rule_profile: &aci_tenant_action_rule_profile_2_present <<: *aci_tenant_action_rule_profile_2_absent state: present register: nm_add_tenant_action_rule_profile_2 @@ -145,13 +145,13 @@ - nm_add_tenant_action_rule_profile_2.current.0.rtctrlAttrP.children.0.rtctrlSetNh.attributes.addr == "1.1.1.2" - name: Query all action rule profiles - aci_tenant_action_rule_profile: + cisco.aci.aci_tenant_action_rule_profile: <<: *aci_info state: query register: query_all_tenant_action_rule_profile - name: Query first action rule profile - aci_tenant_action_rule_profile: + cisco.aci.aci_tenant_action_rule_profile: <<: *aci_tenant_action_rule_profile_present state: query register: query_first_tenant_action_rule_profile @@ -178,7 +178,7 @@ - query_first_tenant_action_rule_profile.current.0.rtctrlAttrP.children.7.rtctrlSetTag.attributes.tag == "100" - name: Delete children for first action rule profile (check_mode) - aci_tenant_action_rule_profile: &aci_tenant_action_rule_profile_children_deleted + cisco.aci.aci_tenant_action_rule_profile: &aci_tenant_action_rule_profile_children_deleted <<: *aci_tenant_action_rule_profile_present set_preference: "" set_route_tag: "" @@ -192,18 +192,18 @@ register: cm_delete_children_tenant_action_rule_profile_1 - name: Delete children for first action rule profile (normal_mode) - aci_tenant_action_rule_profile: + cisco.aci.aci_tenant_action_rule_profile: <<: *aci_tenant_action_rule_profile_children_deleted register: nm_delete_children_tenant_action_rule_profile_1 - name: Delete children for first action rule profile again - testing idempotency - aci_tenant_action_rule_profile: + cisco.aci.aci_tenant_action_rule_profile: <<: *aci_tenant_action_rule_profile_children_deleted register: idempotency_delete_children_tenant_action_rule_profile_1 - name: Delete children for second action rule profile - APIC version >= 5.0 when: version.current.0.topSystem.attributes.version is version('5', '>=') - aci_tenant_action_rule_profile: + cisco.aci.aci_tenant_action_rule_profile: <<: *aci_tenant_action_rule_profile_2_5_present set_next_hop: "" next_hop_propagation: false @@ -212,7 +212,7 @@ - name: Delete children for second action rule profile - APIC version < 5.0 when: version.current.0.topSystem.attributes.version is version('5', '<') - aci_tenant_action_rule_profile: + cisco.aci.aci_tenant_action_rule_profile: <<: *aci_tenant_action_rule_profile_2_present set_next_hop: "" register: nm_delete_children_tenant_action_rule_profile_2 @@ -241,34 +241,34 @@ - nm_delete_children_tenant_action_rule_profile_2.current.0.rtctrlAttrP | length == 1 - name: Delete first action rule profile (check_mode) - aci_tenant_action_rule_profile: + cisco.aci.aci_tenant_action_rule_profile: <<: *aci_tenant_action_rule_profile_present state: absent check_mode: true register: cm_delete_tenant_action_rule_profile_1 - name: Delete first action rule profile (normal_mode) - aci_tenant_action_rule_profile: + cisco.aci.aci_tenant_action_rule_profile: <<: *aci_tenant_action_rule_profile_present state: absent register: nm_delete_tenant_action_rule_profile_1 - name: Delete first action rule profile again - testing idempotency - aci_tenant_action_rule_profile: + cisco.aci.aci_tenant_action_rule_profile: <<: *aci_tenant_action_rule_profile_present state: absent register: idempotency_delete_tenant_action_rule_profile_1 - name: Delete second action rule profile - APIC version >= 5.0 when: version.current.0.topSystem.attributes.version is version('5', '>=') - aci_tenant_action_rule_profile: + cisco.aci.aci_tenant_action_rule_profile: <<: *aci_tenant_action_rule_profile_2_5_present state: absent register: nm_delete_tenant_action_rule_profile_2_5 - name: Delete second action rule profile - APIC version < 5.0 when: version.current.0.topSystem.attributes.version is version('5', '<') - aci_tenant_action_rule_profile: + cisco.aci.aci_tenant_action_rule_profile: <<: *aci_tenant_action_rule_profile_2_present state: absent register: nm_delete_tenant_action_rule_profile_2 @@ -301,6 +301,6 @@ - nm_delete_tenant_action_rule_profile_2.current == [] - name: Delete tenant - clean up the environment - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_tenant_present state: absent \ No newline at end of file