From 086f5f9e5efc6ba6e04e1a4898508ccdbff8784b Mon Sep 17 00:00:00 2001 From: Sabari Jaganathan Date: Wed, 2 Feb 2022 18:52:24 +0530 Subject: [PATCH 1/6] Added Fex Profile Policy Group module and test cases --- ...s_port_to_interface_policy_leaf_profile.py | 63 +++- ...eaf_interface_profiles_fex_policy_group.py | 292 ++++++++++++++++++ .../tasks/main.yml | 70 ++++- .../aliases | 2 + .../tasks/main.yml | 283 +++++++++++++++++ 5 files changed, 699 insertions(+), 11 deletions(-) create mode 100644 plugins/modules/aci_leaf_interface_profiles_fex_policy_group.py create mode 100644 tests/integration/targets/aci_leaf_interface_profiles_fex_policy_group/aliases create mode 100644 tests/integration/targets/aci_leaf_interface_profiles_fex_policy_group/tasks/main.yml diff --git a/plugins/modules/aci_access_port_to_interface_policy_leaf_profile.py b/plugins/modules/aci_access_port_to_interface_policy_leaf_profile.py index f624d660f..591999b71 100644 --- a/plugins/modules/aci_access_port_to_interface_policy_leaf_profile.py +++ b/plugins/modules/aci_access_port_to_interface_policy_leaf_profile.py @@ -94,8 +94,17 @@ description: - The type of interface for the static EPG deployment. type: str - choices: [ breakout, fex, port_channel, switch_port, vpc ] + choices: [ breakout, fex, port_channel, switch_port, vpc , fex_profile] default: switch_port + fex_id: + description: + - Id of the fex profile, the valid FEX ID is between 101 to 199. + type: int + fex_profile: + description: + - The name of the Fex Profile. + type: str + aliases: [ fex_profile_name ] type: description: - The type of access port to be created under respective profile. @@ -196,6 +205,23 @@ state: query delegate_to: localhost register: query_result + +- name: Create and Bind Access Port Selector with Fex Profile Policy Group + cisco.aci.aci_access_port_to_interface_policy_leaf_profile: + host: apic + username: admin + password: SomeSecretPassword + leaf_interface_profile: leafintprftest + fex_profile: fexintprftest + policy_group: fexintprftest + access_port_selector_name: anstest_fex_accessportselector + interface_type: fex_profile + from_port: 13 + to_port: 13 + port_blk: block2 + fex_id: 105 + state: present + delegate_to: localhost """ RETURN = r""" @@ -309,6 +335,7 @@ INTERFACE_TYPE_MAPPING = dict( breakout="uni/infra/funcprof/brkoutportgrp-{0}", fex="uni/infra/funcprof/accportgrp-{0}", + fex_profile="uni/infra/fexprof-{0}/fexbundle-{1}", port_channel="uni/infra/funcprof/accbundle-{0}", switch_port="uni/infra/funcprof/accportgrp-{0}", vpc="uni/infra/funcprof/accbundle-{0}", @@ -330,7 +357,9 @@ def main(): from_card=dict(type="str", aliases=["from_card_range"]), to_card=dict(type="str", aliases=["to_card_range"]), policy_group=dict(type="str", aliases=["policy_group_name"]), - interface_type=dict(type="str", default="switch_port", choices=["breakout", "fex", "port_channel", "switch_port", "vpc"]), + interface_type=dict(type="str", default="switch_port", choices=["breakout", "fex", "port_channel", "switch_port", "vpc", "fex_profile"]), + fex_id=dict(type="int"), + fex_profile=dict(type="str", aliases=["fex_profile_name"]), type=dict(type="str", default="leaf", choices=["fex", "leaf"]), state=dict(type="str", default="present", choices=["absent", "present", "query"]), ) @@ -355,6 +384,8 @@ def main(): to_card = module.params.get("to_card") policy_group = module.params.get("policy_group") interface_type = module.params.get("interface_type") + fex_id = module.params.get("fex_id") + fex_profile = module.params.get("fex_profile") state = module.params.get("state") type_profile = module.params.get("type") @@ -376,16 +407,28 @@ def main(): # Add infraRsAccBaseGrp only when policy_group was defined if policy_group is not None: - child_configs.append( - dict( - infraRsAccBaseGrp=dict( - attributes=dict( - tDn=INTERFACE_TYPE_MAPPING[interface_type].format(policy_group), - ), - ), - ) + if fex_profile is None: + infra_rs_Acc_base_grp_t_dn = INTERFACE_TYPE_MAPPING[interface_type].format(policy_group) + else: + infra_rs_Acc_base_grp_t_dn = INTERFACE_TYPE_MAPPING[interface_type].format(fex_profile, policy_group) + + infra_rs_Acc_base_grp = dict( + infraRsAccBaseGrp=dict( + attributes=dict(tDn=infra_rs_Acc_base_grp_t_dn), + ), ) + if interface_type == "fex_profile": + if fex_id is not None: + if fex_id in range(101, 200): + infra_rs_Acc_base_grp["infraRsAccBaseGrp"]["attributes"]["fexId"] = fex_id + else: + module.fail_json(msg="The valid FEX ID is between 101 to 199") + else: + module.fail_json(msg="The fex_id must not be None, when interface_type is fex_profile") + + child_configs.append(infra_rs_Acc_base_grp) + aci = ACIModule(module) aci_class = "infraAccPortP" aci_rn = "accportprof" diff --git a/plugins/modules/aci_leaf_interface_profiles_fex_policy_group.py b/plugins/modules/aci_leaf_interface_profiles_fex_policy_group.py new file mode 100644 index 000000000..268fea884 --- /dev/null +++ b/plugins/modules/aci_leaf_interface_profiles_fex_policy_group.py @@ -0,0 +1,292 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2022, Sabari Jaganathan +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = {"metadata_version": "1.1", "status": ["preview"], "supported_by": "certified"} + +DOCUMENTATION = r""" +--- +module: aci_leaf_interface_profiles_fex_policy_group +short_description: Manage leaf interface profiles fex policy group (infra:FexBndlGrp) +description: +- Manage leaf interface profiles fex policy group on Cisco ACI fabrics. +options: + name: + description: + - The name of the Fex Profile Policy Group. + type: str + aliases: [ policy_group ] + fex_profile: + description: + - The name of the Fex Profile. + type: str + state: + description: + - Use C(present) or C(absent) for adding or removing. + - Use C(query) for listing an object or multiple objects. + type: str + choices: [ absent, present, query ] + default: present +extends_documentation_fragment: +- cisco.aci.aci +- cisco.aci.annotation +- cisco.aci.owner + +seealso: +- name: APIC Management Information Model reference + description: More information about the internal APIC class B(infra:FexBndlGrp). + link: https://developer.cisco.com/docs/apic-mim-ref/ +author: +- Sabari Jaganathan (@sajagana) +""" + +EXAMPLES = r""" +- name: Add a new fex policy group + cisco.aci.aci_leaf_interface_profiles_fex_policy_group: + host: apic + username: admin + password: SomeSecretPassword + name: fex_policy_group + fex_profile: anstest_fex_profile + state: present + delegate_to: localhost + +- name: Add list of fex policy groups + cisco.aci.aci_leaf_interface_profiles_fex_policy_group: + host: apic + username: admin + password: SomeSecretPassword + name: "{{ item.name }}" + fex_profile: "{{ item.fex_profile }}" + state: present + delegate_to: localhost + with_items: + - name: fex_policy_group_1 + fex_profile: anstest_fex_profile + - name: fex_policy_group_2 + fex_profile: anstest_fex_profile + +- name: Query a fex policy group under fex profile + cisco.aci.aci_leaf_interface_profiles_fex_policy_group: + host: apic + username: admin + password: SomeSecretPassword + name: fex_policy_group + fex_profile: anstest_fex_profile + state: query + delegate_to: localhost + +- name: Query all fex policy groups under fex profile + cisco.aci.aci_leaf_interface_profiles_fex_policy_group: + host: apic + username: admin + password: SomeSecretPassword + fex_profile: anstest_fex_profile + state: query + delegate_to: localhost + +- name: Query all fex policy groups with name + cisco.aci.aci_leaf_interface_profiles_fex_policy_group: + host: apic + username: admin + password: SomeSecretPassword + name: fex_policy_group + state: query + delegate_to: localhost + +- name: Query all fex policy groups + cisco.aci.aci_leaf_interface_profiles_fex_policy_group: + host: apic + username: admin + password: SomeSecretPassword + state: query + delegate_to: localhost + +- name: Remove fex policy group + cisco.aci.aci_leaf_interface_profiles_fex_policy_group: + host: apic + username: admin + password: SomeSecretPassword + name: fex_policy_group + fex_profile: anstest_fex_profile + state: absent + delegate_to: localhost +""" + +RETURN = r""" +current: + description: The existing configuration from the APIC after the module has finished + returned: success + type: list + sample: + [ + { + "fvTenant": { + "attributes": { + "descr": "Production environment", + "dn": "uni/tn-production", + "name": "production", + "nameAlias": "", + "ownerKey": "", + "ownerTag": "" + } + } + } + ] +error: + description: The error information as returned from the APIC + returned: failure + type: dict + sample: + { + "code": "122", + "text": "unknown managed object class foo" + } +raw: + description: The raw output returned by the APIC REST API (xml or json) + returned: parse error + type: str + sample: '' +sent: + description: The actual/minimal configuration pushed to the APIC + returned: info + type: list + sample: + { + "fvTenant": { + "attributes": { + "descr": "Production environment" + } + } + } +previous: + description: The original configuration from the APIC before the module has started + returned: info + type: list + sample: + [ + { + "fvTenant": { + "attributes": { + "descr": "Production", + "dn": "uni/tn-production", + "name": "production", + "nameAlias": "", + "ownerKey": "", + "ownerTag": "" + } + } + } + ] +proposed: + description: The assembled configuration from the user-provided parameters + returned: info + type: dict + sample: + { + "fvTenant": { + "attributes": { + "descr": "Production environment", + "name": "production" + } + } + } +filter_string: + description: The filter string used for the request + returned: failure or debug + type: str + sample: ?rsp-prop-include=config-only +method: + description: The HTTP method used for the request to the APIC + returned: failure or debug + type: str + sample: POST +response: + description: The HTTP response from the APIC + returned: failure or debug + type: str + sample: OK (30 bytes) +status: + description: The HTTP status from the APIC + returned: failure or debug + type: int + sample: 200 +url: + description: The HTTP url used for the request to the APIC + returned: failure or debug + type: str + sample: https://10.11.12.13/api/mo/uni/tn-production.json +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.cisco.aci.plugins.module_utils.aci import ACIModule, aci_argument_spec, aci_annotation_spec, aci_owner_spec + + +def main(): + argument_spec = aci_argument_spec() + argument_spec.update(aci_annotation_spec()) + argument_spec.update(aci_owner_spec()) + argument_spec.update( + name=dict(type="str", aliases=["policy_group"]), + fex_profile=dict(type="str"), + state=dict(type="str", default="present", choices=["absent", "present", "query"]), + ) + + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + required_if=[ + ["state", "absent", ["name", "fex_profile"]], + ["state", "present", ["name", "fex_profile"]], + ], + ) + + name = module.params.get("name") + fex_profile = module.params.get("fex_profile") + state = module.params.get("state") + + aci = ACIModule(module) + + aci.construct_url( + root_class=dict( + aci_class="infraFexP", + aci_rn="infra/fexprof-{0}".format(fex_profile), + module_object=fex_profile, + target_filter={"name": fex_profile}, + ), + subclass_1=dict( + aci_class="infraFexBndlGrp", + aci_rn="fexbundle-{0}".format(name), + module_object=name, + target_filter={"name": name}, + ), + ) + + aci.get_existing() + + if state == "present": + aci.payload( + aci_class="infraFexBndlGrp", + class_config=dict( + name=name, + ), + ) + + aci.get_diff(aci_class="infraFexBndlGrp") + + aci.post_config() + + elif state == "absent": + aci.delete_config() + + aci.exit_json() + + +if __name__ == "__main__": + main() diff --git a/tests/integration/targets/aci_access_port_to_interface_policy_leaf_profile/tasks/main.yml b/tests/integration/targets/aci_access_port_to_interface_policy_leaf_profile/tasks/main.yml index b13ea6ff0..5ac3eafa9 100644 --- a/tests/integration/targets/aci_access_port_to_interface_policy_leaf_profile/tasks/main.yml +++ b/tests/integration/targets/aci_access_port_to_interface_policy_leaf_profile/tasks/main.yml @@ -65,6 +65,29 @@ type: fex leaf_interface_profile: fexintprftest +- name: Add a new fex policy group to the fexintprftest fex profile + cisco.aci.aci_leaf_interface_profiles_fex_policy_group: &fexintprftest_policy_group_present + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: debug + policy_group: fexintprftest + fex_profile: fexintprftest + state: present + register: fexintprftest_policy_group_present + +- name: Assertions check for remove fex policy group from the fexintprftest fex profile + assert: + that: + - fexintprftest_policy_group_present is changed + - fexintprftest_policy_group_present.current | length == 1 + - fexintprftest_policy_group_present.previous | length == 0 + - fexintprftest_policy_group_present.current.0.infraFexBndlGrp.attributes.name == "fexintprftest" + - fexintprftest_policy_group_present.current.0.infraFexBndlGrp.attributes.dn == "uni/infra/fexprof-fexintprftest/fexbundle-fexintprftest" + # TODO: Ensure that leaf Policy Group Exists (module missing) (infra:AccPortGrp) - name: Bind an Interface Access Port Selector to an Interface Policy Leaf Profile with a Policy Group - check mode works @@ -160,6 +183,51 @@ - binding_query.current | length >= 1 - '"api/mo/uni/infra/accportprof-leafintprftest/hports-anstest_accessportselector-typ-range.json" in binding_query.url' +- name: Bind anstest_fex_accessportselector with fexintprftest - Fex Profile Policy Group + cisco.aci.aci_access_port_to_interface_policy_leaf_profile: + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: debug + state: present + leaf_interface_profile: leafintprftest + fex_profile: fexintprftest + policy_group: fexintprftest + access_port_selector_name: anstest_fex_accessportselector + interface_type: fex_profile + from_port: 13 + to_port: 13 + port_blk: block2 + fex_id: 105 + register: bind_fexintprftest_policy_group + +- name: Assertions check for remove fex policy group from the fexintprftest fex profile + assert: + that: + - bind_fexintprftest_policy_group is changed + - bind_fexintprftest_policy_group.previous | length == 0 + - bind_fexintprftest_policy_group.current.0.infraHPortS.attributes.name == "anstest_fex_accessportselector" + - bind_fexintprftest_policy_group.current.0.infraHPortS.children.1.infraRsAccBaseGrp.attributes.fexId == "105" + - bind_fexintprftest_policy_group.current.0.infraHPortS.children.1.infraRsAccBaseGrp.attributes.tDn == "uni/infra/fexprof-fexintprftest/fexbundle-fexintprftest" + +- name: Remove fex policy group from the fexintprftest fex profile + cisco.aci.aci_leaf_interface_profiles_fex_policy_group: + <<: *fexintprftest_policy_group_present + state: absent + register: fexintprftest_policy_group_absent + +- name: Assertions check for remove fex policy group from the fexintprftest fex profile + assert: + that: + - fexintprftest_policy_group_absent is changed + - fexintprftest_policy_group_absent.current | length == 0 + - fexintprftest_policy_group_absent.previous | length == 1 + - fexintprftest_policy_group_absent.previous.0.infraFexBndlGrp.attributes.name == "fexintprftest" + - fexintprftest_policy_group_absent.previous.0.infraFexBndlGrp.attributes.dn == "uni/infra/fexprof-fexintprftest/fexbundle-fexintprftest" + - name: Remove binding of interface access port selector and Interface Policy Leaf Profile - check mode cisco.aci.aci_access_port_to_interface_policy_leaf_profile: <<: *aci_access_port_to_interface_policy_leaf_profile_absent @@ -202,4 +270,4 @@ <<: *aci_interface_policy_leaf_profile_absent type: fex leaf_interface_profile: fexintprftest - state: absent \ No newline at end of file + state: absent diff --git a/tests/integration/targets/aci_leaf_interface_profiles_fex_policy_group/aliases b/tests/integration/targets/aci_leaf_interface_profiles_fex_policy_group/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/tests/integration/targets/aci_leaf_interface_profiles_fex_policy_group/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/tests/integration/targets/aci_leaf_interface_profiles_fex_policy_group/tasks/main.yml b/tests/integration/targets/aci_leaf_interface_profiles_fex_policy_group/tasks/main.yml new file mode 100644 index 000000000..9fc9099a3 --- /dev/null +++ b/tests/integration/targets/aci_leaf_interface_profiles_fex_policy_group/tasks/main.yml @@ -0,0 +1,283 @@ +# Test code for the ACI modules +# Copyright: (c) 2022, Sabari Jaganathan (@sajagana) + +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +- name: Test that we have an ACI APIC host, ACI username and ACI password + fail: + msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' + when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined + +# SET VARS +- name: Set vars + set_fact: + aci_info: &aci_info + host: '{{ aci_hostname }}' + username: '{{ aci_username }}' + password: '{{ aci_password }}' + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("info") }}' + +- name: Ensure anstest_fex_profile - Interface Policy Fex profile does not exists + cisco.aci.aci_interface_policy_leaf_profile: &fex_profile_absent + <<: *aci_info + type: fex + leaf_interface_profile: anstest_fex_profile + state: absent + +- name: Add anstest_fex_profile - Interface Policy Fex profile + cisco.aci.aci_interface_policy_leaf_profile: &fex_profile_present + <<: *fex_profile_absent + state: present + register: fex_profile_present + +- name: Add Fex Policy Group to anstest_fex_profile - Interface Policy Fex profile with check mode + cisco.aci.aci_leaf_interface_profiles_fex_policy_group: &cm_fex_policy_group_present + <<: *aci_info + name: anstest_fex_policy_group + fex_profile: anstest_fex_profile + state: present + check_mode: yes + register: cm_fex_policy_group_present + +- name: Assertions check for add Fex Policy Group to anstest_fex_profile - Interface Policy Fex profile with check mode + assert: + that: + - cm_fex_policy_group_present is changed + - cm_fex_policy_group_present.current | length == 0 + - cm_fex_policy_group_present.previous | length == 0 + - cm_fex_policy_group_present.sent.infraFexBndlGrp.attributes.name == "anstest_fex_policy_group" + - cm_fex_policy_group_present.sent.infraFexBndlGrp.attributes.dn == "uni/infra/fexprof-anstest_fex_profile/fexbundle-anstest_fex_policy_group" + +- name: Add Fex Policy Group to anstest_fex_profile - Interface Policy Fex profile with normal mode + cisco.aci.aci_leaf_interface_profiles_fex_policy_group: &nm_fex_policy_group_present + <<: *cm_fex_policy_group_present + register: nm_fex_policy_group_present + +- name: Assertions check for add Fex Policy Group to anstest_fex_profile - Interface Policy Fex profile with normal mode + assert: + that: + - nm_fex_policy_group_present is changed + - nm_fex_policy_group_present.current | length == 1 + - nm_fex_policy_group_present.previous | length == 0 + - nm_fex_policy_group_present.current.0.infraFexBndlGrp.attributes.name == "anstest_fex_policy_group" + - nm_fex_policy_group_present.current.0.infraFexBndlGrp.attributes.dn == "uni/infra/fexprof-anstest_fex_profile/fexbundle-anstest_fex_policy_group" + +- name: Add Fex Policy Group to anstest_fex_profile - Interface Policy Fex profile with normal mode - idempotency works + cisco.aci.aci_leaf_interface_profiles_fex_policy_group: &idempotency_fex_policy_group_present + <<: *nm_fex_policy_group_present + register: idempotency_fex_policy_group_present + +- name: Idempotency assertions check for add Fex Policy Group to anstest_fex_profile - Interface Policy Fex profile with normal mode + assert: + that: + - idempotency_fex_policy_group_present is not changed + - idempotency_fex_policy_group_present.current | length == 1 + - idempotency_fex_policy_group_present.previous | length == 1 + - idempotency_fex_policy_group_present.current.0.infraFexBndlGrp.attributes.name == "anstest_fex_policy_group" + - idempotency_fex_policy_group_present.current.0.infraFexBndlGrp.attributes.dn == "uni/infra/fexprof-anstest_fex_profile/fexbundle-anstest_fex_policy_group" + - idempotency_fex_policy_group_present.previous.0.infraFexBndlGrp.attributes.name == "anstest_fex_policy_group" + - idempotency_fex_policy_group_present.previous.0.infraFexBndlGrp.attributes.dn == "uni/infra/fexprof-anstest_fex_profile/fexbundle-anstest_fex_policy_group" + +- name: Add multiple Fex Policy Group to anstest_fex_profile - Interface Policy Fex profile with normal mode + cisco.aci.aci_leaf_interface_profiles_fex_policy_group: + <<: *aci_info + name: "{{ item.name }}" + fex_profile: "{{ item.fex_profile }}" + state: present + with_items: + - name: anstest_fex_policy_group_1 + fex_profile: anstest_fex_profile + - name: anstest_fex_policy_group_2 + fex_profile: anstest_fex_profile + register: multiple_fex_policy_group_present + +- name: Assertions check for add multiple Fex Policy Group to anstest_fex_profile - Interface Policy Fex profile with normal mode + assert: + that: + - multiple_fex_policy_group_present is changed + - multiple_fex_policy_group_present.results.0 is changed + - multiple_fex_policy_group_present.results.1 is changed + - multiple_fex_policy_group_present.results.0.current | length == 1 + - multiple_fex_policy_group_present.results.1.current | length == 1 + - multiple_fex_policy_group_present.results.0.current.0.infraFexBndlGrp.attributes.name == "anstest_fex_policy_group_1" + - multiple_fex_policy_group_present.results.1.current.0.infraFexBndlGrp.attributes.name == "anstest_fex_policy_group_2" + - multiple_fex_policy_group_present.results.0.current.0.infraFexBndlGrp.attributes.dn == "uni/infra/fexprof-anstest_fex_profile/fexbundle-anstest_fex_policy_group_1" + - multiple_fex_policy_group_present.results.1.current.0.infraFexBndlGrp.attributes.dn == "uni/infra/fexprof-anstest_fex_profile/fexbundle-anstest_fex_policy_group_2" + +- name: Ensure temp_anstest_fex_profile - Interface Policy Fex profile does not exists + cisco.aci.aci_interface_policy_leaf_profile: &temp_anstest_fex_profile_absent + <<: *aci_info + type: fex + leaf_interface_profile: temp_anstest_fex_profile + state: absent + register: temp_anstest_fex_profile_absent + +- name: Assertions check for remove temp_anstest_fex_profile - Interface Policy Fex profile + assert: + that: + - temp_anstest_fex_profile_absent.current | length == 0 + +- name: Add temp_anstest_fex_profile - Interface Policy Fex profile + cisco.aci.aci_interface_policy_leaf_profile: &temp_anstest_fex_profile_present + <<: *temp_anstest_fex_profile_absent + state: present + register: temp_anstest_fex_profile_present + +- name: Assertions check for add temp_anstest_fex_profile - Interface Policy Fex profile + assert: + that: + - temp_anstest_fex_profile_present is changed + - temp_anstest_fex_profile_present.current | length == 1 + - temp_anstest_fex_profile_present.previous | length == 0 + +- name: Add Fex Policy Group to temp_anstest_fex_profile - Interface Policy Fex profile + cisco.aci.aci_leaf_interface_profiles_fex_policy_group: + <<: *aci_info + name: anstest_fex_policy_group + fex_profile: temp_anstest_fex_profile + state: present + register: temp_anstest_fex_policy_group_present + +- name: Assertions check for add Fex Policy Group to temp_anstest_fex_profile - Interface Policy Fex profile + assert: + that: + - temp_anstest_fex_policy_group_present is changed + - temp_anstest_fex_policy_group_present.current | length == 1 + - temp_anstest_fex_policy_group_present.previous | length == 0 + - temp_anstest_fex_policy_group_present.current.0.infraFexBndlGrp.attributes.name == "anstest_fex_policy_group" + - temp_anstest_fex_policy_group_present.current.0.infraFexBndlGrp.attributes.dn == "uni/infra/fexprof-temp_anstest_fex_profile/fexbundle-anstest_fex_policy_group" + +- name: Query anstest_fex_policy_group - fex policy group with fex_profile + cisco.aci.aci_leaf_interface_profiles_fex_policy_group: + <<: *aci_info + name: anstest_fex_policy_group + fex_profile: anstest_fex_profile + state: query + register: query_res_fex_policy_group_with_profile + +- name: Assertions check for query anstest_fex_policy_group - fex policy group with fex_profile + assert: + that: + - query_res_fex_policy_group_with_profile is not changed + - query_res_fex_policy_group_with_profile.current | length == 1 + - query_res_fex_policy_group_with_profile.current.0.infraFexBndlGrp.attributes.name == "anstest_fex_policy_group" + - query_res_fex_policy_group_with_profile.current.0.infraFexBndlGrp.attributes.dn == "uni/infra/fexprof-anstest_fex_profile/fexbundle-anstest_fex_policy_group" + +- name: Query all fex policy group under anstest_fex_profile + cisco.aci.aci_leaf_interface_profiles_fex_policy_group: + <<: *aci_info + fex_profile: anstest_fex_profile + state: query + register: query_all_policy_groups_under_fex_profile + +- name: Assertions check for query all fex policy group under anstest_fex_profile + assert: + that: + - query_all_policy_groups_under_fex_profile is not changed + - query_all_policy_groups_under_fex_profile.current.0.infraFexP.children | length == 3 + +- name: Query all anstest_fex_policy_group - fex policy groups + cisco.aci.aci_leaf_interface_profiles_fex_policy_group: + <<: *aci_info + name: anstest_fex_policy_group + state: query + register: query_res_anstest_fex_policy_group + +- name: Assertions check for query all anstest_fex_policy_group - fex policy groups + assert: + that: + - query_res_anstest_fex_policy_group is not changed + - query_res_anstest_fex_policy_group.current | length >= 2 + - query_res_anstest_fex_policy_group.current.0.infraFexBndlGrp.attributes.name == "anstest_fex_policy_group" + - query_res_anstest_fex_policy_group.current.1.infraFexBndlGrp.attributes.name == "anstest_fex_policy_group" + +- name: Query all - fex policy groups + cisco.aci.aci_leaf_interface_profiles_fex_policy_group: + <<: *aci_info + state: query + register: all_fex_policy_groups + +- name: Assertions check for query all - fex policy groups + assert: + that: + - all_fex_policy_groups is not changed + - all_fex_policy_groups.current | length >= 4 + +- name: Remove anstest_fex_policy_group - Fex Policy Group from anstest_fex_profile with check mode + cisco.aci.aci_leaf_interface_profiles_fex_policy_group: &cm_anstest_fex_policy_group_absent + <<: *aci_info + name: anstest_fex_policy_group + fex_profile: anstest_fex_profile + state: absent + check_mode: yes + register: cm_anstest_fex_policy_group_absent + +- name: Assertions check for remove anstest_fex_policy_group - Fex Policy Group from anstest_fex_profile with check mode + assert: + that: + - cm_anstest_fex_policy_group_absent is changed + - cm_anstest_fex_policy_group_absent.current | length == 1 + - cm_anstest_fex_policy_group_absent.previous | length == 1 + - cm_anstest_fex_policy_group_absent.current.0.infraFexBndlGrp.attributes.name == "anstest_fex_policy_group" + - cm_anstest_fex_policy_group_absent.current.0.infraFexBndlGrp.attributes.dn == "uni/infra/fexprof-anstest_fex_profile/fexbundle-anstest_fex_policy_group" + - cm_anstest_fex_policy_group_absent.previous.0.infraFexBndlGrp.attributes.name == "anstest_fex_policy_group" + - cm_anstest_fex_policy_group_absent.previous.0.infraFexBndlGrp.attributes.dn == "uni/infra/fexprof-anstest_fex_profile/fexbundle-anstest_fex_policy_group" + +- name: Remove anstest_fex_policy_group - Fex Policy Group from anstest_fex_profile with normal mode + cisco.aci.aci_leaf_interface_profiles_fex_policy_group: &nm_anstest_fex_policy_group_absent + <<: *cm_anstest_fex_policy_group_absent + register: nm_anstest_fex_policy_group_absent + +- name: Assertions check for remove anstest_fex_policy_group - Fex Policy Group from anstest_fex_profile with normal mode + assert: + that: + - nm_anstest_fex_policy_group_absent is changed + - nm_anstest_fex_policy_group_absent.current | length == 0 + - nm_anstest_fex_policy_group_absent.previous | length == 1 + - nm_anstest_fex_policy_group_absent.previous.0.infraFexBndlGrp.attributes.name == "anstest_fex_policy_group" + - nm_anstest_fex_policy_group_absent.previous.0.infraFexBndlGrp.attributes.dn == "uni/infra/fexprof-anstest_fex_profile/fexbundle-anstest_fex_policy_group" + +- name: Remove anstest_fex_policy_group - Fex Policy Group from anstest_fex_profile with normal mode - idempotency works + cisco.aci.aci_leaf_interface_profiles_fex_policy_group: &idempotency_anstest_fex_policy_group_absent + <<: *nm_anstest_fex_policy_group_absent + register: idempotency_anstest_fex_policy_group_absent + +- name: Idempotency assertions check for remove anstest_fex_policy_group - Fex Policy Group from anstest_fex_profile with normal mode + assert: + that: + - idempotency_anstest_fex_policy_group_absent is not changed + - idempotency_anstest_fex_policy_group_absent.current | length == 0 + - idempotency_anstest_fex_policy_group_absent.previous | length == 0 + +- name: Remove temp_anstest_fex_profile Fex Profile + cisco.aci.aci_interface_policy_leaf_profile: + <<: *temp_anstest_fex_profile_present + state: absent + register: temp_anstest_fex_profile_absent + +- name: Assertions check for remove temp_anstest_fex_profile Fex Profile + assert: + that: + - temp_anstest_fex_profile_absent is changed + - temp_anstest_fex_profile_absent.current | length == 0 + - temp_anstest_fex_profile_absent.previous | length == 1 + - temp_anstest_fex_profile_absent.previous.0.infraFexP.attributes.name == "temp_anstest_fex_profile" + - temp_anstest_fex_profile_absent.previous.0.infraFexP.attributes.dn == "uni/infra/fexprof-temp_anstest_fex_profile" + +- name: Remove anstest_fex_profile Fex Profile + cisco.aci.aci_interface_policy_leaf_profile: + <<: *fex_profile_present + state: absent + register: fex_profile_present_absent + +- name: Assertions check for remove anstest_fex_profile Fex Profile + assert: + that: + - fex_profile_present_absent is changed + - fex_profile_present_absent.current | length == 0 + - fex_profile_present_absent.previous | length == 1 + - fex_profile_present_absent.previous.0.infraFexP.attributes.name == "anstest_fex_profile" + - fex_profile_present_absent.previous.0.infraFexP.attributes.dn == "uni/infra/fexprof-anstest_fex_profile" From 408e6d1269a052dcb034a4ec47f89de5236778ac Mon Sep 17 00:00:00 2001 From: Sabari Jaganathan <93724860+sajagana@users.noreply.github.com> Date: Mon, 21 Feb 2022 12:22:16 +0530 Subject: [PATCH 2/6] Updated task name --- .../tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/targets/aci_access_port_to_interface_policy_leaf_profile/tasks/main.yml b/tests/integration/targets/aci_access_port_to_interface_policy_leaf_profile/tasks/main.yml index 5ac3eafa9..ab3149103 100644 --- a/tests/integration/targets/aci_access_port_to_interface_policy_leaf_profile/tasks/main.yml +++ b/tests/integration/targets/aci_access_port_to_interface_policy_leaf_profile/tasks/main.yml @@ -204,7 +204,7 @@ fex_id: 105 register: bind_fexintprftest_policy_group -- name: Assertions check for remove fex policy group from the fexintprftest fex profile +- name: Assertions check for bind anstest_fex_accessportselector with fexintprftest - Fex Profile Policy Group assert: that: - bind_fexintprftest_policy_group is changed From 0a1034fbcc9c04f38eeabb19445f8e4aa3781088 Mon Sep 17 00:00:00 2001 From: Sabari Jaganathan Date: Mon, 7 Mar 2022 15:36:25 +0530 Subject: [PATCH 3/6] Added set var task to initialize basic parameters. --- .../tasks/main.yml | 51 +++++++------------ 1 file changed, 17 insertions(+), 34 deletions(-) diff --git a/tests/integration/targets/aci_access_port_to_interface_policy_leaf_profile/tasks/main.yml b/tests/integration/targets/aci_access_port_to_interface_policy_leaf_profile/tasks/main.yml index ab3149103..d4eacdfa2 100644 --- a/tests/integration/targets/aci_access_port_to_interface_policy_leaf_profile/tasks/main.yml +++ b/tests/integration/targets/aci_access_port_to_interface_policy_leaf_profile/tasks/main.yml @@ -9,14 +9,21 @@ msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined +# SET VARS +- name: Set vars + set_fact: + aci_info: &aci_info + host: '{{ aci_hostname }}' + username: '{{ aci_username }}' + password: '{{ aci_password }}' + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("info") }}' + - name: Remove Interface policy leaf profile - Cleanup cisco.aci.aci_interface_policy_leaf_profile: &aci_interface_policy_leaf_profile_absent - host: "{{ aci_hostname }}" - username: "{{ aci_username }}" - password: "{{ aci_password }}" - validate_certs: '{{ aci_validate_certs | default(false) }}' - use_ssl: '{{ aci_use_ssl | default(true) }}' - use_proxy: '{{ aci_use_proxy | default(true) }}' + <<: *aci_info leaf_interface_profile: leafintprftest state: absent @@ -29,12 +36,7 @@ - name: Ensuring bindings do not already exist cisco.aci.aci_access_port_to_interface_policy_leaf_profile: &aci_access_port_to_interface_policy_leaf_profile_absent - host: "{{ aci_hostname }}" - username: "{{ aci_username }}" - password: "{{ aci_password }}" - validate_certs: '{{ aci_validate_certs | default(false) }}' - use_ssl: '{{ aci_use_ssl | default(true) }}' - use_proxy: '{{ aci_use_proxy | default(true) }}' + <<: *aci_info leaf_interface_profile: leafintprftest access_port_selector: anstest_accessportselector state: absent @@ -48,13 +50,7 @@ - name: Ensuring Interface Policy Leaf profile exists for kick off cisco.aci.aci_interface_policy_leaf_profile: &aci_interface_policy_leaf_profile_present - host: "{{ aci_hostname }}" - username: "{{ aci_username }}" - password: "{{ aci_password }}" - validate_certs: '{{ aci_validate_certs | default(false) }}' - use_ssl: '{{ aci_use_ssl | default(true) }}' - use_proxy: '{{ aci_use_proxy | default(true) }}' - output_level: debug + <<: *aci_info state: present leaf_interface_profile: leafintprftest register: leaf_profile_present @@ -67,13 +63,7 @@ - name: Add a new fex policy group to the fexintprftest fex profile cisco.aci.aci_leaf_interface_profiles_fex_policy_group: &fexintprftest_policy_group_present - host: "{{ aci_hostname }}" - username: "{{ aci_username }}" - password: "{{ aci_password }}" - validate_certs: '{{ aci_validate_certs | default(false) }}' - use_ssl: '{{ aci_use_ssl | default(true) }}' - use_proxy: '{{ aci_use_proxy | default(true) }}' - output_level: debug + <<: *aci_info policy_group: fexintprftest fex_profile: fexintprftest state: present @@ -181,17 +171,10 @@ - binding_query is not changed - binding_query_fex is not changed - binding_query.current | length >= 1 - - '"api/mo/uni/infra/accportprof-leafintprftest/hports-anstest_accessportselector-typ-range.json" in binding_query.url' - name: Bind anstest_fex_accessportselector with fexintprftest - Fex Profile Policy Group cisco.aci.aci_access_port_to_interface_policy_leaf_profile: - host: "{{ aci_hostname }}" - username: "{{ aci_username }}" - password: "{{ aci_password }}" - validate_certs: '{{ aci_validate_certs | default(false) }}' - use_ssl: '{{ aci_use_ssl | default(true) }}' - use_proxy: '{{ aci_use_proxy | default(true) }}' - output_level: debug + <<: *aci_info state: present leaf_interface_profile: leafintprftest fex_profile: fexintprftest From abe68b0c54ba60ffb182ef12fdb4ce37b43bc599 Mon Sep 17 00:00:00 2001 From: Sabari Jaganathan Date: Wed, 3 Aug 2022 13:49:06 +0530 Subject: [PATCH 4/6] Added new tasks to validate policy group and other logics --- ...s_port_to_interface_policy_leaf_profile.py | 42 +- ...e_policy_leaf_profile_fex_policy_group.py} | 16 +- .../tasks/main.yml | 404 +++++++++++++++++- .../aliases | 0 .../tasks/main.yml | 24 +- 5 files changed, 448 insertions(+), 38 deletions(-) rename plugins/modules/{aci_leaf_interface_profiles_fex_policy_group.py => aci_interface_policy_leaf_profile_fex_policy_group.py} (93%) rename tests/integration/targets/{aci_leaf_interface_profiles_fex_policy_group => aci_interface_policy_leaf_profile_fex_policy_group}/aliases (100%) rename tests/integration/targets/{aci_leaf_interface_profiles_fex_policy_group => aci_interface_policy_leaf_profile_fex_policy_group}/tasks/main.yml (93%) diff --git a/plugins/modules/aci_access_port_to_interface_policy_leaf_profile.py b/plugins/modules/aci_access_port_to_interface_policy_leaf_profile.py index 591999b71..9a41e2124 100644 --- a/plugins/modules/aci_access_port_to_interface_policy_leaf_profile.py +++ b/plugins/modules/aci_access_port_to_interface_policy_leaf_profile.py @@ -93,8 +93,9 @@ interface_type: description: - The type of interface for the static EPG deployment. + - The interface_type fex_profile can not be configured with a profile of type fex. type: str - choices: [ breakout, fex, port_channel, switch_port, vpc , fex_profile] + choices: [ breakout, fex, port_channel, switch_port, vpc, fex_port_channel, fex_vpc , fex_profile] default: switch_port fex_id: description: @@ -102,13 +103,14 @@ type: int fex_profile: description: - - The name of the Fex Profile. + - The name of the Fex Profile. Value of the fex_profile is overridden by the policy_group. type: str aliases: [ fex_profile_name ] type: description: - The type of access port to be created under respective profile. type: str + aliases: [ profile_type ] choices: [ fex, leaf ] default: leaf state: @@ -332,13 +334,17 @@ from ansible.module_utils.basic import AnsibleModule from ansible_collections.cisco.aci.plugins.module_utils.aci import ACIModule, aci_argument_spec, aci_annotation_spec, aci_owner_spec +port_channels_dn = "uni/infra/funcprof/accbundle-{0}" + INTERFACE_TYPE_MAPPING = dict( breakout="uni/infra/funcprof/brkoutportgrp-{0}", fex="uni/infra/funcprof/accportgrp-{0}", fex_profile="uni/infra/fexprof-{0}/fexbundle-{1}", - port_channel="uni/infra/funcprof/accbundle-{0}", + port_channel=port_channels_dn, switch_port="uni/infra/funcprof/accportgrp-{0}", - vpc="uni/infra/funcprof/accbundle-{0}", + vpc=port_channels_dn, + fex_port_channel=port_channels_dn, + fex_vpc=port_channels_dn, ) @@ -357,10 +363,12 @@ def main(): from_card=dict(type="str", aliases=["from_card_range"]), to_card=dict(type="str", aliases=["to_card_range"]), policy_group=dict(type="str", aliases=["policy_group_name"]), - interface_type=dict(type="str", default="switch_port", choices=["breakout", "fex", "port_channel", "switch_port", "vpc", "fex_profile"]), + interface_type=dict( + type="str", default="switch_port", choices=["breakout", "fex", "port_channel", "switch_port", "vpc", "fex_port_channel", "fex_vpc", "fex_profile"] + ), fex_id=dict(type="int"), fex_profile=dict(type="str", aliases=["fex_profile_name"]), - type=dict(type="str", default="leaf", choices=["fex", "leaf"]), + type=dict(type="str", default="leaf", choices=["fex", "leaf"], aliases=["profile_type"]), state=dict(type="str", default="present", choices=["absent", "present", "query"]), ) @@ -407,27 +415,31 @@ def main(): # Add infraRsAccBaseGrp only when policy_group was defined if policy_group is not None: - if fex_profile is None: - infra_rs_Acc_base_grp_t_dn = INTERFACE_TYPE_MAPPING[interface_type].format(policy_group) - else: - infra_rs_Acc_base_grp_t_dn = INTERFACE_TYPE_MAPPING[interface_type].format(fex_profile, policy_group) - - infra_rs_Acc_base_grp = dict( + if interface_type == "fex_profile" and type_profile == "fex": + module.fail_json(msg="Invalid Configuration - interface_type fex_profile can not be configured with a profile of type fex") + elif interface_type == "fex_profile" and fex_profile is not None: + infra_rs_acc_base_grp_t_dn = INTERFACE_TYPE_MAPPING[interface_type].format(fex_profile, policy_group) + elif interface_type == "fex_profile" and fex_profile is None: + infra_rs_acc_base_grp_t_dn = INTERFACE_TYPE_MAPPING[interface_type].format(policy_group, policy_group) + elif interface_type != "fex_profile": + infra_rs_acc_base_grp_t_dn = INTERFACE_TYPE_MAPPING[interface_type].format(policy_group) + + infra_rs_acc_base_grp = dict( infraRsAccBaseGrp=dict( - attributes=dict(tDn=infra_rs_Acc_base_grp_t_dn), + attributes=dict(tDn=infra_rs_acc_base_grp_t_dn), ), ) if interface_type == "fex_profile": if fex_id is not None: if fex_id in range(101, 200): - infra_rs_Acc_base_grp["infraRsAccBaseGrp"]["attributes"]["fexId"] = fex_id + infra_rs_acc_base_grp["infraRsAccBaseGrp"]["attributes"]["fexId"] = fex_id else: module.fail_json(msg="The valid FEX ID is between 101 to 199") else: module.fail_json(msg="The fex_id must not be None, when interface_type is fex_profile") - child_configs.append(infra_rs_Acc_base_grp) + child_configs.append(infra_rs_acc_base_grp) aci = ACIModule(module) aci_class = "infraAccPortP" diff --git a/plugins/modules/aci_leaf_interface_profiles_fex_policy_group.py b/plugins/modules/aci_interface_policy_leaf_profile_fex_policy_group.py similarity index 93% rename from plugins/modules/aci_leaf_interface_profiles_fex_policy_group.py rename to plugins/modules/aci_interface_policy_leaf_profile_fex_policy_group.py index 268fea884..8b0208546 100644 --- a/plugins/modules/aci_leaf_interface_profiles_fex_policy_group.py +++ b/plugins/modules/aci_interface_policy_leaf_profile_fex_policy_group.py @@ -12,7 +12,7 @@ DOCUMENTATION = r""" --- -module: aci_leaf_interface_profiles_fex_policy_group +module: aci_interface_policy_leaf_profile_fex_policy_group short_description: Manage leaf interface profiles fex policy group (infra:FexBndlGrp) description: - Manage leaf interface profiles fex policy group on Cisco ACI fabrics. @@ -48,7 +48,7 @@ EXAMPLES = r""" - name: Add a new fex policy group - cisco.aci.aci_leaf_interface_profiles_fex_policy_group: + cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: host: apic username: admin password: SomeSecretPassword @@ -58,7 +58,7 @@ delegate_to: localhost - name: Add list of fex policy groups - cisco.aci.aci_leaf_interface_profiles_fex_policy_group: + cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: host: apic username: admin password: SomeSecretPassword @@ -73,7 +73,7 @@ fex_profile: anstest_fex_profile - name: Query a fex policy group under fex profile - cisco.aci.aci_leaf_interface_profiles_fex_policy_group: + cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: host: apic username: admin password: SomeSecretPassword @@ -83,7 +83,7 @@ delegate_to: localhost - name: Query all fex policy groups under fex profile - cisco.aci.aci_leaf_interface_profiles_fex_policy_group: + cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: host: apic username: admin password: SomeSecretPassword @@ -92,7 +92,7 @@ delegate_to: localhost - name: Query all fex policy groups with name - cisco.aci.aci_leaf_interface_profiles_fex_policy_group: + cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: host: apic username: admin password: SomeSecretPassword @@ -101,7 +101,7 @@ delegate_to: localhost - name: Query all fex policy groups - cisco.aci.aci_leaf_interface_profiles_fex_policy_group: + cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: host: apic username: admin password: SomeSecretPassword @@ -109,7 +109,7 @@ delegate_to: localhost - name: Remove fex policy group - cisco.aci.aci_leaf_interface_profiles_fex_policy_group: + cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: host: apic username: admin password: SomeSecretPassword diff --git a/tests/integration/targets/aci_access_port_to_interface_policy_leaf_profile/tasks/main.yml b/tests/integration/targets/aci_access_port_to_interface_policy_leaf_profile/tasks/main.yml index d4eacdfa2..5ea94dab0 100644 --- a/tests/integration/targets/aci_access_port_to_interface_policy_leaf_profile/tasks/main.yml +++ b/tests/integration/targets/aci_access_port_to_interface_policy_leaf_profile/tasks/main.yml @@ -56,13 +56,13 @@ register: leaf_profile_present - name: Ensuring Interface Policy Fex profile exists for kick off - cisco.aci.aci_interface_policy_leaf_profile: + cisco.aci.aci_interface_policy_leaf_profile: <<: *aci_interface_policy_leaf_profile_present type: fex leaf_interface_profile: fexintprftest - name: Add a new fex policy group to the fexintprftest fex profile - cisco.aci.aci_leaf_interface_profiles_fex_policy_group: &fexintprftest_policy_group_present + cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: &fexintprftest_policy_group_present <<: *aci_info policy_group: fexintprftest fex_profile: fexintprftest @@ -134,6 +134,7 @@ that: - accessport_to_intf_check_mode_present is changed - accessport_to_intf_present is changed + - accessport_to_intf_present.current.0.infraHPortS.attributes.annotation == 'orchestrator:ansible' - accessport_to_intf_present.previous == [] - accessport_to_intf_present.sent.infraHPortS.attributes.name == 'anstest_accessportselector' - accessport_to_intf_idempotent is not changed @@ -154,6 +155,7 @@ <<: *aci_interface_policy_leaf_profile_present access_port_selector: anstest_accessportselector # "{{ fake_var | default(omit) }}" ? state: query + output_level: debug register: binding_query - name: Query Specific access_port_selector and fex_interface_profile binding @@ -171,6 +173,7 @@ - binding_query is not changed - binding_query_fex is not changed - binding_query.current | length >= 1 + - '"api/mo/uni/infra/accportprof-leafintprftest/hports-anstest_accessportselector-typ-range.json" in binding_query.url' - name: Bind anstest_fex_accessportselector with fexintprftest - Fex Profile Policy Group cisco.aci.aci_access_port_to_interface_policy_leaf_profile: @@ -197,7 +200,7 @@ - bind_fexintprftest_policy_group.current.0.infraHPortS.children.1.infraRsAccBaseGrp.attributes.tDn == "uni/infra/fexprof-fexintprftest/fexbundle-fexintprftest" - name: Remove fex policy group from the fexintprftest fex profile - cisco.aci.aci_leaf_interface_profiles_fex_policy_group: + cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: <<: *fexintprftest_policy_group_present state: absent register: fexintprftest_policy_group_absent @@ -254,3 +257,398 @@ type: fex leaf_interface_profile: fexintprftest state: absent + +- name: Add anstest_fex_port_channel - Interface Policy Leaf Profile with type Fex + cisco.aci.aci_interface_policy_leaf_profile: &anstest_fex_port_channel_present + <<: *aci_interface_policy_leaf_profile_present + type: fex + leaf_interface_profile: anstest_fex_port_channel + +- name: Add policygroupname_link_fpc - Policy Group with lag type link + cisco.aci.aci_interface_policy_leaf_policy_group: + <<: *aci_info + policy_group: policygroupname_link_fpc + lag_type: link + link_level_policy: link_level_policy + fibre_channel_interface_policy: fiber_channel_policy + state: present + +- name: Bind anstest_fex_port_channel Access Port Selector with policygroupname_link_fpc Policy Group - check mode + cisco.aci.aci_access_port_to_interface_policy_leaf_profile: &cm_fpc_present + <<: *anstest_fex_port_channel_present + interface_type: fex_port_channel + access_port_selector: anstest_fex_port_channel + policy_group: policygroupname_link_fpc + check_mode: yes + register: cm_fpc_present + +- name: Assertion check for bind anstest_fex_port_channel Access Port Selector with policygroupname_link_fpc Policy Group - check mode + assert: + that: + - cm_fpc_present.current | length == 0 + - cm_fpc_present.previous | length == 0 + - cm_fpc_present.sent.infraHPortS.attributes.name == "anstest_fex_port_channel" + - cm_fpc_present.sent.infraHPortS.children.0.infraRsAccBaseGrp.attributes.tDn == "uni/infra/funcprof/accbundle-policygroupname_link_fpc" + +- name: Bind anstest_fex_port_channel Access Port Selector with policygroupname_link_fpc Policy Group - normal mode + cisco.aci.aci_access_port_to_interface_policy_leaf_profile: &nm_fpc_present + <<: *cm_fpc_present + register: nm_fpc_present + +- name: Assertion check for bind anstest_fex_port_channel Access Port Selector with policygroupname_link_fpc Policy Group - normal mode + assert: + that: + - nm_fpc_present.current | length == 1 + - nm_fpc_present.previous | length == 0 + - nm_fpc_present.current.0.infraHPortS.attributes.name == "anstest_fex_port_channel" + - nm_fpc_present.current.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.tDn == "uni/infra/funcprof/accbundle-policygroupname_link_fpc" + - nm_fpc_present.current.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.fexId == "101" + +- name: Remove anstest_fex_port_channel Access Port Selector with policygroupname_link_fpc Policy Group - check mode + cisco.aci.aci_access_port_to_interface_policy_leaf_profile: &cm_fpc_absent + <<: *nm_fpc_present + state: absent + check_mode: yes + register: cm_fpc_absent + +- name: Assertion check for remove anstest_fex_port_channel Access Port Selector with policygroupname_link_fpc Policy Group - check mode + assert: + that: + - cm_fpc_absent.current | length == 1 + - cm_fpc_absent.previous | length == 1 + - cm_fpc_absent.current.0.infraHPortS.attributes.name == "anstest_fex_port_channel" + - cm_fpc_absent.previous.0.infraHPortS.attributes.name == "anstest_fex_port_channel" + - cm_fpc_absent.current.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.tDn == "uni/infra/funcprof/accbundle-policygroupname_link_fpc" + - cm_fpc_absent.previous.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.tDn == "uni/infra/funcprof/accbundle-policygroupname_link_fpc" + - cm_fpc_absent.current.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.fexId == "101" + - cm_fpc_absent.previous.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.fexId == "101" + +- name: Remove anstest_fex_port_channel Access Port Selector with policygroupname_link_fpc Policy Group - normal mode + cisco.aci.aci_access_port_to_interface_policy_leaf_profile: + <<: *cm_fpc_absent + register: nm_fpc_absent + +- name: Assertion check for remove anstest_fex_port_channel Access Port Selector with policygroupname_link_fpc Policy Group - normal mode + assert: + that: + - nm_fpc_absent.current | length == 0 + - nm_fpc_absent.previous | length == 1 + - nm_fpc_absent.previous.0.infraHPortS.attributes.name == "anstest_fex_port_channel" + - nm_fpc_absent.previous.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.tDn == "uni/infra/funcprof/accbundle-policygroupname_link_fpc" + - nm_fpc_absent.previous.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.fexId == "101" + +- name: Add anstest_fex_vpc - Interface Policy Leaf Profile with type Fex + cisco.aci.aci_interface_policy_leaf_profile: &anstest_fex_vpc + <<: *aci_interface_policy_leaf_profile_present + type: fex + leaf_interface_profile: anstest_fex_vpc + register: anstest_fex_vpc_present + +- name: Assertion check for add anstest_fex_vpc - Interface Policy Leaf Profile with type Fex + assert: + that: + - anstest_fex_vpc_present.current | length == 1 + - anstest_fex_vpc_present.current.0.infraFexP.attributes.name == "anstest_fex_vpc" + - anstest_fex_vpc_present.current.0.infraFexP.attributes.dn == "uni/infra/fexprof-anstest_fex_vpc" + +- name: Add policygroupname_node_fvpc - Policy Group with lag type node + cisco.aci.aci_interface_policy_leaf_policy_group: + <<: *aci_info + policy_group: policygroupname_node_fvpc + lag_type: node + link_level_policy: link_level_policy + fibre_channel_interface_policy: fiber_channel_policy + state: present + register: policygroupname_node_fvpc_present + +- name: Assertion check for add policygroupname_node_fvpc - Policy Group with lag type node + assert: + that: + - policygroupname_node_fvpc_present.current | length == 1 + - policygroupname_node_fvpc_present.current.0.infraAccBndlGrp.attributes.name == "policygroupname_node_fvpc" + - policygroupname_node_fvpc_present.current.0.infraAccBndlGrp.attributes.lagT == "node" + +- name: Bind anstest_fex_vpc Access Port Selector with policygroupname_node_fvpc Policy Group - check mode + cisco.aci.aci_access_port_to_interface_policy_leaf_profile: &cm_fex_vpc_present + <<: *anstest_fex_vpc + interface_type: fex_vpc + access_port_selector: anstest_fex_vpc + policy_group: policygroupname_node_fvpc + check_mode: yes + register: cm_fex_vpc_present + +- name: Assertion check for bind anstest_fex_vpc Access Port Selector with policygroupname_node_fvpc Policy Group - check mode + assert: + that: + - cm_fex_vpc_present.current | length == 0 + - cm_fex_vpc_present.previous | length == 0 + - cm_fex_vpc_present.sent.infraHPortS.attributes.name == "anstest_fex_vpc" + - cm_fex_vpc_present.sent.infraHPortS.children.0.infraRsAccBaseGrp.attributes.tDn == "uni/infra/funcprof/accbundle-policygroupname_node_fvpc" + +- name: Bind anstest_fex_vpc Access Port Selector with policygroupname_node_fvpc Policy Group - normal mode + cisco.aci.aci_access_port_to_interface_policy_leaf_profile: + <<: *cm_fex_vpc_present + register: nm_fex_vpc_present + +- name: Assertion check for bind anstest_fex_vpc Access Port Selector with policygroupname_node_fvpc Policy Group - normal mode + assert: + that: + - nm_fex_vpc_present.current | length == 1 + - nm_fex_vpc_present.previous | length == 0 + - nm_fex_vpc_present.current.0.infraHPortS.attributes.name == "anstest_fex_vpc" + - nm_fex_vpc_present.current.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.fexId == "101" + - nm_fex_vpc_present.current.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.tDn == "uni/infra/funcprof/accbundle-policygroupname_node_fvpc" + +- name: Remove anstest_fex_vpc Access Port Selector with policygroupname_node_fvpc Policy Group - check mode + cisco.aci.aci_access_port_to_interface_policy_leaf_profile: &cm_fex_vpc_absent + <<: *cm_fex_vpc_present + state: absent + check_mode: yes + register: cm_fex_vpc_absent + +- name: Assertion check for remove anstest_fex_vpc Access Port Selector with policygroupname_node_fvpc Policy Group - check mode + assert: + that: + - cm_fex_vpc_absent.current | length == 1 + - cm_fex_vpc_absent.previous | length == 1 + - cm_fex_vpc_absent.current.0.infraHPortS.attributes.name == "anstest_fex_vpc" + - cm_fex_vpc_absent.previous.0.infraHPortS.attributes.name == "anstest_fex_vpc" + - cm_fex_vpc_absent.current.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.fexId == "101" + - cm_fex_vpc_absent.previous.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.fexId == "101" + - cm_fex_vpc_absent.current.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.tDn == "uni/infra/funcprof/accbundle-policygroupname_node_fvpc" + - cm_fex_vpc_absent.previous.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.tDn == "uni/infra/funcprof/accbundle-policygroupname_node_fvpc" + +- name: Remove anstest_fex_vpc Access Port Selector with policygroupname_node_fvpc Policy Group - normal mode + cisco.aci.aci_access_port_to_interface_policy_leaf_profile: + <<: *cm_fex_vpc_absent + register: nm_fex_vpc_absent + +- name: Assertion check for remove anstest_fex_vpc Access Port Selector with policygroupname_node_fvpc Policy Group - normal mode + assert: + that: + - nm_fex_vpc_absent.current | length == 0 + - nm_fex_vpc_absent.previous | length == 1 + - nm_fex_vpc_absent.previous.0.infraHPortS.attributes.name == "anstest_fex_vpc" + - nm_fex_vpc_absent.previous.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.fexId == "101" + - nm_fex_vpc_absent.previous.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.tDn == "uni/infra/funcprof/accbundle-policygroupname_node_fvpc" + +# Removing profiles +- name: Remove anstest_fex_vpc - Interface Policy Leaf Profile with type Fex + cisco.aci.aci_interface_policy_leaf_profile: + <<: *anstest_fex_vpc + state: absent + register: anstest_fex_vpc_absent + +- name: Assertion check for remove anstest_fex_vpc - Interface Policy Leaf Profile with type Fex + assert: + that: + - anstest_fex_vpc_absent.current | length == 0 + - anstest_fex_vpc_absent.previous | length == 1 + - anstest_fex_vpc_absent.previous.0.infraFexP.attributes.name == "anstest_fex_vpc" + +- name: Remove anstest_fex_port_channel - Interface Policy Leaf Profile with type Fex + cisco.aci.aci_interface_policy_leaf_profile: + <<: *anstest_fex_port_channel_present + state: absent + register: anstest_fex_port_channel_absent + +- name: Assertion check for remove anstest_fex_port_channel - Interface Policy Leaf Profile with type Fex + assert: + that: + - anstest_fex_port_channel_absent.current | length == 0 + - anstest_fex_port_channel_absent.previous | length == 1 + - anstest_fex_port_channel_absent.previous.0.infraFexP.attributes.name == "anstest_fex_port_channel" + +- name: Ensure anstest_leaf_profile interface does not exists + cisco.aci.aci_interface_policy_leaf_profile: &anstest_leaf_profile_absent + <<: *aci_info + type: leaf + leaf_interface_profile: anstest_leaf_profile + state: absent + register: anstest_leaf_profile_absent + +- name: Assertion check for ensure anstest_leaf_profile interface does not exists + assert: + that: + - anstest_leaf_profile_absent.current | length == 0 + +- name: Ensure anstest_fex_profile interface does not exists + cisco.aci.aci_interface_policy_leaf_profile: &anstest_fex_profile_absent + <<: *aci_info + type: fex + leaf_interface_profile: anstest_fex_profile + state: absent + register: anstest_fex_profile_absent + +- name: Assertion check for ensure anstest_fex_profile interface does not exists + assert: + that: + - anstest_fex_profile_absent.current | length == 0 + +- name: Ensure temp_anstest_fex_profile interface does not exists + cisco.aci.aci_interface_policy_leaf_profile: &temp_anstest_fex_profile_absent + <<: *aci_info + type: fex + leaf_interface_profile: temp_anstest_fex_profile + state: absent + register: temp_anstest_fex_profile_absent + +- name: Assertion check for ensure temp_anstest_fex_profile interface does not exists + assert: + that: + - temp_anstest_fex_profile_absent.current | length == 0 + +- name: Add a new anstest_leaf_profile with profile type leaf + cisco.aci.aci_interface_policy_leaf_profile: &anstest_leaf_profile_present + <<: *anstest_leaf_profile_absent + state: present + register: anstest_leaf_profile_present + +- name: Assertion check for add a new anstest_leaf_profile with profile type leaf + assert: + that: + - anstest_leaf_profile_present is changed + - anstest_leaf_profile_present.current | length == 1 + - anstest_leaf_profile_present.previous | length == 0 + - anstest_leaf_profile_present.current.0.infraAccPortP.attributes.name == "anstest_leaf_profile" + - anstest_leaf_profile_present.current.0.infraAccPortP.attributes.dn == "uni/infra/accportprof-anstest_leaf_profile" + +- name: Add a new anstest_fex_profile with profile type fex + cisco.aci.aci_interface_policy_leaf_profile: &anstest_fex_profile_present + <<: *anstest_fex_profile_absent + state: present + register: anstest_fex_profile_present + +- name: Assertion check for add a new anstest_fex_profile with profile type fex + assert: + that: + - anstest_fex_profile_present is changed + - anstest_fex_profile_present.current | length == 1 + - anstest_fex_profile_present.previous | length == 0 + - anstest_fex_profile_present.current.0.infraFexP.attributes.name == "anstest_fex_profile" + - anstest_fex_profile_present.current.0.infraFexP.attributes.dn == "uni/infra/fexprof-anstest_fex_profile" + +- name: Add a new temp_anstest_fex_profile with profile type fex + cisco.aci.aci_interface_policy_leaf_profile: &temp_anstest_fex_profile_present + <<: *temp_anstest_fex_profile_absent + state: present + register: temp_anstest_fex_profile_present + +- name: Assertion check for add a new temp_anstest_fex_profile with profile type fex + assert: + that: + - temp_anstest_fex_profile_present is changed + - temp_anstest_fex_profile_present.current | length == 1 + - temp_anstest_fex_profile_present.previous | length == 0 + - temp_anstest_fex_profile_present.current.0.infraFexP.attributes.name == "temp_anstest_fex_profile" + - temp_anstest_fex_profile_present.current.0.infraFexP.attributes.dn == "uni/infra/fexprof-temp_anstest_fex_profile" + +- name: Add a new policy_group with the same name of interface profile - temp_anstest_fex_profile + cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: &temp_anstest_fex_profile_policy_group_present + <<: *aci_info + policy_group: temp_anstest_fex_profile + fex_profile: temp_anstest_fex_profile + state: present + register: temp_anstest_fex_profile_policy_group_present + +- name: Assertion check for add a new policy_group with the same name of interface profile - temp_anstest_fex_profile + assert: + that: + - temp_anstest_fex_profile_policy_group_present is changed + - temp_anstest_fex_profile_policy_group_present.current | length == 1 + - temp_anstest_fex_profile_policy_group_present.previous | length == 0 + - temp_anstest_fex_profile_policy_group_present.current.0.infraFexBndlGrp.attributes.name == "temp_anstest_fex_profile" + - temp_anstest_fex_profile_policy_group_present.current.0.infraFexBndlGrp.attributes.dn == "uni/infra/fexprof-temp_anstest_fex_profile/fexbundle-temp_anstest_fex_profile" + +- name: Bind temp_anstest_fex_profile with anstest_fex_profile - Fex Profile Policy Group + cisco.aci.aci_access_port_to_interface_policy_leaf_profile: + <<: *aci_info + leaf_interface_profile: anstest_fex_profile + policy_group: temp_anstest_fex_profile + access_port_selector_name: temp_anstest_fex_profile_access_port + interface_type: fex_profile + fex_id: 105 + type: fex + state: present + register: temp_anstest_fex_profile_access_port_present + ignore_errors: yes + +- name: Assertion check for bind temp_anstest_fex_profile with anstest_fex_profile - Fex Profile Policy Group + assert: + that: + - temp_anstest_fex_profile_access_port_present.msg == "Invalid Configuration - interface_type fex_profile can not be configured with a profile of type fex" + +- name: Remove temp_anstest_fex_profile + cisco.aci.aci_interface_policy_leaf_profile: + <<: *temp_anstest_fex_profile_absent + register: remove_anstest_fex_profile_absent + +- name: Assertion check for remove temp_anstest_fex_profile + assert: + that: + - remove_anstest_fex_profile_absent is changed + - remove_anstest_fex_profile_absent.current | length == 0 + - remove_anstest_fex_profile_absent.previous | length == 1 + +- name: Add a new policy_group with the same name of interface profile - anstest_fex_profile + cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: &anstest_fex_profile_policy_group_present + <<: *aci_info + policy_group: anstest_fex_profile + fex_profile: anstest_fex_profile + state: present + register: anstest_fex_profile_policy_group_present + +- name: Assertion check for add a new policy_group with the same name of interface profile - anstest_fex_profile + assert: + that: + - anstest_fex_profile_policy_group_present is changed + - anstest_fex_profile_policy_group_present.current | length == 1 + - anstest_fex_profile_policy_group_present.previous | length == 0 + - anstest_fex_profile_policy_group_present.current.0.infraFexBndlGrp.attributes.name == "anstest_fex_profile" + - anstest_fex_profile_policy_group_present.current.0.infraFexBndlGrp.attributes.dn == "uni/infra/fexprof-anstest_fex_profile/fexbundle-anstest_fex_profile" + +- name: Bind anstest_leaf_profile with anstest_fex_profile - Fex Profile Policy Group + cisco.aci.aci_access_port_to_interface_policy_leaf_profile: &anstest_leaf_profile_access_port_present + <<: *aci_info + leaf_interface_profile: anstest_leaf_profile + policy_group: anstest_fex_profile + access_port_selector_name: anstest_leaf_profile_access_port + interface_type: fex_profile + fex_id: 105 + type: leaf + state: present + register: anstest_leaf_profile_access_port_present + +- name: Assertion check for bind anstest_leaf_profile with anstest_fex_profile - Fex Profile Policy Group + assert: + that: + - anstest_leaf_profile_access_port_present is changed + - anstest_leaf_profile_access_port_present.current | length == 1 + - anstest_leaf_profile_access_port_present.previous | length == 0 + - anstest_leaf_profile_access_port_present.current.0.infraHPortS.attributes.name == "anstest_leaf_profile_access_port" + - anstest_leaf_profile_access_port_present.current.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.tDn == "uni/infra/fexprof-anstest_fex_profile/fexbundle-anstest_fex_profile" + - anstest_leaf_profile_access_port_present.current.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.fexId == "105" + +- name: Remove anstest_leaf_profile + cisco.aci.aci_interface_policy_leaf_profile: + <<: *anstest_leaf_profile_absent + register: anstest_leaf_profile_cleanup + +- name: Assertion check for remove anstest_leaf_profile + assert: + that: + - anstest_leaf_profile_cleanup is changed + - anstest_leaf_profile_cleanup.previous | length == 1 + - anstest_leaf_profile_cleanup.current | length == 0 + +- name: Remove anstest_fex_profile + cisco.aci.aci_interface_policy_leaf_profile: + <<: *anstest_fex_profile_absent + register: anstest_fex_profile_cleanup + +- name: Assertion check for remove anstest_fex_profile + assert: + that: + - anstest_fex_profile_cleanup is changed + - anstest_fex_profile_cleanup.previous | length == 1 + - anstest_fex_profile_cleanup.current | length == 0 diff --git a/tests/integration/targets/aci_leaf_interface_profiles_fex_policy_group/aliases b/tests/integration/targets/aci_interface_policy_leaf_profile_fex_policy_group/aliases similarity index 100% rename from tests/integration/targets/aci_leaf_interface_profiles_fex_policy_group/aliases rename to tests/integration/targets/aci_interface_policy_leaf_profile_fex_policy_group/aliases diff --git a/tests/integration/targets/aci_leaf_interface_profiles_fex_policy_group/tasks/main.yml b/tests/integration/targets/aci_interface_policy_leaf_profile_fex_policy_group/tasks/main.yml similarity index 93% rename from tests/integration/targets/aci_leaf_interface_profiles_fex_policy_group/tasks/main.yml rename to tests/integration/targets/aci_interface_policy_leaf_profile_fex_policy_group/tasks/main.yml index 9fc9099a3..56da9f6e2 100644 --- a/tests/integration/targets/aci_leaf_interface_profiles_fex_policy_group/tasks/main.yml +++ b/tests/integration/targets/aci_interface_policy_leaf_profile_fex_policy_group/tasks/main.yml @@ -34,7 +34,7 @@ register: fex_profile_present - name: Add Fex Policy Group to anstest_fex_profile - Interface Policy Fex profile with check mode - cisco.aci.aci_leaf_interface_profiles_fex_policy_group: &cm_fex_policy_group_present + cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: &cm_fex_policy_group_present <<: *aci_info name: anstest_fex_policy_group fex_profile: anstest_fex_profile @@ -52,7 +52,7 @@ - cm_fex_policy_group_present.sent.infraFexBndlGrp.attributes.dn == "uni/infra/fexprof-anstest_fex_profile/fexbundle-anstest_fex_policy_group" - name: Add Fex Policy Group to anstest_fex_profile - Interface Policy Fex profile with normal mode - cisco.aci.aci_leaf_interface_profiles_fex_policy_group: &nm_fex_policy_group_present + cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: &nm_fex_policy_group_present <<: *cm_fex_policy_group_present register: nm_fex_policy_group_present @@ -66,7 +66,7 @@ - nm_fex_policy_group_present.current.0.infraFexBndlGrp.attributes.dn == "uni/infra/fexprof-anstest_fex_profile/fexbundle-anstest_fex_policy_group" - name: Add Fex Policy Group to anstest_fex_profile - Interface Policy Fex profile with normal mode - idempotency works - cisco.aci.aci_leaf_interface_profiles_fex_policy_group: &idempotency_fex_policy_group_present + cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: &idempotency_fex_policy_group_present <<: *nm_fex_policy_group_present register: idempotency_fex_policy_group_present @@ -82,7 +82,7 @@ - idempotency_fex_policy_group_present.previous.0.infraFexBndlGrp.attributes.dn == "uni/infra/fexprof-anstest_fex_profile/fexbundle-anstest_fex_policy_group" - name: Add multiple Fex Policy Group to anstest_fex_profile - Interface Policy Fex profile with normal mode - cisco.aci.aci_leaf_interface_profiles_fex_policy_group: + cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: <<: *aci_info name: "{{ item.name }}" fex_profile: "{{ item.fex_profile }}" @@ -134,7 +134,7 @@ - temp_anstest_fex_profile_present.previous | length == 0 - name: Add Fex Policy Group to temp_anstest_fex_profile - Interface Policy Fex profile - cisco.aci.aci_leaf_interface_profiles_fex_policy_group: + cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: <<: *aci_info name: anstest_fex_policy_group fex_profile: temp_anstest_fex_profile @@ -151,7 +151,7 @@ - temp_anstest_fex_policy_group_present.current.0.infraFexBndlGrp.attributes.dn == "uni/infra/fexprof-temp_anstest_fex_profile/fexbundle-anstest_fex_policy_group" - name: Query anstest_fex_policy_group - fex policy group with fex_profile - cisco.aci.aci_leaf_interface_profiles_fex_policy_group: + cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: <<: *aci_info name: anstest_fex_policy_group fex_profile: anstest_fex_profile @@ -167,7 +167,7 @@ - query_res_fex_policy_group_with_profile.current.0.infraFexBndlGrp.attributes.dn == "uni/infra/fexprof-anstest_fex_profile/fexbundle-anstest_fex_policy_group" - name: Query all fex policy group under anstest_fex_profile - cisco.aci.aci_leaf_interface_profiles_fex_policy_group: + cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: <<: *aci_info fex_profile: anstest_fex_profile state: query @@ -180,7 +180,7 @@ - query_all_policy_groups_under_fex_profile.current.0.infraFexP.children | length == 3 - name: Query all anstest_fex_policy_group - fex policy groups - cisco.aci.aci_leaf_interface_profiles_fex_policy_group: + cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: <<: *aci_info name: anstest_fex_policy_group state: query @@ -195,7 +195,7 @@ - query_res_anstest_fex_policy_group.current.1.infraFexBndlGrp.attributes.name == "anstest_fex_policy_group" - name: Query all - fex policy groups - cisco.aci.aci_leaf_interface_profiles_fex_policy_group: + cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: <<: *aci_info state: query register: all_fex_policy_groups @@ -207,7 +207,7 @@ - all_fex_policy_groups.current | length >= 4 - name: Remove anstest_fex_policy_group - Fex Policy Group from anstest_fex_profile with check mode - cisco.aci.aci_leaf_interface_profiles_fex_policy_group: &cm_anstest_fex_policy_group_absent + cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: &cm_anstest_fex_policy_group_absent <<: *aci_info name: anstest_fex_policy_group fex_profile: anstest_fex_profile @@ -227,7 +227,7 @@ - cm_anstest_fex_policy_group_absent.previous.0.infraFexBndlGrp.attributes.dn == "uni/infra/fexprof-anstest_fex_profile/fexbundle-anstest_fex_policy_group" - name: Remove anstest_fex_policy_group - Fex Policy Group from anstest_fex_profile with normal mode - cisco.aci.aci_leaf_interface_profiles_fex_policy_group: &nm_anstest_fex_policy_group_absent + cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: &nm_anstest_fex_policy_group_absent <<: *cm_anstest_fex_policy_group_absent register: nm_anstest_fex_policy_group_absent @@ -241,7 +241,7 @@ - nm_anstest_fex_policy_group_absent.previous.0.infraFexBndlGrp.attributes.dn == "uni/infra/fexprof-anstest_fex_profile/fexbundle-anstest_fex_policy_group" - name: Remove anstest_fex_policy_group - Fex Policy Group from anstest_fex_profile with normal mode - idempotency works - cisco.aci.aci_leaf_interface_profiles_fex_policy_group: &idempotency_anstest_fex_policy_group_absent + cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: &idempotency_anstest_fex_policy_group_absent <<: *nm_anstest_fex_policy_group_absent register: idempotency_anstest_fex_policy_group_absent From 8eed6ca4d45c7683097cdb1639c72267ee9ce1a9 Mon Sep 17 00:00:00 2001 From: Sabari Jaganathan <93724860+sajagana@users.noreply.github.com> Date: Tue, 11 Oct 2022 20:02:27 +0530 Subject: [PATCH 5/6] Rearranged infra_rs_acc_base_grp_t_dn calculation conditions --- ...s_port_to_interface_policy_leaf_profile.py | 20 +- .../tasks/main.yml | 275 +++++++++--------- .../tasks/main.yml | 32 +- 3 files changed, 172 insertions(+), 155 deletions(-) diff --git a/plugins/modules/aci_access_port_to_interface_policy_leaf_profile.py b/plugins/modules/aci_access_port_to_interface_policy_leaf_profile.py index 9a41e2124..ed26e98dc 100644 --- a/plugins/modules/aci_access_port_to_interface_policy_leaf_profile.py +++ b/plugins/modules/aci_access_port_to_interface_policy_leaf_profile.py @@ -415,22 +415,21 @@ def main(): # Add infraRsAccBaseGrp only when policy_group was defined if policy_group is not None: - if interface_type == "fex_profile" and type_profile == "fex": - module.fail_json(msg="Invalid Configuration - interface_type fex_profile can not be configured with a profile of type fex") - elif interface_type == "fex_profile" and fex_profile is not None: - infra_rs_acc_base_grp_t_dn = INTERFACE_TYPE_MAPPING[interface_type].format(fex_profile, policy_group) - elif interface_type == "fex_profile" and fex_profile is None: - infra_rs_acc_base_grp_t_dn = INTERFACE_TYPE_MAPPING[interface_type].format(policy_group, policy_group) - elif interface_type != "fex_profile": - infra_rs_acc_base_grp_t_dn = INTERFACE_TYPE_MAPPING[interface_type].format(policy_group) infra_rs_acc_base_grp = dict( infraRsAccBaseGrp=dict( - attributes=dict(tDn=infra_rs_acc_base_grp_t_dn), + attributes=dict(), ), ) if interface_type == "fex_profile": + if type_profile == "fex": + module.fail_json(msg="Invalid Configuration - interface_type fex_profile can not be configured with a profile of type fex") + elif fex_profile is not None: + infra_rs_acc_base_grp["infraRsAccBaseGrp"]["attributes"]["tDn"] = INTERFACE_TYPE_MAPPING[interface_type].format(fex_profile, policy_group) + elif fex_profile is None: + infra_rs_acc_base_grp["infraRsAccBaseGrp"]["attributes"]["tDn"] = INTERFACE_TYPE_MAPPING[interface_type].format(policy_group, policy_group) + if fex_id is not None: if fex_id in range(101, 200): infra_rs_acc_base_grp["infraRsAccBaseGrp"]["attributes"]["fexId"] = fex_id @@ -439,6 +438,9 @@ def main(): else: module.fail_json(msg="The fex_id must not be None, when interface_type is fex_profile") + elif interface_type != "fex_profile": + infra_rs_acc_base_grp["infraRsAccBaseGrp"]["attributes"]["tDn"] = INTERFACE_TYPE_MAPPING[interface_type].format(policy_group) + child_configs.append(infra_rs_acc_base_grp) aci = ACIModule(module) diff --git a/tests/integration/targets/aci_access_port_to_interface_policy_leaf_profile/tasks/main.yml b/tests/integration/targets/aci_access_port_to_interface_policy_leaf_profile/tasks/main.yml index 82157e2c8..da4f699c8 100644 --- a/tests/integration/targets/aci_access_port_to_interface_policy_leaf_profile/tasks/main.yml +++ b/tests/integration/targets/aci_access_port_to_interface_policy_leaf_profile/tasks/main.yml @@ -6,23 +6,24 @@ - name: Test that we have an ACI APIC host, ACI username and ACI password fail: - msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' + msg: "Please define the following variables: aci_hostname, aci_username and aci_password." when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined # SET VARS - name: Set vars set_fact: aci_info: &aci_info - host: '{{ aci_hostname }}' - username: '{{ aci_username }}' - password: '{{ aci_password }}' - validate_certs: '{{ aci_validate_certs | default(false) }}' - use_ssl: '{{ aci_use_ssl | default(true) }}' - use_proxy: '{{ aci_use_proxy | default(true) }}' + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: "{{ aci_validate_certs | default(false) }}" + use_ssl: "{{ aci_use_ssl | default(true) }}" + use_proxy: "{{ aci_use_proxy | default(true) }}" output_level: '{{ aci_output_level | default("info") }}' - name: Remove Interface policy leaf profile - Cleanup - cisco.aci.aci_interface_policy_leaf_profile: &aci_interface_policy_leaf_profile_absent + cisco.aci.aci_interface_policy_leaf_profile: + &aci_interface_policy_leaf_profile_absent <<: *aci_info leaf_interface_profile: leafintprftest state: absent @@ -35,7 +36,8 @@ state: absent - name: Ensuring bindings do not already exist - cisco.aci.aci_access_port_to_interface_policy_leaf_profile: &aci_access_port_to_interface_policy_leaf_profile_absent + cisco.aci.aci_access_port_to_interface_policy_leaf_profile: + &aci_access_port_to_interface_policy_leaf_profile_absent <<: *aci_info leaf_interface_profile: leafintprftest access_port_selector: anstest_accessportselector @@ -49,7 +51,8 @@ state: absent - name: Ensuring Interface Policy Leaf profile exists for kick off - cisco.aci.aci_interface_policy_leaf_profile: &aci_interface_policy_leaf_profile_present + cisco.aci.aci_interface_policy_leaf_profile: + &aci_interface_policy_leaf_profile_present <<: *aci_info state: present leaf_interface_profile: leafintprftest @@ -62,7 +65,8 @@ leaf_interface_profile: fexintprftest - name: Add a new fex policy group to the fexintprftest fex profile - cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: &fexintprftest_policy_group_present + cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: + &fexintprftest_policy_group_present <<: *aci_info policy_group: fexintprftest fex_profile: fexintprftest @@ -81,7 +85,8 @@ # TODO: Ensure that leaf Policy Group Exists (module missing) (infra:AccPortGrp) - name: Bind an Interface Access Port Selector to an Interface Policy Leaf Profile with a Policy Group - check mode works - cisco.aci.aci_access_port_to_interface_policy_leaf_profile: &aci_access_port_to_interface_policy_leaf_profile_present + cisco.aci.aci_access_port_to_interface_policy_leaf_profile: + &aci_access_port_to_interface_policy_leaf_profile_present <<: *aci_interface_policy_leaf_profile_present access_port_selector: anstest_accessportselector check_mode: yes @@ -132,23 +137,23 @@ - name: present assertions assert: that: - - accessport_to_intf_check_mode_present is changed - - accessport_to_intf_present is changed - - accessport_to_intf_present.current.0.infraHPortS.attributes.annotation == 'orchestrator:ansible' - - accessport_to_intf_present.previous == [] - - accessport_to_intf_present.sent.infraHPortS.attributes.name == 'anstest_accessportselector' - - accessport_to_intf_idempotent is not changed - - accessport_to_intf_idempotent.sent == {} - - accessport_to_intf_update is changed - - accessport_to_intf_update.sent.infraHPortS.attributes == {} - - accessport_to_intf_update.sent.infraHPortS.children[0].infraRsAccBaseGrp.attributes.tDn == 'uni/infra/funcprof/accportgrp-anstest_policygroupname' - - accessport_to_intf_present_fex is changed - - accessport_to_intf_present_fex.previous == [] - - accessport_to_intf_present_fex.sent.infraHPortS.attributes.name == 'anstest_fex_accessportselector' - - accessport_to_intf_idempotent_fex is not changed - - accessport_to_intf_idempotent_fex.sent == {} - - accessport_to_intf_update_fex is changed - - accessport_to_intf_update_fex.sent.infraHPortS.children[0].infraRsAccBaseGrp.attributes.tDn == 'uni/infra/funcprof/accportgrp-anstest_fex_policygroupname' + - accessport_to_intf_check_mode_present is changed + - accessport_to_intf_present is changed + - accessport_to_intf_present.current.0.infraHPortS.attributes.annotation == 'orchestrator:ansible' + - accessport_to_intf_present.previous == [] + - accessport_to_intf_present.sent.infraHPortS.attributes.name == 'anstest_accessportselector' + - accessport_to_intf_idempotent is not changed + - accessport_to_intf_idempotent.sent == {} + - accessport_to_intf_update is changed + - accessport_to_intf_update.sent.infraHPortS.attributes == {} + - accessport_to_intf_update.sent.infraHPortS.children[0].infraRsAccBaseGrp.attributes.tDn == 'uni/infra/funcprof/accportgrp-anstest_policygroupname' + - accessport_to_intf_present_fex is changed + - accessport_to_intf_present_fex.previous == [] + - accessport_to_intf_present_fex.sent.infraHPortS.attributes.name == 'anstest_fex_accessportselector' + - accessport_to_intf_idempotent_fex is not changed + - accessport_to_intf_idempotent_fex.sent == {} + - accessport_to_intf_update_fex is changed + - accessport_to_intf_update_fex.sent.infraHPortS.children[0].infraRsAccBaseGrp.attributes.tDn == 'uni/infra/funcprof/accportgrp-anstest_fex_policygroupname' - name: Query Specific access_port_selector and leaf_interface_profile binding cisco.aci.aci_access_port_to_interface_policy_leaf_profile: @@ -286,10 +291,10 @@ - name: Assertion check for bind anstest_fex_port_channel Access Port Selector with policygroupname_link_fpc Policy Group - check mode assert: that: - - cm_fpc_present.current | length == 0 - - cm_fpc_present.previous | length == 0 - - cm_fpc_present.sent.infraHPortS.attributes.name == "anstest_fex_port_channel" - - cm_fpc_present.sent.infraHPortS.children.0.infraRsAccBaseGrp.attributes.tDn == "uni/infra/funcprof/accbundle-policygroupname_link_fpc" + - cm_fpc_present.current | length == 0 + - cm_fpc_present.previous | length == 0 + - cm_fpc_present.sent.infraHPortS.attributes.name == "anstest_fex_port_channel" + - cm_fpc_present.sent.infraHPortS.children.0.infraRsAccBaseGrp.attributes.tDn == "uni/infra/funcprof/accbundle-policygroupname_link_fpc" - name: Bind anstest_fex_port_channel Access Port Selector with policygroupname_link_fpc Policy Group - normal mode cisco.aci.aci_access_port_to_interface_policy_leaf_profile: &nm_fpc_present @@ -299,11 +304,11 @@ - name: Assertion check for bind anstest_fex_port_channel Access Port Selector with policygroupname_link_fpc Policy Group - normal mode assert: that: - - nm_fpc_present.current | length == 1 - - nm_fpc_present.previous | length == 0 - - nm_fpc_present.current.0.infraHPortS.attributes.name == "anstest_fex_port_channel" - - nm_fpc_present.current.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.tDn == "uni/infra/funcprof/accbundle-policygroupname_link_fpc" - - nm_fpc_present.current.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.fexId == "101" + - nm_fpc_present.current | length == 1 + - nm_fpc_present.previous | length == 0 + - nm_fpc_present.current.0.infraHPortS.attributes.name == "anstest_fex_port_channel" + - nm_fpc_present.current.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.tDn == "uni/infra/funcprof/accbundle-policygroupname_link_fpc" + - nm_fpc_present.current.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.fexId == "101" - name: Remove anstest_fex_port_channel Access Port Selector with policygroupname_link_fpc Policy Group - check mode cisco.aci.aci_access_port_to_interface_policy_leaf_profile: &cm_fpc_absent @@ -315,14 +320,14 @@ - name: Assertion check for remove anstest_fex_port_channel Access Port Selector with policygroupname_link_fpc Policy Group - check mode assert: that: - - cm_fpc_absent.current | length == 1 - - cm_fpc_absent.previous | length == 1 - - cm_fpc_absent.current.0.infraHPortS.attributes.name == "anstest_fex_port_channel" - - cm_fpc_absent.previous.0.infraHPortS.attributes.name == "anstest_fex_port_channel" - - cm_fpc_absent.current.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.tDn == "uni/infra/funcprof/accbundle-policygroupname_link_fpc" - - cm_fpc_absent.previous.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.tDn == "uni/infra/funcprof/accbundle-policygroupname_link_fpc" - - cm_fpc_absent.current.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.fexId == "101" - - cm_fpc_absent.previous.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.fexId == "101" + - cm_fpc_absent.current | length == 1 + - cm_fpc_absent.previous | length == 1 + - cm_fpc_absent.current.0.infraHPortS.attributes.name == "anstest_fex_port_channel" + - cm_fpc_absent.previous.0.infraHPortS.attributes.name == "anstest_fex_port_channel" + - cm_fpc_absent.current.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.tDn == "uni/infra/funcprof/accbundle-policygroupname_link_fpc" + - cm_fpc_absent.previous.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.tDn == "uni/infra/funcprof/accbundle-policygroupname_link_fpc" + - cm_fpc_absent.current.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.fexId == "101" + - cm_fpc_absent.previous.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.fexId == "101" - name: Remove anstest_fex_port_channel Access Port Selector with policygroupname_link_fpc Policy Group - normal mode cisco.aci.aci_access_port_to_interface_policy_leaf_profile: @@ -332,11 +337,11 @@ - name: Assertion check for remove anstest_fex_port_channel Access Port Selector with policygroupname_link_fpc Policy Group - normal mode assert: that: - - nm_fpc_absent.current | length == 0 - - nm_fpc_absent.previous | length == 1 - - nm_fpc_absent.previous.0.infraHPortS.attributes.name == "anstest_fex_port_channel" - - nm_fpc_absent.previous.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.tDn == "uni/infra/funcprof/accbundle-policygroupname_link_fpc" - - nm_fpc_absent.previous.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.fexId == "101" + - nm_fpc_absent.current | length == 0 + - nm_fpc_absent.previous | length == 1 + - nm_fpc_absent.previous.0.infraHPortS.attributes.name == "anstest_fex_port_channel" + - nm_fpc_absent.previous.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.tDn == "uni/infra/funcprof/accbundle-policygroupname_link_fpc" + - nm_fpc_absent.previous.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.fexId == "101" - name: Add anstest_fex_vpc - Interface Policy Leaf Profile with type Fex cisco.aci.aci_interface_policy_leaf_profile: &anstest_fex_vpc @@ -348,9 +353,9 @@ - name: Assertion check for add anstest_fex_vpc - Interface Policy Leaf Profile with type Fex assert: that: - - anstest_fex_vpc_present.current | length == 1 - - anstest_fex_vpc_present.current.0.infraFexP.attributes.name == "anstest_fex_vpc" - - anstest_fex_vpc_present.current.0.infraFexP.attributes.dn == "uni/infra/fexprof-anstest_fex_vpc" + - anstest_fex_vpc_present.current | length == 1 + - anstest_fex_vpc_present.current.0.infraFexP.attributes.name == "anstest_fex_vpc" + - anstest_fex_vpc_present.current.0.infraFexP.attributes.dn == "uni/infra/fexprof-anstest_fex_vpc" - name: Add policygroupname_node_fvpc - Policy Group with lag type node cisco.aci.aci_interface_policy_leaf_policy_group: @@ -365,12 +370,13 @@ - name: Assertion check for add policygroupname_node_fvpc - Policy Group with lag type node assert: that: - - policygroupname_node_fvpc_present.current | length == 1 - - policygroupname_node_fvpc_present.current.0.infraAccBndlGrp.attributes.name == "policygroupname_node_fvpc" - - policygroupname_node_fvpc_present.current.0.infraAccBndlGrp.attributes.lagT == "node" + - policygroupname_node_fvpc_present.current | length == 1 + - policygroupname_node_fvpc_present.current.0.infraAccBndlGrp.attributes.name == "policygroupname_node_fvpc" + - policygroupname_node_fvpc_present.current.0.infraAccBndlGrp.attributes.lagT == "node" - name: Bind anstest_fex_vpc Access Port Selector with policygroupname_node_fvpc Policy Group - check mode - cisco.aci.aci_access_port_to_interface_policy_leaf_profile: &cm_fex_vpc_present + cisco.aci.aci_access_port_to_interface_policy_leaf_profile: + &cm_fex_vpc_present <<: *anstest_fex_vpc interface_type: fex_vpc access_port_selector: anstest_fex_vpc @@ -381,10 +387,10 @@ - name: Assertion check for bind anstest_fex_vpc Access Port Selector with policygroupname_node_fvpc Policy Group - check mode assert: that: - - cm_fex_vpc_present.current | length == 0 - - cm_fex_vpc_present.previous | length == 0 - - cm_fex_vpc_present.sent.infraHPortS.attributes.name == "anstest_fex_vpc" - - cm_fex_vpc_present.sent.infraHPortS.children.0.infraRsAccBaseGrp.attributes.tDn == "uni/infra/funcprof/accbundle-policygroupname_node_fvpc" + - cm_fex_vpc_present.current | length == 0 + - cm_fex_vpc_present.previous | length == 0 + - cm_fex_vpc_present.sent.infraHPortS.attributes.name == "anstest_fex_vpc" + - cm_fex_vpc_present.sent.infraHPortS.children.0.infraRsAccBaseGrp.attributes.tDn == "uni/infra/funcprof/accbundle-policygroupname_node_fvpc" - name: Bind anstest_fex_vpc Access Port Selector with policygroupname_node_fvpc Policy Group - normal mode cisco.aci.aci_access_port_to_interface_policy_leaf_profile: @@ -394,11 +400,11 @@ - name: Assertion check for bind anstest_fex_vpc Access Port Selector with policygroupname_node_fvpc Policy Group - normal mode assert: that: - - nm_fex_vpc_present.current | length == 1 - - nm_fex_vpc_present.previous | length == 0 - - nm_fex_vpc_present.current.0.infraHPortS.attributes.name == "anstest_fex_vpc" - - nm_fex_vpc_present.current.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.fexId == "101" - - nm_fex_vpc_present.current.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.tDn == "uni/infra/funcprof/accbundle-policygroupname_node_fvpc" + - nm_fex_vpc_present.current | length == 1 + - nm_fex_vpc_present.previous | length == 0 + - nm_fex_vpc_present.current.0.infraHPortS.attributes.name == "anstest_fex_vpc" + - nm_fex_vpc_present.current.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.fexId == "101" + - nm_fex_vpc_present.current.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.tDn == "uni/infra/funcprof/accbundle-policygroupname_node_fvpc" - name: Remove anstest_fex_vpc Access Port Selector with policygroupname_node_fvpc Policy Group - check mode cisco.aci.aci_access_port_to_interface_policy_leaf_profile: &cm_fex_vpc_absent @@ -410,14 +416,14 @@ - name: Assertion check for remove anstest_fex_vpc Access Port Selector with policygroupname_node_fvpc Policy Group - check mode assert: that: - - cm_fex_vpc_absent.current | length == 1 - - cm_fex_vpc_absent.previous | length == 1 - - cm_fex_vpc_absent.current.0.infraHPortS.attributes.name == "anstest_fex_vpc" - - cm_fex_vpc_absent.previous.0.infraHPortS.attributes.name == "anstest_fex_vpc" - - cm_fex_vpc_absent.current.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.fexId == "101" - - cm_fex_vpc_absent.previous.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.fexId == "101" - - cm_fex_vpc_absent.current.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.tDn == "uni/infra/funcprof/accbundle-policygroupname_node_fvpc" - - cm_fex_vpc_absent.previous.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.tDn == "uni/infra/funcprof/accbundle-policygroupname_node_fvpc" + - cm_fex_vpc_absent.current | length == 1 + - cm_fex_vpc_absent.previous | length == 1 + - cm_fex_vpc_absent.current.0.infraHPortS.attributes.name == "anstest_fex_vpc" + - cm_fex_vpc_absent.previous.0.infraHPortS.attributes.name == "anstest_fex_vpc" + - cm_fex_vpc_absent.current.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.fexId == "101" + - cm_fex_vpc_absent.previous.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.fexId == "101" + - cm_fex_vpc_absent.current.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.tDn == "uni/infra/funcprof/accbundle-policygroupname_node_fvpc" + - cm_fex_vpc_absent.previous.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.tDn == "uni/infra/funcprof/accbundle-policygroupname_node_fvpc" - name: Remove anstest_fex_vpc Access Port Selector with policygroupname_node_fvpc Policy Group - normal mode cisco.aci.aci_access_port_to_interface_policy_leaf_profile: @@ -427,11 +433,11 @@ - name: Assertion check for remove anstest_fex_vpc Access Port Selector with policygroupname_node_fvpc Policy Group - normal mode assert: that: - - nm_fex_vpc_absent.current | length == 0 - - nm_fex_vpc_absent.previous | length == 1 - - nm_fex_vpc_absent.previous.0.infraHPortS.attributes.name == "anstest_fex_vpc" - - nm_fex_vpc_absent.previous.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.fexId == "101" - - nm_fex_vpc_absent.previous.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.tDn == "uni/infra/funcprof/accbundle-policygroupname_node_fvpc" + - nm_fex_vpc_absent.current | length == 0 + - nm_fex_vpc_absent.previous | length == 1 + - nm_fex_vpc_absent.previous.0.infraHPortS.attributes.name == "anstest_fex_vpc" + - nm_fex_vpc_absent.previous.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.fexId == "101" + - nm_fex_vpc_absent.previous.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.tDn == "uni/infra/funcprof/accbundle-policygroupname_node_fvpc" # Removing profiles - name: Remove anstest_fex_vpc - Interface Policy Leaf Profile with type Fex @@ -443,9 +449,9 @@ - name: Assertion check for remove anstest_fex_vpc - Interface Policy Leaf Profile with type Fex assert: that: - - anstest_fex_vpc_absent.current | length == 0 - - anstest_fex_vpc_absent.previous | length == 1 - - anstest_fex_vpc_absent.previous.0.infraFexP.attributes.name == "anstest_fex_vpc" + - anstest_fex_vpc_absent.current | length == 0 + - anstest_fex_vpc_absent.previous | length == 1 + - anstest_fex_vpc_absent.previous.0.infraFexP.attributes.name == "anstest_fex_vpc" - name: Remove anstest_fex_port_channel - Interface Policy Leaf Profile with type Fex cisco.aci.aci_interface_policy_leaf_profile: @@ -456,9 +462,9 @@ - name: Assertion check for remove anstest_fex_port_channel - Interface Policy Leaf Profile with type Fex assert: that: - - anstest_fex_port_channel_absent.current | length == 0 - - anstest_fex_port_channel_absent.previous | length == 1 - - anstest_fex_port_channel_absent.previous.0.infraFexP.attributes.name == "anstest_fex_port_channel" + - anstest_fex_port_channel_absent.current | length == 0 + - anstest_fex_port_channel_absent.previous | length == 1 + - anstest_fex_port_channel_absent.previous.0.infraFexP.attributes.name == "anstest_fex_port_channel" - name: Ensure anstest_leaf_profile interface does not exists cisco.aci.aci_interface_policy_leaf_profile: &anstest_leaf_profile_absent @@ -471,7 +477,7 @@ - name: Assertion check for ensure anstest_leaf_profile interface does not exists assert: that: - - anstest_leaf_profile_absent.current | length == 0 + - anstest_leaf_profile_absent.current | length == 0 - name: Ensure anstest_fex_profile interface does not exists cisco.aci.aci_interface_policy_leaf_profile: &anstest_fex_profile_absent @@ -484,7 +490,7 @@ - name: Assertion check for ensure anstest_fex_profile interface does not exists assert: that: - - anstest_fex_profile_absent.current | length == 0 + - anstest_fex_profile_absent.current | length == 0 - name: Ensure temp_anstest_fex_profile interface does not exists cisco.aci.aci_interface_policy_leaf_profile: &temp_anstest_fex_profile_absent @@ -497,7 +503,7 @@ - name: Assertion check for ensure temp_anstest_fex_profile interface does not exists assert: that: - - temp_anstest_fex_profile_absent.current | length == 0 + - temp_anstest_fex_profile_absent.current | length == 0 - name: Add a new anstest_leaf_profile with profile type leaf cisco.aci.aci_interface_policy_leaf_profile: &anstest_leaf_profile_present @@ -508,11 +514,11 @@ - name: Assertion check for add a new anstest_leaf_profile with profile type leaf assert: that: - - anstest_leaf_profile_present is changed - - anstest_leaf_profile_present.current | length == 1 - - anstest_leaf_profile_present.previous | length == 0 - - anstest_leaf_profile_present.current.0.infraAccPortP.attributes.name == "anstest_leaf_profile" - - anstest_leaf_profile_present.current.0.infraAccPortP.attributes.dn == "uni/infra/accportprof-anstest_leaf_profile" + - anstest_leaf_profile_present is changed + - anstest_leaf_profile_present.current | length == 1 + - anstest_leaf_profile_present.previous | length == 0 + - anstest_leaf_profile_present.current.0.infraAccPortP.attributes.name == "anstest_leaf_profile" + - anstest_leaf_profile_present.current.0.infraAccPortP.attributes.dn == "uni/infra/accportprof-anstest_leaf_profile" - name: Add a new anstest_fex_profile with profile type fex cisco.aci.aci_interface_policy_leaf_profile: &anstest_fex_profile_present @@ -523,11 +529,11 @@ - name: Assertion check for add a new anstest_fex_profile with profile type fex assert: that: - - anstest_fex_profile_present is changed - - anstest_fex_profile_present.current | length == 1 - - anstest_fex_profile_present.previous | length == 0 - - anstest_fex_profile_present.current.0.infraFexP.attributes.name == "anstest_fex_profile" - - anstest_fex_profile_present.current.0.infraFexP.attributes.dn == "uni/infra/fexprof-anstest_fex_profile" + - anstest_fex_profile_present is changed + - anstest_fex_profile_present.current | length == 1 + - anstest_fex_profile_present.previous | length == 0 + - anstest_fex_profile_present.current.0.infraFexP.attributes.name == "anstest_fex_profile" + - anstest_fex_profile_present.current.0.infraFexP.attributes.dn == "uni/infra/fexprof-anstest_fex_profile" - name: Add a new temp_anstest_fex_profile with profile type fex cisco.aci.aci_interface_policy_leaf_profile: &temp_anstest_fex_profile_present @@ -538,14 +544,15 @@ - name: Assertion check for add a new temp_anstest_fex_profile with profile type fex assert: that: - - temp_anstest_fex_profile_present is changed - - temp_anstest_fex_profile_present.current | length == 1 - - temp_anstest_fex_profile_present.previous | length == 0 - - temp_anstest_fex_profile_present.current.0.infraFexP.attributes.name == "temp_anstest_fex_profile" - - temp_anstest_fex_profile_present.current.0.infraFexP.attributes.dn == "uni/infra/fexprof-temp_anstest_fex_profile" + - temp_anstest_fex_profile_present is changed + - temp_anstest_fex_profile_present.current | length == 1 + - temp_anstest_fex_profile_present.previous | length == 0 + - temp_anstest_fex_profile_present.current.0.infraFexP.attributes.name == "temp_anstest_fex_profile" + - temp_anstest_fex_profile_present.current.0.infraFexP.attributes.dn == "uni/infra/fexprof-temp_anstest_fex_profile" - name: Add a new policy_group with the same name of interface profile - temp_anstest_fex_profile - cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: &temp_anstest_fex_profile_policy_group_present + cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: + &temp_anstest_fex_profile_policy_group_present <<: *aci_info policy_group: temp_anstest_fex_profile fex_profile: temp_anstest_fex_profile @@ -555,11 +562,11 @@ - name: Assertion check for add a new policy_group with the same name of interface profile - temp_anstest_fex_profile assert: that: - - temp_anstest_fex_profile_policy_group_present is changed - - temp_anstest_fex_profile_policy_group_present.current | length == 1 - - temp_anstest_fex_profile_policy_group_present.previous | length == 0 - - temp_anstest_fex_profile_policy_group_present.current.0.infraFexBndlGrp.attributes.name == "temp_anstest_fex_profile" - - temp_anstest_fex_profile_policy_group_present.current.0.infraFexBndlGrp.attributes.dn == "uni/infra/fexprof-temp_anstest_fex_profile/fexbundle-temp_anstest_fex_profile" + - temp_anstest_fex_profile_policy_group_present is changed + - temp_anstest_fex_profile_policy_group_present.current | length == 1 + - temp_anstest_fex_profile_policy_group_present.previous | length == 0 + - temp_anstest_fex_profile_policy_group_present.current.0.infraFexBndlGrp.attributes.name == "temp_anstest_fex_profile" + - temp_anstest_fex_profile_policy_group_present.current.0.infraFexBndlGrp.attributes.dn == "uni/infra/fexprof-temp_anstest_fex_profile/fexbundle-temp_anstest_fex_profile" - name: Bind temp_anstest_fex_profile with anstest_fex_profile - Fex Profile Policy Group cisco.aci.aci_access_port_to_interface_policy_leaf_profile: @@ -577,7 +584,7 @@ - name: Assertion check for bind temp_anstest_fex_profile with anstest_fex_profile - Fex Profile Policy Group assert: that: - - temp_anstest_fex_profile_access_port_present.msg == "Invalid Configuration - interface_type fex_profile can not be configured with a profile of type fex" + - temp_anstest_fex_profile_access_port_present.msg == "Invalid Configuration - interface_type fex_profile can not be configured with a profile of type fex" - name: Remove temp_anstest_fex_profile cisco.aci.aci_interface_policy_leaf_profile: @@ -587,12 +594,13 @@ - name: Assertion check for remove temp_anstest_fex_profile assert: that: - - remove_anstest_fex_profile_absent is changed - - remove_anstest_fex_profile_absent.current | length == 0 - - remove_anstest_fex_profile_absent.previous | length == 1 + - remove_anstest_fex_profile_absent is changed + - remove_anstest_fex_profile_absent.current | length == 0 + - remove_anstest_fex_profile_absent.previous | length == 1 - name: Add a new policy_group with the same name of interface profile - anstest_fex_profile - cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: &anstest_fex_profile_policy_group_present + cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: + &anstest_fex_profile_policy_group_present <<: *aci_info policy_group: anstest_fex_profile fex_profile: anstest_fex_profile @@ -602,14 +610,15 @@ - name: Assertion check for add a new policy_group with the same name of interface profile - anstest_fex_profile assert: that: - - anstest_fex_profile_policy_group_present is changed - - anstest_fex_profile_policy_group_present.current | length == 1 - - anstest_fex_profile_policy_group_present.previous | length == 0 - - anstest_fex_profile_policy_group_present.current.0.infraFexBndlGrp.attributes.name == "anstest_fex_profile" - - anstest_fex_profile_policy_group_present.current.0.infraFexBndlGrp.attributes.dn == "uni/infra/fexprof-anstest_fex_profile/fexbundle-anstest_fex_profile" + - anstest_fex_profile_policy_group_present is changed + - anstest_fex_profile_policy_group_present.current | length == 1 + - anstest_fex_profile_policy_group_present.previous | length == 0 + - anstest_fex_profile_policy_group_present.current.0.infraFexBndlGrp.attributes.name == "anstest_fex_profile" + - anstest_fex_profile_policy_group_present.current.0.infraFexBndlGrp.attributes.dn == "uni/infra/fexprof-anstest_fex_profile/fexbundle-anstest_fex_profile" - name: Bind anstest_leaf_profile with anstest_fex_profile - Fex Profile Policy Group - cisco.aci.aci_access_port_to_interface_policy_leaf_profile: &anstest_leaf_profile_access_port_present + cisco.aci.aci_access_port_to_interface_policy_leaf_profile: + &anstest_leaf_profile_access_port_present <<: *aci_info leaf_interface_profile: anstest_leaf_profile policy_group: anstest_fex_profile @@ -623,12 +632,12 @@ - name: Assertion check for bind anstest_leaf_profile with anstest_fex_profile - Fex Profile Policy Group assert: that: - - anstest_leaf_profile_access_port_present is changed - - anstest_leaf_profile_access_port_present.current | length == 1 - - anstest_leaf_profile_access_port_present.previous | length == 0 - - anstest_leaf_profile_access_port_present.current.0.infraHPortS.attributes.name == "anstest_leaf_profile_access_port" - - anstest_leaf_profile_access_port_present.current.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.tDn == "uni/infra/fexprof-anstest_fex_profile/fexbundle-anstest_fex_profile" - - anstest_leaf_profile_access_port_present.current.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.fexId == "105" + - anstest_leaf_profile_access_port_present is changed + - anstest_leaf_profile_access_port_present.current | length == 1 + - anstest_leaf_profile_access_port_present.previous | length == 0 + - anstest_leaf_profile_access_port_present.current.0.infraHPortS.attributes.name == "anstest_leaf_profile_access_port" + - anstest_leaf_profile_access_port_present.current.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.tDn == "uni/infra/fexprof-anstest_fex_profile/fexbundle-anstest_fex_profile" + - anstest_leaf_profile_access_port_present.current.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.fexId == "105" - name: Remove anstest_leaf_profile cisco.aci.aci_interface_policy_leaf_profile: @@ -638,9 +647,9 @@ - name: Assertion check for remove anstest_leaf_profile assert: that: - - anstest_leaf_profile_cleanup is changed - - anstest_leaf_profile_cleanup.previous | length == 1 - - anstest_leaf_profile_cleanup.current | length == 0 + - anstest_leaf_profile_cleanup is changed + - anstest_leaf_profile_cleanup.previous | length == 1 + - anstest_leaf_profile_cleanup.current | length == 0 - name: Remove anstest_fex_profile cisco.aci.aci_interface_policy_leaf_profile: @@ -650,6 +659,6 @@ - name: Assertion check for remove anstest_fex_profile assert: that: - - anstest_fex_profile_cleanup is changed - - anstest_fex_profile_cleanup.previous | length == 1 - - anstest_fex_profile_cleanup.current | length == 0 + - anstest_fex_profile_cleanup is changed + - anstest_fex_profile_cleanup.previous | length == 1 + - anstest_fex_profile_cleanup.current | length == 0 diff --git a/tests/integration/targets/aci_interface_policy_leaf_profile_fex_policy_group/tasks/main.yml b/tests/integration/targets/aci_interface_policy_leaf_profile_fex_policy_group/tasks/main.yml index 56da9f6e2..bbea74d61 100644 --- a/tests/integration/targets/aci_interface_policy_leaf_profile_fex_policy_group/tasks/main.yml +++ b/tests/integration/targets/aci_interface_policy_leaf_profile_fex_policy_group/tasks/main.yml @@ -5,19 +5,19 @@ - name: Test that we have an ACI APIC host, ACI username and ACI password fail: - msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' + msg: "Please define the following variables: aci_hostname, aci_username and aci_password." when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined # SET VARS - name: Set vars set_fact: aci_info: &aci_info - host: '{{ aci_hostname }}' - username: '{{ aci_username }}' - password: '{{ aci_password }}' - validate_certs: '{{ aci_validate_certs | default(false) }}' - use_ssl: '{{ aci_use_ssl | default(true) }}' - use_proxy: '{{ aci_use_proxy | default(true) }}' + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: "{{ aci_validate_certs | default(false) }}" + use_ssl: "{{ aci_use_ssl | default(true) }}" + use_proxy: "{{ aci_use_proxy | default(true) }}" output_level: '{{ aci_output_level | default("info") }}' - name: Ensure anstest_fex_profile - Interface Policy Fex profile does not exists @@ -34,7 +34,8 @@ register: fex_profile_present - name: Add Fex Policy Group to anstest_fex_profile - Interface Policy Fex profile with check mode - cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: &cm_fex_policy_group_present + cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: + &cm_fex_policy_group_present <<: *aci_info name: anstest_fex_policy_group fex_profile: anstest_fex_profile @@ -52,7 +53,8 @@ - cm_fex_policy_group_present.sent.infraFexBndlGrp.attributes.dn == "uni/infra/fexprof-anstest_fex_profile/fexbundle-anstest_fex_policy_group" - name: Add Fex Policy Group to anstest_fex_profile - Interface Policy Fex profile with normal mode - cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: &nm_fex_policy_group_present + cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: + &nm_fex_policy_group_present <<: *cm_fex_policy_group_present register: nm_fex_policy_group_present @@ -66,7 +68,8 @@ - nm_fex_policy_group_present.current.0.infraFexBndlGrp.attributes.dn == "uni/infra/fexprof-anstest_fex_profile/fexbundle-anstest_fex_policy_group" - name: Add Fex Policy Group to anstest_fex_profile - Interface Policy Fex profile with normal mode - idempotency works - cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: &idempotency_fex_policy_group_present + cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: + &idempotency_fex_policy_group_present <<: *nm_fex_policy_group_present register: idempotency_fex_policy_group_present @@ -207,7 +210,8 @@ - all_fex_policy_groups.current | length >= 4 - name: Remove anstest_fex_policy_group - Fex Policy Group from anstest_fex_profile with check mode - cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: &cm_anstest_fex_policy_group_absent + cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: + &cm_anstest_fex_policy_group_absent <<: *aci_info name: anstest_fex_policy_group fex_profile: anstest_fex_profile @@ -227,7 +231,8 @@ - cm_anstest_fex_policy_group_absent.previous.0.infraFexBndlGrp.attributes.dn == "uni/infra/fexprof-anstest_fex_profile/fexbundle-anstest_fex_policy_group" - name: Remove anstest_fex_policy_group - Fex Policy Group from anstest_fex_profile with normal mode - cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: &nm_anstest_fex_policy_group_absent + cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: + &nm_anstest_fex_policy_group_absent <<: *cm_anstest_fex_policy_group_absent register: nm_anstest_fex_policy_group_absent @@ -241,7 +246,8 @@ - nm_anstest_fex_policy_group_absent.previous.0.infraFexBndlGrp.attributes.dn == "uni/infra/fexprof-anstest_fex_profile/fexbundle-anstest_fex_policy_group" - name: Remove anstest_fex_policy_group - Fex Policy Group from anstest_fex_profile with normal mode - idempotency works - cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: &idempotency_anstest_fex_policy_group_absent + cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: + &idempotency_anstest_fex_policy_group_absent <<: *nm_anstest_fex_policy_group_absent register: idempotency_anstest_fex_policy_group_absent From 51da77b1462a6aea28cf02d815710474d39af368 Mon Sep 17 00:00:00 2001 From: Lionel Hercot Date: Fri, 21 Oct 2022 17:36:45 -0700 Subject: [PATCH 6/6] [ignore] Fix tests for aci_access_port_to_interface_policy_leaf_profile for increased coverage --- ...s_port_to_interface_policy_leaf_profile.py | 6 +- .../tasks/main.yml | 58 +++++++++++++++++++ 2 files changed, 61 insertions(+), 3 deletions(-) diff --git a/plugins/modules/aci_access_port_to_interface_policy_leaf_profile.py b/plugins/modules/aci_access_port_to_interface_policy_leaf_profile.py index ed26e98dc..b9407f34d 100644 --- a/plugins/modules/aci_access_port_to_interface_policy_leaf_profile.py +++ b/plugins/modules/aci_access_port_to_interface_policy_leaf_profile.py @@ -99,7 +99,7 @@ default: switch_port fex_id: description: - - Id of the fex profile, the valid FEX ID is between 101 to 199. + - Id of the fex profile, a valid FEX ID is between 101 to 199. type: int fex_profile: description: @@ -434,11 +434,11 @@ def main(): if fex_id in range(101, 200): infra_rs_acc_base_grp["infraRsAccBaseGrp"]["attributes"]["fexId"] = fex_id else: - module.fail_json(msg="The valid FEX ID is between 101 to 199") + module.fail_json(msg="A valid FEX ID is between 101 to 199") else: module.fail_json(msg="The fex_id must not be None, when interface_type is fex_profile") - elif interface_type != "fex_profile": + else: infra_rs_acc_base_grp["infraRsAccBaseGrp"]["attributes"]["tDn"] = INTERFACE_TYPE_MAPPING[interface_type].format(policy_group) child_configs.append(infra_rs_acc_base_grp) diff --git a/tests/integration/targets/aci_access_port_to_interface_policy_leaf_profile/tasks/main.yml b/tests/integration/targets/aci_access_port_to_interface_policy_leaf_profile/tasks/main.yml index da4f699c8..6aa648043 100644 --- a/tests/integration/targets/aci_access_port_to_interface_policy_leaf_profile/tasks/main.yml +++ b/tests/integration/targets/aci_access_port_to_interface_policy_leaf_profile/tasks/main.yml @@ -205,6 +205,29 @@ - bind_fexintprftest_policy_group.current.0.infraHPortS.children.1.infraRsAccBaseGrp.attributes.fexId == "105" - bind_fexintprftest_policy_group.current.0.infraHPortS.children.1.infraRsAccBaseGrp.attributes.tDn == "uni/infra/fexprof-fexintprftest/fexbundle-fexintprftest" +- name: Bind anstest_fex_accessportselector_2 without fex_profile + cisco.aci.aci_access_port_to_interface_policy_leaf_profile: + <<: *aci_info + state: present + leaf_interface_profile: leafintprftest + policy_group: fexintprftest + access_port_selector_name: anstest_fex_accessportselector_2 + interface_type: fex_profile + from_port: 14 + to_port: 14 + port_blk: block2 + fex_id: 106 + register: bind_fexintprftest_policy_group_2 + +- name: Assertions check for bind anstest_fex_accessportselector with fexintprftest - Fex Profile Policy Group + assert: + that: + - bind_fexintprftest_policy_group_2 is changed + - bind_fexintprftest_policy_group_2.previous | length == 0 + - bind_fexintprftest_policy_group_2.current.0.infraHPortS.attributes.name == "anstest_fex_accessportselector_2" + - bind_fexintprftest_policy_group_2.current.0.infraHPortS.children.1.infraRsAccBaseGrp.attributes.fexId == "106" + - bind_fexintprftest_policy_group_2.current.0.infraHPortS.children.1.infraRsAccBaseGrp.attributes.tDn == "uni/infra/fexprof-fexintprftest/fexbundle-fexintprftest" + - name: Remove fex policy group from the fexintprftest fex profile cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: <<: *fexintprftest_policy_group_present @@ -639,6 +662,41 @@ - anstest_leaf_profile_access_port_present.current.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.tDn == "uni/infra/fexprof-anstest_fex_profile/fexbundle-anstest_fex_profile" - anstest_leaf_profile_access_port_present.current.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.fexId == "105" +- name: Bind anstest_leaf_profile with anstest_fex_profile with wrong fex_id + cisco.aci.aci_access_port_to_interface_policy_leaf_profile: + <<: *aci_info + leaf_interface_profile: anstest_leaf_profile + policy_group: anstest_fex_profile + access_port_selector_name: anstest_leaf_profile_access_port + interface_type: fex_profile + fex_id: 999 + type: leaf + state: present + ignore_errors: yes + register: anstest_leaf_profile_access_port_wrong_fex_id + +- name: Assertion check for bind anstest_leaf_profile with wrong fex_id + assert: + that: + - anstest_leaf_profile_access_port_wrong_fex_id.msg == "A valid FEX ID is between 101 to 199" + +- name: Bind anstest_leaf_profile with anstest_fex_profile with no fex_id + cisco.aci.aci_access_port_to_interface_policy_leaf_profile: + <<: *aci_info + leaf_interface_profile: anstest_leaf_profile + policy_group: anstest_fex_profile + access_port_selector_name: anstest_leaf_profile_access_port + interface_type: fex_profile + type: leaf + state: present + ignore_errors: yes + register: anstest_leaf_profile_access_port_no_fex_id + +- name: Assertion check for bind anstest_leaf_profile with no fex_id + assert: + that: + - anstest_leaf_profile_access_port_no_fex_id.msg == "The fex_id must not be None, when interface_type is fex_profile" + - name: Remove anstest_leaf_profile cisco.aci.aci_interface_policy_leaf_profile: <<: *anstest_leaf_profile_absent