From a948e62b5b4fe696d0b0d4fdea2f0917f7759fe3 Mon Sep 17 00:00:00 2001 From: anvitha-jain Date: Mon, 9 Oct 2023 06:24:19 -0700 Subject: [PATCH 01/10] [minor_changes] Added BFD Multihop Interface policy (bfdMhIfPol) class. --- .../aci_bfd_multihop_interface_policy.py | 312 ++++++++++++++++++ .../aci_bfd_multihop_interface_policy/aliases | 2 + .../tasks/main.yml | 181 ++++++++++ 3 files changed, 495 insertions(+) create mode 100644 plugins/modules/aci_bfd_multihop_interface_policy.py create mode 100644 tests/integration/targets/aci_bfd_multihop_interface_policy/aliases create mode 100644 tests/integration/targets/aci_bfd_multihop_interface_policy/tasks/main.yml diff --git a/plugins/modules/aci_bfd_multihop_interface_policy.py b/plugins/modules/aci_bfd_multihop_interface_policy.py new file mode 100644 index 000000000..2f4a36840 --- /dev/null +++ b/plugins/modules/aci_bfd_multihop_interface_policy.py @@ -0,0 +1,312 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2023, Anvitha Jain (@anvjain) +# 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": "community"} + +DOCUMENTATION = r""" +--- +module: aci_bfd_multihop_interface_policy +short_description: Manage BFD Multihop Interface policies. +description: +- Manage BFD Multihop Interface policy (bfdMhIfPol) configuration on Cisco ACI fabrics. +- Only availavle in APIC version 5.2 or later. +options: + tenant: + description: + - Name of an existing tenant. + type: str + name: + description: + - Name of the BFD Multihop Interface policy + type: str + aliases: [ bfd_multihop_interface_policy ] + description: + description: + - Description of the BFD Multihop Interface policy + type: str + admin_state: + description: + - Admin state of the BFD Multihop Interface policy + type: str + choices: [ enabled, disabled ] + default: enabled + detection_multiplier: + description: + - Detection multiplier of the BFD Multihop Interface policy + type: int + default: 3 + min_transmit_interval: + description: + - Minimum transmit (Tx) interval of the BFD Multihop Interface policy + - Allowed range is 250-999. + type: int + default: 250 + min_receive_interval: + description: + - Minimum receive (Rx) interval of the BFD Multihop Interface policy + - Allowed range is 250-999. + type: int + default: 250 + 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 + +notes: +- The C(tenant) must exist before using this module in your playbook. + The M(cisco.aci.aci_tenant) modules can be used for this. +seealso: +- name: APIC Management Information Model reference + description: More information about the internal APIC class B(bfdMhIfPol). + link: https://developer.cisco.com/docs/apic-mim-ref/ +author: +- Anvitha Jain (@anvjain) +""" + +EXAMPLES = r""" +- name: Add a new BFD Multihop Interface policy + cisco.aci.aci_bfd_multihop_interface_policy: + host: apic + username: admin + password: SomeSecretPassword + tenant: ansible_tenant + name: ansible_bfd_multihop_interface_policy + description: Ansible BFD Multihop Interface Policy + state: present + state: present + delegate_to: localhost + +- name: Remove a BFD Multihop Interface policy + cisco.aci.aci_bfd_multihop_interface_policy: + host: apic + username: admin + password: SomeSecretPassword + tenant: ansible_tenant + name: ansible_bfd_multihop_interface_policy + state: absent + delegate_to: localhost + +- name: Query a BFD Multihop Interface policy + cisco.aci.aci_bfd_multihop_interface_policy: + host: apic + username: admin + password: SomeSecretPassword + tenant: ansible_tenant + name: my_dhcp_relay + state: query + delegate_to: localhost + register: query_result + +- name: Query all BFD Multihop Interface policies in a specific tenant + cisco.aci.aci_bfd_multihop_interface_policy: + host: apic + username: admin + password: SomeSecretPassword + tenant: ansible_tenant + state: query + delegate_to: localhost + register: query_result +""" + +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 + + +def main(): + argument_spec = aci_argument_spec() + argument_spec.update(aci_annotation_spec()) + argument_spec.update( + name=dict(type="str", aliases=["bfd_multihop_interface_policy"]), + description=dict(type="str"), + admin_state=dict(type="str", default="enabled", choices=["enabled", "disabled"]), + detection_multiplier=dict(type="int", default=3), + min_transmit_interval=dict(type="int", default=250), + min_receive_interval=dict(type="int", default=250), + state=dict(type="str", default="present", choices=["absent", "present", "query"]), + tenant=dict(type="str"), + ) + + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + required_if=[ + ["state", "absent", ["name", "tenant"]], + ["state", "present", ["name", "tenant"]], + ], + ) + + name = module.params.get("name") + description = module.params.get("description") + state = module.params.get("state") + tenant = module.params.get("tenant") + admin_state = module.params.get("admin_state") + detection_multiplier = module.params.get("detection_multiplier") + if detection_multiplier is not None and detection_multiplier not in range(1, 50): + module.fail_json(msg='The "detection_multiplier" must be a value between 1 and 50') + min_transmit_interval = module.params.get("min_transmit_interval") + if min_transmit_interval is not None and min_transmit_interval not in range(250, 999): + module.fail_json(msg='The "min_transmit_interval" must be a value between 250 and 999') + min_receive_interval = module.params.get("min_receive_interval") + if min_receive_interval is not None and min_receive_interval not in range(250, 999): + module.fail_json(msg='The "min_receive_interval" must be a value between 250 and 999') + + aci = ACIModule(module) + aci.construct_url( + root_class=dict( + aci_class="fvTenant", + aci_rn="tn-{0}".format(tenant), + module_object=tenant, + target_filter={"name": tenant}, + ), + subclass_1=dict( + aci_class="bfdMhIfPol", + aci_rn="bfdMhIfPol-{0}".format(name), + module_object=name, + target_filter={"name": name}, + ), + ) + + aci.get_existing() + + if state == "present": + aci.payload( + aci_class="bfdMhIfPol", + class_config=dict( + name=name, + descr=description, + adminSt=admin_state, + detectMult=detection_multiplier, + minTxIntvl=min_transmit_interval, + minRxIntvl=min_receive_interval), + ) + + aci.get_diff(aci_class="bfdMhIfPol") + + aci.post_config() + + elif state == "absent": + aci.delete_config() + + aci.exit_json() + + +if __name__ == "__main__": + main() diff --git a/tests/integration/targets/aci_bfd_multihop_interface_policy/aliases b/tests/integration/targets/aci_bfd_multihop_interface_policy/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/tests/integration/targets/aci_bfd_multihop_interface_policy/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/tests/integration/targets/aci_bfd_multihop_interface_policy/tasks/main.yml b/tests/integration/targets/aci_bfd_multihop_interface_policy/tasks/main.yml new file mode 100644 index 000000000..4d97fe404 --- /dev/null +++ b/tests/integration/targets/aci_bfd_multihop_interface_policy/tasks/main.yml @@ -0,0 +1,181 @@ +# Test code for the ACI modules +# Copyright: (c) 2023, Anvitha Jain (@anvjain) + +# 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 + +- 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: debug + +- name: Query system information + cisco.aci.aci_system: + <<: *aci_info + id: 1 + state: query + register: version + +- name: Execute tasks only for non-cloud sites + when: version.current.0.topSystem.attributes.version is version('5.2', '>=') # This condition will execute only when APIC version >= 5.2 + block: # block specifies execution of tasks within, based on conditions + + # CLEAN ENVIRONMENT + - name: Remove the ansible_tenant + aci_tenant: + <<: *aci_info + tenant: ansible_tenant + state: absent + + - name: Add a new tenant + aci_tenant: + <<: *aci_info + tenant: ansible_tenant + description: Ansible tenant + state: present + + # CREATE BFD Multihop Interface policy + - name: Add a new BFD Multihop Interface policy - check mode + cisco.aci.aci_bfd_multihop_interface_policy: &add_bfd_multihop_interface_pol + <<: *aci_info + tenant: ansible_tenant + name: ansible_bfd_multihop_interface_policy + description: Ansible BFD Multihop Interface Policy + state: present + check_mode: true + register: cm_add_bfd_multihop_interface_pol + + - name: Add a new BFD Multihop Interface policy - normal mode + cisco.aci.aci_bfd_multihop_interface_policy: + <<: *add_bfd_multihop_interface_pol + state: present + register: nm_add_bfd_multihop_interface_pol + + - name: Verify BFD Multihop Interface Policy creation + assert: + that: + - cm_add_bfd_multihop_interface_pol is changed + - nm_add_bfd_multihop_interface_pol is changed + - cm_add_bfd_multihop_interface_pol.previous == nm_add_bfd_multihop_interface_pol.previous == [] + - nm_add_bfd_multihop_interface_pol.current.0.bfdMhIfPol.attributes.dn == "uni/tn-ansible_tenant/bfdMhIfPol-ansible_bfd_multihop_interface_policy" + - nm_add_bfd_multihop_interface_pol.current.0.bfdMhIfPol.attributes.name == "ansible_bfd_multihop_interface_policy" + - nm_add_bfd_multihop_interface_pol.current.0.bfdMhIfPol.attributes.descr == "Ansible BFD Multihop Interface Policy" + - nm_add_bfd_multihop_interface_pol.current.0.bfdMhIfPol.attributes.adminSt == "enabled" + - nm_add_bfd_multihop_interface_pol.current.0.bfdMhIfPol.attributes.detectMult == "3" + - nm_add_bfd_multihop_interface_pol.current.0.bfdMhIfPol.attributes.minRxIntvl == "250" + - nm_add_bfd_multihop_interface_pol.current.0.bfdMhIfPol.attributes.minTxIntvl == "250" + + - name: Add a new BFD Multihop Interface policy again - idempotency + cisco.aci.aci_bfd_multihop_interface_policy: + <<: *add_bfd_multihop_interface_pol + state: present + register: add_bfd_multihop_interface_pol_again + + - name: Verify BFD Multihop Interface Policy creation again - idempotency + assert: + that: + - add_bfd_multihop_interface_pol_again is not changed + - add_bfd_multihop_interface_pol_again.previous != [] + - add_bfd_multihop_interface_pol_again.current | length == 1 + - add_bfd_multihop_interface_pol_again.previous | length == 1 + + - name: Modify a BFD Multihop Interface policy + cisco.aci.aci_bfd_multihop_interface_policy: + <<: *add_bfd_multihop_interface_pol + admin_state: disabled + detection_multiplier: 5 + min_transmit_interval: 270 + min_receive_interval: 500 + state: present + register: update_bfd_multihop_interface_pol + + - name: Verify modifying BFD Multihop Interface Policy + assert: + that: + - update_bfd_multihop_interface_pol is changed + - update_bfd_multihop_interface_pol.previous != update_bfd_multihop_interface_pol.current + - update_bfd_multihop_interface_pol.current.0.bfdMhIfPol.attributes.dn == "uni/tn-ansible_tenant/bfdMhIfPol-ansible_bfd_multihop_interface_policy" + - update_bfd_multihop_interface_pol.current.0.bfdMhIfPol.attributes.name == "ansible_bfd_multihop_interface_policy" + - update_bfd_multihop_interface_pol.current.0.bfdMhIfPol.attributes.descr == "Ansible BFD Multihop Interface Policy" + - update_bfd_multihop_interface_pol.current.0.bfdMhIfPol.attributes.adminSt == "disabled" + - update_bfd_multihop_interface_pol.current.0.bfdMhIfPol.attributes.detectMult == "5" + - update_bfd_multihop_interface_pol.current.0.bfdMhIfPol.attributes.minRxIntvl == "500" + - update_bfd_multihop_interface_pol.current.0.bfdMhIfPol.attributes.minTxIntvl == "270" + + # Added another BFD Multihop Interface policy + - name: Add a new BFD Multihop Interface policy - normal mode + cisco.aci.aci_bfd_multihop_interface_policy: + <<: *add_bfd_multihop_interface_pol + name: ansible_bfd_multihop_interface_policy_2 + state: present + register: add_bfd_multihop_interface_pol_2 + + - name: Verify BFD Multihop Interface Policy creation + assert: + that: + - add_bfd_multihop_interface_pol_2 is changed + - add_bfd_multihop_interface_pol_2.previous == [] + - add_bfd_multihop_interface_pol_2.current.0.bfdMhIfPol.attributes.dn == "uni/tn-ansible_tenant/bfdMhIfPol-ansible_bfd_multihop_interface_policy_2" + - add_bfd_multihop_interface_pol_2.current.0.bfdMhIfPol.attributes.name == "ansible_bfd_multihop_interface_policy_2" + - add_bfd_multihop_interface_pol_2.current.0.bfdMhIfPol.attributes.descr == "Ansible BFD Multihop Interface Policy" + - add_bfd_multihop_interface_pol_2.current.0.bfdMhIfPol.attributes.adminSt == "enabled" + - add_bfd_multihop_interface_pol_2.current.0.bfdMhIfPol.attributes.detectMult == "3" + - add_bfd_multihop_interface_pol_2.current.0.bfdMhIfPol.attributes.minRxIntvl == "250" + - add_bfd_multihop_interface_pol_2.current.0.bfdMhIfPol.attributes.minTxIntvl == "250" + + - name: Query all BFD Multihop Interface policies in a specific tenant + cisco.aci.aci_bfd_multihop_interface_policy: + <<: *aci_info + tenant: ansible_tenant + state: query + register: query_all_result + + - name: Verify querying all BFD Multihop Interface Policies + assert: + that: + - query_all_result is not changed + - query_all_result.current.0.fvTenant.children | length == 2 + - query_all_result.current.0.fvTenant.children[0].bfdMhIfPol.attributes.name == "ansible_bfd_multihop_interface_policy_2" + - query_all_result.current.0.fvTenant.children[1].bfdMhIfPol.attributes.name == "ansible_bfd_multihop_interface_policy" + + - name: Query 'ansible_bfd_multihop_interface_policy' BFD Multihop Interface policies in a specific tenant + cisco.aci.aci_bfd_multihop_interface_policy: + <<: *aci_info + tenant: ansible_tenant + name: ansible_bfd_multihop_interface_policy + state: query + register: query_result + + - name: Verify querying'ansible_bfd_multihop_interface_policy BFD' Multihop Interface Policy + assert: + that: + - query_result is not changed + - query_result.current.0.bfdMhIfPol.attributes.dn == "uni/tn-ansible_tenant/bfdMhIfPol-ansible_bfd_multihop_interface_policy" + - query_result.current.0.bfdMhIfPol.attributes.name == "ansible_bfd_multihop_interface_policy" + + - name: Remove a BFD Multihop Interface policy + cisco.aci.aci_bfd_multihop_interface_policy: + <<: *aci_info + tenant: ansible_tenant + name: ansible_bfd_multihop_interface_policy + state: absent + register: remove_bfd_multihop_interface_pol + + - name: Verifyremoving BFD Multihop Interface Policies + assert: + that: + - remove_bfd_multihop_interface_pol is changed + - remove_bfd_multihop_interface_pol.previous != [] + - remove_bfd_multihop_interface_pol.current == [] + + From 079dc1a15d8ac4232a8cae3a30381b6413dc7075 Mon Sep 17 00:00:00 2001 From: anvitha-jain Date: Wed, 11 Oct 2023 08:23:16 -0700 Subject: [PATCH 02/10] [minor_changes] Added aci_bfd_multihop_node_policy (bfdMhNodePol) object. --- .../aci_bfd_multihop_interface_policy.py | 2 +- .../modules/aci_bfd_multihop_node_policy.py | 312 ++++++++++++++++++ .../tasks/main.yml | 2 +- .../aci_bfd_multihop_node_policy/aliases | 2 + .../tasks/main.yml | 181 ++++++++++ 5 files changed, 497 insertions(+), 2 deletions(-) create mode 100644 plugins/modules/aci_bfd_multihop_node_policy.py create mode 100644 tests/integration/targets/aci_bfd_multihop_node_policy/aliases create mode 100644 tests/integration/targets/aci_bfd_multihop_node_policy/tasks/main.yml diff --git a/plugins/modules/aci_bfd_multihop_interface_policy.py b/plugins/modules/aci_bfd_multihop_interface_policy.py index 2f4a36840..64df9d10a 100644 --- a/plugins/modules/aci_bfd_multihop_interface_policy.py +++ b/plugins/modules/aci_bfd_multihop_interface_policy.py @@ -16,7 +16,7 @@ short_description: Manage BFD Multihop Interface policies. description: - Manage BFD Multihop Interface policy (bfdMhIfPol) configuration on Cisco ACI fabrics. -- Only availavle in APIC version 5.2 or later. +- Only available in APIC version 5.2 or later. options: tenant: description: diff --git a/plugins/modules/aci_bfd_multihop_node_policy.py b/plugins/modules/aci_bfd_multihop_node_policy.py new file mode 100644 index 000000000..dd1ae2620 --- /dev/null +++ b/plugins/modules/aci_bfd_multihop_node_policy.py @@ -0,0 +1,312 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2023, Anvitha Jain (@anvjain) +# 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": "community"} + +DOCUMENTATION = r""" +--- +module: aci_bfd_multihop_node_policy +short_description: Manage BFD Multihop Node policies. +description: +- Manage BFD Multihop Node policy (bfdMhNodePol) configuration on Cisco ACI fabrics. +- Only available in APIC version 5.2 or later. +options: + tenant: + description: + - Name of an existing tenant. + type: str + name: + description: + - Name of the BFD Multihop Node policy + type: str + aliases: [ bfd_multihop_node_policy ] + description: + description: + - Description of the BFD Multihop Node policy + type: str + admin_state: + description: + - Admin state of the BFD Multihop Node policy + type: str + choices: [ enabled, disabled ] + default: enabled + detection_multiplier: + description: + - Detection multiplier of the BFD Multihop Node policy + type: int + default: 3 + min_transmit_interval: + description: + - Minimum transmit (Tx) interval of the BFD Multihop Node policy + - Allowed range is 250-999. + type: int + default: 250 + min_receive_interval: + description: + - Minimum receive (Rx) interval of the BFD Multihop Node policy + - Allowed range is 250-999. + type: int + default: 250 + 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 + +notes: +- The C(tenant) must exist before using this module in your playbook. + The M(cisco.aci.aci_tenant) modules can be used for this. +seealso: +- name: APIC Management Information Model reference + description: More information about the internal APIC class B(bfdMhNodePol). + link: https://developer.cisco.com/docs/apic-mim-ref/ +author: +- Anvitha Jain (@anvjain) +""" + +EXAMPLES = r""" +- name: Add a new BFD Multihop Node policy + cisco.aci.aci_bfd_multihop_node_policy: + host: apic + username: admin + password: SomeSecretPassword + tenant: ansible_tenant + name: ansible_bfd_multihop_node_policy + description: Ansible BFD Multihop Node Policy + state: present + state: present + delegate_to: localhost + +- name: Remove a BFD Multihop Node policy + cisco.aci.aci_bfd_multihop_node_policy: + host: apic + username: admin + password: SomeSecretPassword + tenant: ansible_tenant + name: ansible_bfd_multihop_node_policy + state: absent + delegate_to: localhost + +- name: Query a BFD Multihop Node policy + cisco.aci.aci_bfd_multihop_node_policy: + host: apic + username: admin + password: SomeSecretPassword + tenant: ansible_tenant + name: my_dhcp_relay + state: query + delegate_to: localhost + register: query_result + +- name: Query all BFD Multihop Node policies in a specific tenant + cisco.aci.aci_bfd_multihop_node_policy: + host: apic + username: admin + password: SomeSecretPassword + tenant: ansible_tenant + state: query + delegate_to: localhost + register: query_result +""" + +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 + + +def main(): + argument_spec = aci_argument_spec() + argument_spec.update(aci_annotation_spec()) + argument_spec.update( + name=dict(type="str", aliases=["bfd_multihop_node_policy"]), + description=dict(type="str"), + admin_state=dict(type="str", default="enabled", choices=["enabled", "disabled"]), + detection_multiplier=dict(type="int", default=3), + min_transmit_interval=dict(type="int", default=250), + min_receive_interval=dict(type="int", default=250), + state=dict(type="str", default="present", choices=["absent", "present", "query"]), + tenant=dict(type="str"), + ) + + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + required_if=[ + ["state", "absent", ["name", "tenant"]], + ["state", "present", ["name", "tenant"]], + ], + ) + + name = module.params.get("name") + description = module.params.get("description") + state = module.params.get("state") + tenant = module.params.get("tenant") + admin_state = module.params.get("admin_state") + detection_multiplier = module.params.get("detection_multiplier") + if detection_multiplier is not None and detection_multiplier not in range(1, 50): + module.fail_json(msg='The "detection_multiplier" must be a value between 1 and 50') + min_transmit_interval = module.params.get("min_transmit_interval") + if min_transmit_interval is not None and min_transmit_interval not in range(250, 999): + module.fail_json(msg='The "min_transmit_interval" must be a value between 250 and 999') + min_receive_interval = module.params.get("min_receive_interval") + if min_receive_interval is not None and min_receive_interval not in range(250, 999): + module.fail_json(msg='The "min_receive_interval" must be a value between 250 and 999') + + aci = ACIModule(module) + aci.construct_url( + root_class=dict( + aci_class="fvTenant", + aci_rn="tn-{0}".format(tenant), + module_object=tenant, + target_filter={"name": tenant}, + ), + subclass_1=dict( + aci_class="bfdMhNodePol", + aci_rn="bfdMhNodePol-{0}".format(name), + module_object=name, + target_filter={"name": name}, + ), + ) + + aci.get_existing() + + if state == "present": + aci.payload( + aci_class="bfdMhNodePol", + class_config=dict( + name=name, + descr=description, + adminSt=admin_state, + detectMult=detection_multiplier, + minTxIntvl=min_transmit_interval, + minRxIntvl=min_receive_interval), + ) + + aci.get_diff(aci_class="bfdMhNodePol") + + aci.post_config() + + elif state == "absent": + aci.delete_config() + + aci.exit_json() + + +if __name__ == "__main__": + main() diff --git a/tests/integration/targets/aci_bfd_multihop_interface_policy/tasks/main.yml b/tests/integration/targets/aci_bfd_multihop_interface_policy/tasks/main.yml index 4d97fe404..bdd96d0fd 100644 --- a/tests/integration/targets/aci_bfd_multihop_interface_policy/tasks/main.yml +++ b/tests/integration/targets/aci_bfd_multihop_interface_policy/tasks/main.yml @@ -171,7 +171,7 @@ state: absent register: remove_bfd_multihop_interface_pol - - name: Verifyremoving BFD Multihop Interface Policies + - name: Verify removing BFD Multihop Interface Policies assert: that: - remove_bfd_multihop_interface_pol is changed diff --git a/tests/integration/targets/aci_bfd_multihop_node_policy/aliases b/tests/integration/targets/aci_bfd_multihop_node_policy/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/tests/integration/targets/aci_bfd_multihop_node_policy/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/tests/integration/targets/aci_bfd_multihop_node_policy/tasks/main.yml b/tests/integration/targets/aci_bfd_multihop_node_policy/tasks/main.yml new file mode 100644 index 000000000..b1e1f1685 --- /dev/null +++ b/tests/integration/targets/aci_bfd_multihop_node_policy/tasks/main.yml @@ -0,0 +1,181 @@ +# Test code for the ACI modules +# Copyright: (c) 2023, Anvitha Jain (@anvjain) + +# 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 + +- 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: debug + +- name: Query system information + cisco.aci.aci_system: + <<: *aci_info + id: 1 + state: query + register: version + +- name: Execute tasks only for non-cloud sites + when: version.current.0.topSystem.attributes.version is version('5.2', '>=') # This condition will execute only when APIC version >= 5.2 + block: # block specifies execution of tasks within, based on conditions + + # CLEAN ENVIRONMENT + - name: Remove the ansible_tenant + aci_tenant: + <<: *aci_info + tenant: ansible_tenant + state: absent + + - name: Add a new tenant + aci_tenant: + <<: *aci_info + tenant: ansible_tenant + description: Ansible tenant + state: present + + # CREATE BFD Multihop Node policy + - name: Add a new BFD Multihop Node policy - check mode + cisco.aci.aci_bfd_multihop_node_policy: &add_bfd_multihop_node_pol + <<: *aci_info + tenant: ansible_tenant + name: ansible_bfd_multihop_node_policy + description: Ansible BFD Multihop Node Policy + state: present + check_mode: true + register: cm_add_bfd_multihop_node_pol + + - name: Add a new BFD Multihop Node policy - normal mode + cisco.aci.aci_bfd_multihop_node_policy: + <<: *add_bfd_multihop_node_pol + state: present + register: nm_add_bfd_multihop_node_pol + + - name: Verify BFD Multihop Node Policy creation + assert: + that: + - cm_add_bfd_multihop_node_pol is changed + - nm_add_bfd_multihop_node_pol is changed + - cm_add_bfd_multihop_node_pol.previous == nm_add_bfd_multihop_node_pol.previous == [] + - nm_add_bfd_multihop_node_pol.current.0.bfdMhNodePol.attributes.dn == "uni/tn-ansible_tenant/bfdMhNodePol-ansible_bfd_multihop_node_policy" + - nm_add_bfd_multihop_node_pol.current.0.bfdMhNodePol.attributes.name == "ansible_bfd_multihop_node_policy" + - nm_add_bfd_multihop_node_pol.current.0.bfdMhNodePol.attributes.descr == "Ansible BFD Multihop Node Policy" + - nm_add_bfd_multihop_node_pol.current.0.bfdMhNodePol.attributes.adminSt == "enabled" + - nm_add_bfd_multihop_node_pol.current.0.bfdMhNodePol.attributes.detectMult == "3" + - nm_add_bfd_multihop_node_pol.current.0.bfdMhNodePol.attributes.minRxIntvl == "250" + - nm_add_bfd_multihop_node_pol.current.0.bfdMhNodePol.attributes.minTxIntvl == "250" + + - name: Add a new BFD Multihop Node policy again - idempotency + cisco.aci.aci_bfd_multihop_node_policy: + <<: *add_bfd_multihop_node_pol + state: present + register: add_bfd_multihop_node_pol_again + + - name: Verify BFD Multihop Node Policy creation again - idempotency + assert: + that: + - add_bfd_multihop_node_pol_again is not changed + - add_bfd_multihop_node_pol_again.previous != [] + - add_bfd_multihop_node_pol_again.current | length == 1 + - add_bfd_multihop_node_pol_again.previous | length == 1 + + - name: Modify a BFD Multihop Node policy + cisco.aci.aci_bfd_multihop_node_policy: + <<: *add_bfd_multihop_node_pol + admin_state: disabled + detection_multiplier: 5 + min_transmit_interval: 270 + min_receive_interval: 500 + state: present + register: update_bfd_multihop_node_pol + + - name: Verify modifying BFD Multihop Node Policy + assert: + that: + - update_bfd_multihop_node_pol is changed + - update_bfd_multihop_node_pol.previous != update_bfd_multihop_node_pol.current + - update_bfd_multihop_node_pol.current.0.bfdMhNodePol.attributes.dn == "uni/tn-ansible_tenant/bfdMhNodePol-ansible_bfd_multihop_node_policy" + - update_bfd_multihop_node_pol.current.0.bfdMhNodePol.attributes.name == "ansible_bfd_multihop_node_policy" + - update_bfd_multihop_node_pol.current.0.bfdMhNodePol.attributes.descr == "Ansible BFD Multihop Node Policy" + - update_bfd_multihop_node_pol.current.0.bfdMhNodePol.attributes.adminSt == "disabled" + - update_bfd_multihop_node_pol.current.0.bfdMhNodePol.attributes.detectMult == "5" + - update_bfd_multihop_node_pol.current.0.bfdMhNodePol.attributes.minRxIntvl == "500" + - update_bfd_multihop_node_pol.current.0.bfdMhNodePol.attributes.minTxIntvl == "270" + + # Added another BFD Multihop Node policy + - name: Add a new BFD Multihop Node policy - normal mode + cisco.aci.aci_bfd_multihop_node_policy: + <<: *add_bfd_multihop_node_pol + name: ansible_bfd_multihop_node_policy_2 + state: present + register: add_bfd_multihop_node_pol_2 + + - name: Verify BFD Multihop Node Policy creation + assert: + that: + - add_bfd_multihop_node_pol_2 is changed + - add_bfd_multihop_node_pol_2.previous == [] + - add_bfd_multihop_node_pol_2.current.0.bfdMhNodePol.attributes.dn == "uni/tn-ansible_tenant/bfdMhNodePol-ansible_bfd_multihop_node_policy_2" + - add_bfd_multihop_node_pol_2.current.0.bfdMhNodePol.attributes.name == "ansible_bfd_multihop_node_policy_2" + - add_bfd_multihop_node_pol_2.current.0.bfdMhNodePol.attributes.descr == "Ansible BFD Multihop Node Policy" + - add_bfd_multihop_node_pol_2.current.0.bfdMhNodePol.attributes.adminSt == "enabled" + - add_bfd_multihop_node_pol_2.current.0.bfdMhNodePol.attributes.detectMult == "3" + - add_bfd_multihop_node_pol_2.current.0.bfdMhNodePol.attributes.minRxIntvl == "250" + - add_bfd_multihop_node_pol_2.current.0.bfdMhNodePol.attributes.minTxIntvl == "250" + + - name: Query all BFD Multihop Node policies in a specific tenant + cisco.aci.aci_bfd_multihop_node_policy: + <<: *aci_info + tenant: ansible_tenant + state: query + register: query_all_result + + - name: Verify querying all BFD Multihop Node Policies + assert: + that: + - query_all_result is not changed + - query_all_result.current.0.fvTenant.children | length == 2 + - query_all_result.current.0.fvTenant.children[0].bfdMhNodePol.attributes.name == "ansible_bfd_multihop_node_policy_2" + - query_all_result.current.0.fvTenant.children[1].bfdMhNodePol.attributes.name == "ansible_bfd_multihop_node_policy" + + - name: Query 'ansible_bfd_multihop_node_policy' BFD Multihop Node policies in a specific tenant + cisco.aci.aci_bfd_multihop_node_policy: + <<: *aci_info + tenant: ansible_tenant + name: ansible_bfd_multihop_node_policy + state: query + register: query_result + + - name: Verify querying'ansible_bfd_multihop_node_policy BFD' Multihop Node Policy + assert: + that: + - query_result is not changed + - query_result.current.0.bfdMhNodePol.attributes.dn == "uni/tn-ansible_tenant/bfdMhNodePol-ansible_bfd_multihop_node_policy" + - query_result.current.0.bfdMhNodePol.attributes.name == "ansible_bfd_multihop_node_policy" + + - name: Remove a BFD Multihop Node policy + cisco.aci.aci_bfd_multihop_node_policy: + <<: *aci_info + tenant: ansible_tenant + name: ansible_bfd_multihop_node_policy + state: absent + register: remove_bfd_multihop_node_pol + + - name: Verify removing BFD Multihop Node Policies + assert: + that: + - remove_bfd_multihop_node_pol is changed + - remove_bfd_multihop_node_pol.previous != [] + - remove_bfd_multihop_node_pol.current == [] + + From 19887858b7c6d90d83e70623507deb52ac77917e Mon Sep 17 00:00:00 2001 From: anvitha-jain Date: Thu, 19 Oct 2023 22:23:51 -0700 Subject: [PATCH 03/10] [minor_changes] Added BFD multihop interface profile module and test cases --- .../aci_bfd_multihop_interface_profile.py | 309 ++++++++++++++++++ .../aliases | 2 + .../tasks/main.yml | 174 ++++++++++ 3 files changed, 485 insertions(+) create mode 100644 plugins/modules/aci_bfd_multihop_interface_profile.py create mode 100644 tests/integration/targets/aci_bfd_multihop_interface_profile/aliases create mode 100644 tests/integration/targets/aci_bfd_multihop_interface_profile/tasks/main.yml diff --git a/plugins/modules/aci_bfd_multihop_interface_profile.py b/plugins/modules/aci_bfd_multihop_interface_profile.py new file mode 100644 index 000000000..c9866d3ad --- /dev/null +++ b/plugins/modules/aci_bfd_multihop_interface_profile.py @@ -0,0 +1,309 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2023, Anvitha Jain (@anvjain) +# 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": "community"} + +DOCUMENTATION = r""" +--- +module: aci_bfd_multihop_interface_profile +short_description: Manage BFD Multihop Interface profile. +description: +- Manage BFD Multihop Interface profile (bfdMhIfP) configuration on Cisco ACI fabrics. +- Only available in APIC version 5.2 or later. +options: + tenant: + description: + - Name of an existing tenant. + type: str + l3out: + description: + - Name of an existing L3Out. + type: str + l3out_logical_node_profile: + description: + - Name of an existing L3Out Logical Node profile. + type: str + aliases: [ logical_node_profile, logical_node_profile_name ] + l3out_logical_interface_profile: + description: + - Name of an existing L3Out Logical Interface profile. + type: str + aliases: [ logical_interface_profile, logical_interface_profile_name ] + name: + description: + - Name of the BFD Multihop Interface Profile object. + type: str + aliases: [ bfd_multihop_interface_profile ] + name_alias: + description: + - Name Alias of the BFD Multihop Interface Profile object. + type: str + description: + description: + - Description of the BFD Multihop Interface Profile object. + type: str + interface_profile_type: + description: + - Authentication Type of the BFD Multihop Interface Profile object. + type: str + choices: [ none, sha1 ] + default: none + key: + description: + - Authentication Key of the BFD Multihop Interface Profile object. + type: str + key_id: + description: + - Authentication Key ID of the BFD Multihop Interface Profile object. + - Allowed range is 1-255 + type: int + default: 3 + bfd_multihop_interface_policy: + description: + - The name of the BFD Multihop Interface policy. + type: str + aliases: [ multihop_interface_policy, multihop_interface_policy_name ] + 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 + +notes: +- The C(tenant), c(l3out), C(l3out_logical_node_profile) and C(l3out_logical_interface_profile) must exist before using this module in your playbook. + The M(cisco.aci.aci_tenant) modules can be used for this. +seealso: +- name: APIC Management Information Model reference + description: More information about the internal APIC class B(bfdMhIfP). + link: https://developer.cisco.com/docs/apic-mim-ref/ +author: +- Anvitha Jain (@anvjain) +""" + +EXAMPLES = r""" +""" +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 + + +def main(): + argument_spec = aci_argument_spec() + argument_spec.update(aci_annotation_spec()) + argument_spec.update( + tenant=dict(type="str", aliases=["tenant_name"]), + l3out=dict(type="str", aliases=["l3out_name"]), + l3out_logical_node_profile=dict(type="str", aliases=["logical_node_profile_name", "logical_node_profile"]), + l3out_logical_interface_profile=dict(type="str", aliases=["logical_interface_profile_name", "logical_interface_profile"]), + name=dict(type="str", aliases=["bfd_multihop_interface_profile"]), + name_alias=dict(type="str"), + description=dict(type="str", aliases=["descr"]), + interface_profile_type=dict(type="str", default="none", choices=["none", "sha1"]), + key=dict(type="str"), + key_id=dict(type="int", default=3), + bfd_multihop_interface_policy=dict(type="str", aliases=["multihop_interface_policy", "multihop_interface_policy_name"]), + state=dict(type="str", default="present", choices=["absent", "present", "query"]), + ) + + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + required_if=[ + ["state", "absent", ["tenant", "l3out", "l3out_logical_node_profile", "l3out_logical_interface_profile"]], + ["state", "present", ["tenant", "l3out", "l3out_logical_node_profile", "l3out_logical_interface_profile"]], + ], + ) + + tenant = module.params.get("tenant") + l3out = module.params.get("l3out") + l3out_logical_node_profile = module.params.get("l3out_logical_node_profile") + l3out_logical_interface_profile = module.params.get("l3out_logical_interface_profile") + name = module.params.get("name") + name_alias = module.params.get("name_alias") + description = module.params.get("description") + interface_profile_type = module.params.get("interface_profile_type") + key = module.params.get("key") + key_id = module.params.get("key_id") + bfd_multihop_interface_policy = module.params.get("bfd_multihop_interface_policy") + state = module.params.get("state") + + aci = ACIModule(module) + aci.stdout = str("CHECK MODE: ") + str(bfd_multihop_interface_policy) + aci.construct_url( + root_class=dict( + aci_class="fvTenant", + aci_rn="tn-{0}".format(tenant), + module_object=tenant, + target_filter={"name": tenant}, + ), + subclass_1=dict( + aci_class="l3extOut", + aci_rn="out-{0}".format(l3out), + module_object=l3out, + target_filter={"name": l3out}, + ), + subclass_2=dict( + aci_class="l3extLNodeP", + aci_rn="lnodep-{0}".format(l3out_logical_node_profile), + module_object=l3out_logical_node_profile, + target_filter={"name": l3out_logical_node_profile}, + ), + subclass_3=dict( + aci_class="l3extLIfP", + aci_rn="lifp-{0}".format(l3out_logical_interface_profile), + module_object=l3out_logical_interface_profile, + target_filter={"name": l3out_logical_interface_profile}, + ), + subclass_4=dict( + aci_class="bfdMhIfP", + aci_rn="bfdMhIfP", + module_object="bfdMhIfP", + target_filter={"name": ""}, + ), + child_classes=["bfdMhIfPol"], + ) + + aci.get_existing() + + if state == "present": + aci.payload( + aci_class="bfdMhIfP", + class_config=dict( + name=name, + nameAlias=name_alias, + descr=description, + type=interface_profile_type, + key=key, + keyId=key_id, + ), + child_configs=[dict(bfdRsMhIfPol=dict(attributes=dict(tnBfdMhIfPolName=bfd_multihop_interface_policy)))], + ) + + aci.get_diff(aci_class="bfdMhIfP") + + aci.post_config() + + elif state == "absent": + aci.delete_config() + + aci.exit_json() + + +if __name__ == "__main__": + main() diff --git a/tests/integration/targets/aci_bfd_multihop_interface_profile/aliases b/tests/integration/targets/aci_bfd_multihop_interface_profile/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/tests/integration/targets/aci_bfd_multihop_interface_profile/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/tests/integration/targets/aci_bfd_multihop_interface_profile/tasks/main.yml b/tests/integration/targets/aci_bfd_multihop_interface_profile/tasks/main.yml new file mode 100644 index 000000000..1cf3218c5 --- /dev/null +++ b/tests/integration/targets/aci_bfd_multihop_interface_profile/tasks/main.yml @@ -0,0 +1,174 @@ +# Test code for the ACI modules +# Copyright: (c) 2023, Anvitha Jain (@anvjain) + +# 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 + +- 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: debug + +- name: Query system information + cisco.aci.aci_system: + <<: *aci_info + id: 1 + state: query + register: version + +- name: Execute tasks only for non-cloud sites + when: version.current.0.topSystem.attributes.version is version('5.2', '>=') # This condition will execute only when APIC version >= 5.2 + block: # block specifies execution of tasks within, based on conditions + + # CLEAN ENVIRONMENT + - name: Remove the ansible_tenant + aci_tenant: + <<: *aci_info + tenant: ansible_tenant + state: absent + + # Add a tenant + - name: Add a new tenant + aci_tenant: + <<: *aci_info + tenant: ansible_tenant + description: Ansible tenant + state: present + + # Add VRF + - name: Add a new VRF + aci_vrf: + <<: *aci_info + tenant: ansible_tenant + name: ansible_vrf + description: Ansible VRF + state: present + + # Add L3Out + - name: Add a new L3 Outside + aci_l3out: + <<: *aci_info + tenant: ansible_tenant + name: ansible_l3out + description: Ansible L3 Outside + domain: ansible_dom + vrf: ansible_vrf + l3protocol: bgp + state: present + + # ADD l3out logical node profile + - name: l3out logical node profile + aci_l3out_logical_node_profile: + <<: *aci_info + tenant: ansible_tenant + l3out: ansible_l3out + node_profile: ansible_node_profile + state: present + + # ADD l3out logical interface profile + - name: l3out logical interface profile + aci_l3out_logical_interface_profile: + <<: *aci_info + tenant: ansible_tenant + l3out: ansible_l3out + node_profile: ansible_node_profile + interface_profile: ansible_interface_profile + state: present + + # Add BFD Multihop Interface Profile + - name: Add a new BFD Multihop Interface Profile - check mode + aci_bfd_multihop_interface_profile: &present_bfd_mh_int_profile + <<: *aci_info + tenant: ansible_tenant + l3out: ansible_l3out + l3out_logical_node_profile: ansible_node_profile + l3out_logical_interface_profile: ansible_interface_profile + state: present + check_mode: true + register: cm_add_bfd_mh_int_prof + + - name: Add a new BFD Multihop Interface Profile - normal mode + aci_bfd_multihop_interface_profile: + <<: *present_bfd_mh_int_profile + state: present + register: nm_add_bfd_mh_int_prof + + - name: Verify adding BFD Multihop Interface Profile + assert: + that: + - cm_add_bfd_mh_int_prof is changed + - nm_add_bfd_mh_int_prof is changed + - cm_add_bfd_mh_int_prof.previous == nm_add_bfd_mh_int_prof.previous == [] + - cm_add_bfd_mh_int_prof.proposed.bfdMhIfP.attributes.dn == nm_add_bfd_mh_int_prof.proposed.bfdMhIfP.attributes.dn == "uni/tn-ansible_tenant/out-ansible_l3out/lnodep-ansible_node_profile/lifp-ansible_interface_profile/bfdMhIfP" + - cm_add_bfd_mh_int_prof.proposed.bfdMhIfP.attributes.keyId == nm_add_bfd_mh_int_prof.proposed.bfdMhIfP.attributes.keyId == "3" + - cm_add_bfd_mh_int_prof.proposed.bfdMhIfP.attributes.type == nm_add_bfd_mh_int_prof.proposed.bfdMhIfP.attributes.type == "none" + + - name: Add BFD Multihop Interface Profile again- idempotency + aci_bfd_multihop_interface_profile: + <<: *present_bfd_mh_int_profile + state: present + register: add_bfd_mh_int_prof_again + + - name: Verify adding BFD Multihop Interface Profile again - idempotency + assert: + that: + - add_bfd_mh_int_prof_again is not changed + + # CREATE BFD Multihop Interface policy + - name: Add a new BFD Multihop Interface policy + cisco.aci.aci_bfd_multihop_interface_policy: + <<: *aci_info + tenant: ansible_tenant + name: ansible_bfd_multihop_interface_policy + description: Ansible BFD Multihop Interface Policy + state: present + register: cm_add_bfd_multihop_interface_pol + + # Update BFD Multihop Interface Profile + - name: Update BFD Multihop Interface Profile + aci_bfd_multihop_interface_profile: + <<: *present_bfd_mh_int_profile + interface_profile_type: sha1 + key: "abc*123" + key_id: 15 + bfd_multihop_interface_policy: ansible_bfd_multihop_interface_policy + state: present + register: update_bfd_mh_int_prof + + - name: Verify updating BFD Multihop Interface Profile + assert: + that: + - update_bfd_mh_int_prof is changed + - update_bfd_mh_int_prof.sent.bfdMhIfP.attributes.keyId == "15" + - update_bfd_mh_int_prof.sent.bfdMhIfP.attributes.key == "abc*123" + - update_bfd_mh_int_prof.sent.bfdMhIfP.attributes.type == "sha1" + - update_bfd_mh_int_prof.sent.bfdMhIfP.children.0.bfdRsMhIfPol.attributes.tnBfdMhIfPolName == "ansible_bfd_multihop_interface_policy" + + - name: Query BFD Multihop Interface Profile + aci_bfd_multihop_interface_profile: + <<: *present_bfd_mh_int_profile + state: query + register: query_bfd_mh_int_prof + + - name: Query all BFD Multihop Interface Profile + aci_bfd_multihop_interface_profile: + <<: *aci_info + state: query + register: query_all_bfd_mh_int_prof + + - name: Delete BFD Multihop Interface Profile - check mode + aci_bfd_multihop_interface_profile: + <<: *present_bfd_mh_int_profile + state: absent + check_mode: true + register: cm_remove_bfd_mh_int_prof \ No newline at end of file From 522293b745316345a9d9a8a1cd5602871c92a177 Mon Sep 17 00:00:00 2001 From: anvitha-jain Date: Fri, 3 Nov 2023 00:26:55 -0700 Subject: [PATCH 04/10] [minor_changes] Added ACI L3out BFD Interface profile and other modules which are required. --- plugins/modules/aci_bfd_interface_policy.py | 314 ++++++++++++++++ .../aci_bfd_multihop_interface_policy.py | 6 +- .../aci_bfd_multihop_interface_profile.py | 42 ++- .../modules/aci_bfd_multihop_node_policy.py | 4 +- .../aci_l3out_bfd_interface_profile.py | 348 ++++++++++++++++++ .../targets/aci_bfd_interface_policy/aliases | 2 + .../aci_bfd_interface_policy/tasks/main.yml | 229 ++++++++++++ .../tasks/main.yml | 48 +++ .../tasks/main.yml | 28 +- .../tasks/main.yml | 48 +++ .../aci_l3out_bfd_interface_profile/aliases | 2 + .../tasks/main.yml | 174 +++++++++ 12 files changed, 1227 insertions(+), 18 deletions(-) create mode 100644 plugins/modules/aci_bfd_interface_policy.py create mode 100644 plugins/modules/aci_l3out_bfd_interface_profile.py create mode 100644 tests/integration/targets/aci_bfd_interface_policy/aliases create mode 100644 tests/integration/targets/aci_bfd_interface_policy/tasks/main.yml create mode 100644 tests/integration/targets/aci_l3out_bfd_interface_profile/aliases create mode 100644 tests/integration/targets/aci_l3out_bfd_interface_profile/tasks/main.yml diff --git a/plugins/modules/aci_bfd_interface_policy.py b/plugins/modules/aci_bfd_interface_policy.py new file mode 100644 index 000000000..4afb3df77 --- /dev/null +++ b/plugins/modules/aci_bfd_interface_policy.py @@ -0,0 +1,314 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2023, Anvitha Jain (@anvjain) +# 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": "community"} + +DOCUMENTATION = r""" +--- +module: aci_bfd_interface_policy +short_description: Manage BFD Interface policies. +description: +- Manage BFD Interface policy (bfdMhIfPol) configuration on Cisco ACI fabrics. +- Only available in APIC version 5.2 or later. +options: + tenant: + description: + - Name of an existing tenant. + type: str + name: + description: + - Name of the BFD Interface policy + type: str + aliases: [ bfd_multihop_interface_policy ] + description: + description: + - Description of the BFD Interface policy + type: str + admin_state: + description: + - Admin state of the BFD Interface policy + type: str + choices: [ enabled, disabled ] + default: enabled + detection_multiplier: + description: + - Detection multiplier of the BFD Interface policy + - Allowed range is 1-50. + type: int + default: 3 + min_transmit_interval: + description: + - Minimum transmit (Tx) interval of the BFD Interface policy + - Allowed range is 250-999. + type: int + default: 250 + min_receive_interval: + description: + - Minimum receive (Rx) interval of the BFD Interface policy + - Allowed range is 250-999. + type: int + default: 250 + 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 + +notes: +- The C(tenant) must exist before using this module in your playbook. + The M(cisco.aci.aci_tenant) modules can be used for this. +seealso: +- name: APIC Management Information Model reference + description: More information about the internal APIC class B(bfdMhIfPol). + link: https://developer.cisco.com/docs/apic-mim-ref/ +author: +- Anvitha Jain (@anvjain) +""" + +EXAMPLES = r""" +- name: Add a new BFD Interface policy + cisco.aci.aci_bfd_interface_policy: + host: apic + username: admin + password: SomeSecretPassword + tenant: ansible_tenant + name: ansible_bfd_interface_policy + description: Ansible BFD Interface Policy + state: present + state: present + delegate_to: localhost + +- name: Remove a BFD Interface policy + cisco.aci.aci_bfd_interface_policy: + host: apic + username: admin + password: SomeSecretPassword + tenant: ansible_tenant + name: ansible_bfd_interface_policy + state: absent + delegate_to: localhost + +- name: Query a BFD Interface policy + cisco.aci.aci_bfd_interface_policy: + host: apic + username: admin + password: SomeSecretPassword + tenant: ansible_tenant + name: ansible_bfd_interface_policy + state: query + delegate_to: localhost + register: query_result + +- name: Query all BFD Interface policies in a specific tenant + cisco.aci.aci_bfd_interface_policy: + host: apic + username: admin + password: SomeSecretPassword + tenant: ansible_tenant + state: query + delegate_to: localhost + register: query_result +""" + +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 + + +def main(): + argument_spec = aci_argument_spec() + argument_spec.update(aci_annotation_spec()) + argument_spec.update( + name=dict(type="str", aliases=["bfd_interface_policy"]), + description=dict(type="str"), + admin_state=dict(type="str", default="enabled", choices=["enabled", "disabled"]), + detection_multiplier=dict(type="int", default=3), + min_transmit_interval=dict(type="int", default=50), + min_receive_interval=dict(type="int", default=50), + state=dict(type="str", default="present", choices=["absent", "present", "query"]), + tenant=dict(type="str"), + ) + + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + required_if=[ + ["state", "absent", ["name", "tenant"]], + ["state", "present", ["name", "tenant"]], + ], + ) + + name = module.params.get("name") + description = module.params.get("description") + state = module.params.get("state") + tenant = module.params.get("tenant") + admin_state = module.params.get("admin_state") + detection_multiplier = module.params.get("detection_multiplier") + if detection_multiplier is not None and detection_multiplier not in range(1, 50): + module.fail_json(msg='The "detection_multiplier" must be a value between 1 and 50') + min_transmit_interval = module.params.get("min_transmit_interval") + if min_transmit_interval is not None and min_transmit_interval not in range(50, 999): + module.fail_json(msg='The "min_transmit_interval" must be a value between 50 and 999') + min_receive_interval = module.params.get("min_receive_interval") + if min_receive_interval is not None and min_receive_interval not in range(50, 999): + module.fail_json(msg='The "min_receive_interval" must be a value between 50 and 999') + + aci = ACIModule(module) + aci.construct_url( + root_class=dict( + aci_class="fvTenant", + aci_rn="tn-{0}".format(tenant), + module_object=tenant, + target_filter={"name": tenant}, + ), + subclass_1=dict( + aci_class="bfdIfPol", + aci_rn="bfdIfPol-{0}".format(name), + module_object=name, + target_filter={"name": name}, + ), + ) + + aci.get_existing() + + if state == "present": + aci.payload( + aci_class="bfdIfPol", + class_config=dict( + name=name, + descr=description, + adminSt=admin_state, + detectMult=detection_multiplier, + minTxIntvl=min_transmit_interval, + minRxIntvl=min_receive_interval, + ), + ) + + aci.get_diff(aci_class="bfdIfPol") + + aci.post_config() + + elif state == "absent": + aci.delete_config() + + aci.exit_json() + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/aci_bfd_multihop_interface_policy.py b/plugins/modules/aci_bfd_multihop_interface_policy.py index 64df9d10a..8dab45fcc 100644 --- a/plugins/modules/aci_bfd_multihop_interface_policy.py +++ b/plugins/modules/aci_bfd_multihop_interface_policy.py @@ -40,6 +40,7 @@ detection_multiplier: description: - Detection multiplier of the BFD Multihop Interface policy + - Allowed range is 1-50. type: int default: 3 min_transmit_interval: @@ -105,7 +106,7 @@ username: admin password: SomeSecretPassword tenant: ansible_tenant - name: my_dhcp_relay + name: ansible_bfd_multihop_interface_policy state: query delegate_to: localhost register: query_result @@ -295,7 +296,8 @@ def main(): adminSt=admin_state, detectMult=detection_multiplier, minTxIntvl=min_transmit_interval, - minRxIntvl=min_receive_interval), + minRxIntvl=min_receive_interval, + ), ) aci.get_diff(aci_class="bfdMhIfPol") diff --git a/plugins/modules/aci_bfd_multihop_interface_profile.py b/plugins/modules/aci_bfd_multihop_interface_profile.py index c9866d3ad..aec0faa1e 100644 --- a/plugins/modules/aci_bfd_multihop_interface_profile.py +++ b/plugins/modules/aci_bfd_multihop_interface_profile.py @@ -66,7 +66,7 @@ type: int default: 3 bfd_multihop_interface_policy: - description: + description: - The name of the BFD Multihop Interface policy. type: str aliases: [ multihop_interface_policy, multihop_interface_policy_name ] @@ -93,7 +93,47 @@ """ EXAMPLES = r""" +- name: Add a new L3Out BFD Multihop Interface Profile + cisco.aci.aci_bfd_multihop_interface_profile: + username: admin + password: SomeSecretPassword + tenant: ansible_tenant + l3out: ansible_l3out + l3out_logical_node_profile: ansible_node_profile + l3out_logical_interface_profile: ansible_interface_profile + state: present + delegate_to: localhost + +- name: Query a new L3Out BFD Multihop Interface Profile + cisco.aci.aci_bfd_multihop_interface_profile: + username: admin + password: SomeSecretPassword + tenant: ansible_tenant + l3out: ansible_l3out + l3out_logical_node_profile: ansible_node_profile + l3out_logical_interface_profile: ansible_interface_profile + state: query + delegate_to: localhost + +- name: Query all L3Out BFD Multihop Interface Profile + cisco.aci.aci_bfd_multihop_interface_profile: + username: admin + password: SomeSecretPassword + state: query + delegate_to: localhost + +- name: Delete L3Out BFD Multihop Interface Profile + cisco.aci.aci_bfd_multihop_interface_profile: + username: admin + password: SomeSecretPassword + tenant: ansible_tenant + l3out: ansible_l3out + l3out_logical_node_profile: ansible_node_profile + l3out_logical_interface_profile: ansible_interface_profile + state: absent + delegate_to: localhost """ + RETURN = r""" current: description: The existing configuration from the APIC after the module has finished diff --git a/plugins/modules/aci_bfd_multihop_node_policy.py b/plugins/modules/aci_bfd_multihop_node_policy.py index dd1ae2620..f15eac081 100644 --- a/plugins/modules/aci_bfd_multihop_node_policy.py +++ b/plugins/modules/aci_bfd_multihop_node_policy.py @@ -40,6 +40,7 @@ detection_multiplier: description: - Detection multiplier of the BFD Multihop Node policy + - Allowed range is 1-50. type: int default: 3 min_transmit_interval: @@ -295,7 +296,8 @@ def main(): adminSt=admin_state, detectMult=detection_multiplier, minTxIntvl=min_transmit_interval, - minRxIntvl=min_receive_interval), + minRxIntvl=min_receive_interval, + ), ) aci.get_diff(aci_class="bfdMhNodePol") diff --git a/plugins/modules/aci_l3out_bfd_interface_profile.py b/plugins/modules/aci_l3out_bfd_interface_profile.py new file mode 100644 index 000000000..6eadbbfd8 --- /dev/null +++ b/plugins/modules/aci_l3out_bfd_interface_profile.py @@ -0,0 +1,348 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2023, Anvitha Jain (@anvjain) +# 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": "community"} + +DOCUMENTATION = r""" +--- +module: aci_l3out_bfd_interface_profile +short_description: Manage L3Out BFD Interface profile. +description: +- Manage L3Out BFD Interface profile (bfdIfP) configuration on Cisco ACI fabrics. +- Only available in APIC version 5.2 or later. +options: + tenant: + description: + - Name of an existing tenant. + type: str + l3out: + description: + - Name of an existing L3Out. + type: str + l3out_logical_node_profile: + description: + - Name of an existing L3Out Logical Node profile. + type: str + aliases: [ logical_node_profile, logical_node_profile_name ] + l3out_logical_interface_profile: + description: + - Name of an existing L3Out Logical Interface profile. + type: str + aliases: [ logical_interface_profile, logical_interface_profile_name ] + name: + description: + - Name of the L3Out BFD Interface profile object. + type: str + aliases: [ bfd_multihop_interface_profile ] + name_alias: + description: + - Name Alias of the L3Out BFD Interface profile object. + type: str + description: + description: + - Description of the L3Out BFD Interface profile object. + type: str + interface_profile_type: + description: + - Authentication Type of the L3Out BFD Interface profile object. + type: str + choices: [ none, sha1 ] + default: none + key: + description: + - Authentication Key of the L3Out BFD Interface profile object. + type: str + key_id: + description: + - Authentication Key ID of the L3Out BFD Interface profile object. + - Allowed range is 1-255 + type: int + default: 3 + bfd_interface_policy: + description: + - The name of the Interface policy. + type: str + aliases: [ interface_policy, interface_policy_name ] + 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 + +notes: +- The C(tenant), c(l3out), C(l3out_logical_node_profile) and C(l3out_logical_interface_profile) must exist before using this module in your playbook. + The M(cisco.aci.aci_tenant) modules can be used for this. +seealso: +- name: APIC Management Information Model reference + description: More information about the internal APIC class B(bfdIfP). + link: https://developer.cisco.com/docs/apic-mim-ref/ +author: +- Anvitha Jain (@anvjain) +""" + +EXAMPLES = r""" +- name: Add a new L3Out BFD Interface Profile + cisco.aci.aci_l3out_bfd_interface_profile: + username: admin + password: SomeSecretPassword + tenant: ansible_tenant + l3out: ansible_l3out + l3out_logical_node_profile: ansible_node_profile + l3out_logical_interface_profile: ansible_interface_profile + state: present + delegate_to: localhost + +- name: Query a new L3Out BFD Interface Profile + cisco.aci.aci_l3out_bfd_interface_profile: + username: admin + password: SomeSecretPassword + tenant: ansible_tenant + l3out: ansible_l3out + l3out_logical_node_profile: ansible_node_profile + l3out_logical_interface_profile: ansible_interface_profile + state: query + delegate_to: localhost + +- name: Query all L3Out BFD Interface Profile + cisco.aci.aci_l3out_bfd_interface_profile: + username: admin + password: SomeSecretPassword + state: query + delegate_to: localhost + +- name: Delete L3Out BFD Interface Profile + cisco.aci.aci_l3out_bfd_interface_profile: + username: admin + password: SomeSecretPassword + tenant: ansible_tenant + l3out: ansible_l3out + l3out_logical_node_profile: ansible_node_profile + l3out_logical_interface_profile: ansible_interface_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 + + +def main(): + argument_spec = aci_argument_spec() + argument_spec.update(aci_annotation_spec()) + argument_spec.update( + tenant=dict(type="str", aliases=["tenant_name"]), + l3out=dict(type="str", aliases=["l3out_name"]), + l3out_logical_node_profile=dict(type="str", aliases=["logical_node_profile_name", "logical_node_profile"]), + l3out_logical_interface_profile=dict(type="str", aliases=["logical_interface_profile_name", "logical_interface_profile"]), + name=dict(type="str", aliases=["bfd_multihop_interface_profile"]), + name_alias=dict(type="str"), + description=dict(type="str", aliases=["descr"]), + interface_profile_type=dict(type="str", default="none", choices=["none", "sha1"]), + key=dict(type="str"), + key_id=dict(type="int", default=3), + bfd_interface_policy=dict(type="str", aliases=["interface_policy", "interface_policy_name"]), + state=dict(type="str", default="present", choices=["absent", "present", "query"]), + ) + + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + required_if=[ + ["state", "absent", ["tenant", "l3out", "l3out_logical_node_profile", "l3out_logical_interface_profile"]], + ["state", "present", ["tenant", "l3out", "l3out_logical_node_profile", "l3out_logical_interface_profile"]], + ], + ) + + tenant = module.params.get("tenant") + l3out = module.params.get("l3out") + l3out_logical_node_profile = module.params.get("l3out_logical_node_profile") + l3out_logical_interface_profile = module.params.get("l3out_logical_interface_profile") + name = module.params.get("name") + name_alias = module.params.get("name_alias") + description = module.params.get("description") + interface_profile_type = module.params.get("interface_profile_type") + key = module.params.get("key") + key_id = module.params.get("key_id") + bfd_interface_policy = module.params.get("bfd_interface_policy") + state = module.params.get("state") + + aci = ACIModule(module) + aci.construct_url( + root_class=dict( + aci_class="fvTenant", + aci_rn="tn-{0}".format(tenant), + module_object=tenant, + target_filter={"name": tenant}, + ), + subclass_1=dict( + aci_class="l3extOut", + aci_rn="out-{0}".format(l3out), + module_object=l3out, + target_filter={"name": l3out}, + ), + subclass_2=dict( + aci_class="l3extLNodeP", + aci_rn="lnodep-{0}".format(l3out_logical_node_profile), + module_object=l3out_logical_node_profile, + target_filter={"name": l3out_logical_node_profile}, + ), + subclass_3=dict( + aci_class="l3extLIfP", + aci_rn="lifp-{0}".format(l3out_logical_interface_profile), + module_object=l3out_logical_interface_profile, + target_filter={"name": l3out_logical_interface_profile}, + ), + subclass_4=dict( + aci_class="bfdIfP", + aci_rn="bfdIfP", + module_object="bfdIfP", + target_filter={"name": ""}, + ), + child_classes=["bfdRsIfPol"], + ) + + aci.get_existing() + + if state == "present": + aci.payload( + aci_class="bfdIfP", + class_config=dict( + name=name, + nameAlias=name_alias, + descr=description, + type=interface_profile_type, + key=key, + keyId=key_id, + ), + child_configs=[dict(bfdRsIfPol=dict(attributes=dict(tnBfdIfPolName=bfd_interface_policy)))], + ) + + aci.get_diff(aci_class="bfdIfP") + + aci.post_config() + + elif state == "absent": + aci.delete_config() + + aci.exit_json() + + +if __name__ == "__main__": + main() diff --git a/tests/integration/targets/aci_bfd_interface_policy/aliases b/tests/integration/targets/aci_bfd_interface_policy/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/tests/integration/targets/aci_bfd_interface_policy/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/tests/integration/targets/aci_bfd_interface_policy/tasks/main.yml b/tests/integration/targets/aci_bfd_interface_policy/tasks/main.yml new file mode 100644 index 000000000..21f659f91 --- /dev/null +++ b/tests/integration/targets/aci_bfd_interface_policy/tasks/main.yml @@ -0,0 +1,229 @@ +# Test code for the ACI modules +# Copyright: (c) 2023, Anvitha Jain (@anvjain) + +# 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 + +- 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: debug + +- name: Query system information + cisco.aci.aci_system: + <<: *aci_info + id: 1 + state: query + register: version + +- name: Execute tasks only for non-cloud sites + when: version.current.0.topSystem.attributes.version is version('5.2', '>=') # This condition will execute only when APIC version >= 5.2 + block: # block specifies execution of tasks within, based on conditions + + # CLEAN ENVIRONMENT + - name: Remove the ansible_tenant + aci_tenant: + <<: *aci_info + tenant: ansible_tenant + state: absent + + - name: Add a new tenant + aci_tenant: + <<: *aci_info + tenant: ansible_tenant + description: Ansible tenant + state: present + + # CREATE BFD Interface policy + - name: Add a new BFD Interface policy - check mode + cisco.aci.aci_bfd_interface_policy: &add_bfd_interface_pol + <<: *aci_info + tenant: ansible_tenant + name: ansible_bfd_interface_policy + description: Ansible BFD Interface Policy + state: present + check_mode: true + register: cm_add_bfd_interface_pol + + - name: Add a new BFD Interface policy - normal mode + cisco.aci.aci_bfd_interface_policy: + <<: *add_bfd_interface_pol + state: present + register: nm_add_bfd_interface_pol + + - name: Verify BFD Interface Policy creation + assert: + that: + - cm_add_bfd_interface_pol is changed + - nm_add_bfd_interface_pol is changed + - cm_add_bfd_interface_pol.previous == nm_add_bfd_interface_pol.previous == [] + - nm_add_bfd_interface_pol.current.0.bfdIfPol.attributes.dn == "uni/tn-ansible_tenant/bfdIfPol-ansible_bfd_interface_policy" + - nm_add_bfd_interface_pol.current.0.bfdIfPol.attributes.name == "ansible_bfd_interface_policy" + - nm_add_bfd_interface_pol.current.0.bfdIfPol.attributes.descr == "Ansible BFD Interface Policy" + - nm_add_bfd_interface_pol.current.0.bfdIfPol.attributes.adminSt == "enabled" + - nm_add_bfd_interface_pol.current.0.bfdIfPol.attributes.detectMult == "3" + - nm_add_bfd_interface_pol.current.0.bfdIfPol.attributes.minRxIntvl == "50" + - nm_add_bfd_interface_pol.current.0.bfdIfPol.attributes.minTxIntvl == "50" + + - name: Add a new BFD Interface policy again - idempotency + cisco.aci.aci_bfd_interface_policy: + <<: *add_bfd_interface_pol + state: present + register: add_bfd_interface_pol_again + + - name: Verify BFD Interface Policy creation again - idempotency + assert: + that: + - add_bfd_interface_pol_again is not changed + - add_bfd_interface_pol_again.previous != [] + - add_bfd_interface_pol_again.current | length == 1 + - add_bfd_interface_pol_again.previous | length == 1 + + - name: Modify a BFD Interface policy + cisco.aci.aci_bfd_interface_policy: + <<: *add_bfd_interface_pol + admin_state: disabled + detection_multiplier: 5 + min_transmit_interval: 270 + min_receive_interval: 500 + state: present + register: update_bfd_interface_pol + + - name: Verify modifying BFD Interface Policy + assert: + that: + - update_bfd_interface_pol is changed + - update_bfd_interface_pol.previous != update_bfd_interface_pol.current + - update_bfd_interface_pol.current.0.bfdIfPol.attributes.dn == "uni/tn-ansible_tenant/bfdIfPol-ansible_bfd_interface_policy" + - update_bfd_interface_pol.current.0.bfdIfPol.attributes.name == "ansible_bfd_interface_policy" + - update_bfd_interface_pol.current.0.bfdIfPol.attributes.descr == "Ansible BFD Interface Policy" + - update_bfd_interface_pol.current.0.bfdIfPol.attributes.adminSt == "disabled" + - update_bfd_interface_pol.current.0.bfdIfPol.attributes.detectMult == "5" + - update_bfd_interface_pol.current.0.bfdIfPol.attributes.minRxIntvl == "500" + - update_bfd_interface_pol.current.0.bfdIfPol.attributes.minTxIntvl == "270" + + # Added another BFD Interface policy + - name: Add a new BFD Interface policy - normal mode + cisco.aci.aci_bfd_interface_policy: + <<: *add_bfd_interface_pol + name: ansible_bfd_interface_policy_2 + state: present + register: add_bfd_interface_pol_2 + + - name: Verify BFD Interface Policy creation + assert: + that: + - add_bfd_interface_pol_2 is changed + - add_bfd_interface_pol_2.previous == [] + - add_bfd_interface_pol_2.current.0.bfdIfPol.attributes.dn == "uni/tn-ansible_tenant/bfdIfPol-ansible_bfd_interface_policy_2" + - add_bfd_interface_pol_2.current.0.bfdIfPol.attributes.name == "ansible_bfd_interface_policy_2" + - add_bfd_interface_pol_2.current.0.bfdIfPol.attributes.descr == "Ansible BFD Interface Policy" + - add_bfd_interface_pol_2.current.0.bfdIfPol.attributes.adminSt == "enabled" + - add_bfd_interface_pol_2.current.0.bfdIfPol.attributes.detectMult == "3" + - add_bfd_interface_pol_2.current.0.bfdIfPol.attributes.minRxIntvl == "50" + - add_bfd_interface_pol_2.current.0.bfdIfPol.attributes.minTxIntvl == "50" + + - name: Query all BFD Interface policies in a specific tenant + cisco.aci.aci_bfd_interface_policy: + <<: *aci_info + tenant: ansible_tenant + state: query + register: query_all_result + + - name: Verify querying all BFD Interface Policies + assert: + that: + - query_all_result is not changed + - query_all_result.current.0.fvTenant.children | length == 2 + - query_all_result.current.0.fvTenant.children[0].bfdIfPol.attributes.name == "ansible_bfd_interface_policy_2" + - query_all_result.current.0.fvTenant.children[1].bfdIfPol.attributes.name == "ansible_bfd_interface_policy" + + - name: Query 'ansible_bfd_interface_policy' BFD Interface policies in a specific tenant + cisco.aci.aci_bfd_interface_policy: + <<: *aci_info + tenant: ansible_tenant + name: ansible_bfd_interface_policy + state: query + register: query_result + + - name: Verify querying'ansible_bfd_interface_policy BFD' Multihop Interface Policy + assert: + that: + - query_result is not changed + - query_result.current.0.bfdIfPol.attributes.dn == "uni/tn-ansible_tenant/bfdIfPol-ansible_bfd_interface_policy" + - query_result.current.0.bfdIfPol.attributes.name == "ansible_bfd_interface_policy" + + - name: Remove a BFD Interface policy + cisco.aci.aci_bfd_interface_policy: + <<: *aci_info + tenant: ansible_tenant + name: ansible_bfd_interface_policy + state: absent + register: remove_bfd_interface_pol + + - name: Verify removing BFD Interface Policies + assert: + that: + - remove_bfd_interface_pol is changed + - remove_bfd_interface_pol.previous != [] + - remove_bfd_interface_pol.current == [] + +# Validating out of rage parameters. + +# Added BFD Interface policy with out of the range detection_multiplier + - name: Add a new BFD Interface policy - out of the range detection_multiplier + cisco.aci.aci_bfd_interface_policy: + <<: *add_bfd_interface_pol + name: ansible_bfd_interface_policy_3 + detection_multiplier: 256 + state: present + ignore_errors: true + register: add_bfd_interface_pol_3 + + - name: Verify BFD Interface Policy creation + assert: + that: + - add_bfd_interface_pol_3 is not changed + - add_bfd_interface_pol_3.msg == "The \"detection_multiplier\" must be a value between 1 and 50" + +# Added BFD Interface policy with out of the range min_transmit_interval + - name: Add a new BFD Interface policy - out of the range min_transmit_interval + cisco.aci.aci_bfd_interface_policy: + <<: *add_bfd_interface_pol + name: ansible_bfd_interface_policy_3 + min_transmit_interval: 10 + state: present + ignore_errors: true + register: add_bfd_interface_pol_3 + + - name: Verify BFD Interface Policy creation + assert: + that: + - add_bfd_interface_pol_3 is not changed + - add_bfd_interface_pol_3.msg == "The \"min_transmit_interval\" must be a value between 50 and 999" + +# Added BFD Interface policy with out of the range min_receive_interval + - name: Add a new BFD Interface policy - out of the range min_receive_interval + cisco.aci.aci_bfd_interface_policy: + <<: *add_bfd_interface_pol + name: ansible_bfd_interface_policy_3 + min_receive_interval: 1000 + state: present + ignore_errors: true + register: add_bfd_interface_pol_3 + + - name: Verify BFD Interface Policy creation + assert: + that: + - add_bfd_interface_pol_3 is not changed + - add_bfd_interface_pol_3.msg == "The \"min_receive_interval\" must be a value between 50 and 999" \ No newline at end of file diff --git a/tests/integration/targets/aci_bfd_multihop_interface_policy/tasks/main.yml b/tests/integration/targets/aci_bfd_multihop_interface_policy/tasks/main.yml index bdd96d0fd..8e7be35a7 100644 --- a/tests/integration/targets/aci_bfd_multihop_interface_policy/tasks/main.yml +++ b/tests/integration/targets/aci_bfd_multihop_interface_policy/tasks/main.yml @@ -178,4 +178,52 @@ - remove_bfd_multihop_interface_pol.previous != [] - remove_bfd_multihop_interface_pol.current == [] +# Validating out of rage parameters. +# Added BFD Multihop Interface policy with out of the range detection_multiplier + - name: Add a new BFD Multihop Interface policy - out of the range detection_multiplier + cisco.aci.aci_bfd_multihop_interface_policy: + <<: *add_bfd_multihop_interface_pol + name: ansible_bfd_multihop_interface_policy_3 + detection_multiplier: 256 + state: present + ignore_errors: true + register: add_bfd_multihop_interface_pol_3 + + - name: Verify BFD Multihop Interface Policy creation + assert: + that: + - add_bfd_multihop_interface_pol_3 is not changed + - add_bfd_multihop_interface_pol_3.msg == "The \"detection_multiplier\" must be a value between 1 and 50" + +# Added BFD Multihop Interface policy with out of the range min_transmit_interval + - name: Add a new BFD Multihop Interface policy - out of the range min_transmit_interval + cisco.aci.aci_bfd_multihop_interface_policy: + <<: *add_bfd_multihop_interface_pol + name: ansible_bfd_multihop_interface_policy_3 + min_transmit_interval: 50 + state: present + ignore_errors: true + register: add_bfd_multihop_interface_pol_3 + + - name: Verify BFD Multihop Interface Policy creation + assert: + that: + - add_bfd_multihop_interface_pol_3 is not changed + - add_bfd_multihop_interface_pol_3.msg == "The \"min_transmit_interval\" must be a value between 250 and 999" + +# Added BFD Multihop Interface policy with out of the range min_receive_interval + - name: Add a new BFD Multihop Interface policy - out of the range min_receive_interval + cisco.aci.aci_bfd_multihop_interface_policy: + <<: *add_bfd_multihop_interface_pol + name: ansible_bfd_multihop_interface_policy_3 + min_receive_interval: 1000 + state: present + ignore_errors: true + register: add_bfd_multihop_interface_pol_3 + + - name: Verify BFD Multihop Interface Policy creation + assert: + that: + - add_bfd_multihop_interface_pol_3 is not changed + - add_bfd_multihop_interface_pol_3.msg == "The \"min_receive_interval\" must be a value between 250 and 999" \ No newline at end of file diff --git a/tests/integration/targets/aci_bfd_multihop_interface_profile/tasks/main.yml b/tests/integration/targets/aci_bfd_multihop_interface_profile/tasks/main.yml index 1cf3218c5..1785e87da 100644 --- a/tests/integration/targets/aci_bfd_multihop_interface_profile/tasks/main.yml +++ b/tests/integration/targets/aci_bfd_multihop_interface_profile/tasks/main.yml @@ -32,14 +32,14 @@ # CLEAN ENVIRONMENT - name: Remove the ansible_tenant - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_info tenant: ansible_tenant state: absent # Add a tenant - name: Add a new tenant - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_info tenant: ansible_tenant description: Ansible tenant @@ -47,7 +47,7 @@ # Add VRF - name: Add a new VRF - aci_vrf: + cisco.aci.aci_vrf: <<: *aci_info tenant: ansible_tenant name: ansible_vrf @@ -56,7 +56,7 @@ # Add L3Out - name: Add a new L3 Outside - aci_l3out: + cisco.aci.aci_l3out: <<: *aci_info tenant: ansible_tenant name: ansible_l3out @@ -68,7 +68,7 @@ # ADD l3out logical node profile - name: l3out logical node profile - aci_l3out_logical_node_profile: + cisco.aci.aci_l3out_logical_node_profile: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -77,7 +77,7 @@ # ADD l3out logical interface profile - name: l3out logical interface profile - aci_l3out_logical_interface_profile: + cisco.aci.aci_l3out_logical_interface_profile: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -87,7 +87,7 @@ # Add BFD Multihop Interface Profile - name: Add a new BFD Multihop Interface Profile - check mode - aci_bfd_multihop_interface_profile: &present_bfd_mh_int_profile + cisco.aci.aci_bfd_multihop_interface_profile: &present_bfd_mh_int_profile <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -98,7 +98,7 @@ register: cm_add_bfd_mh_int_prof - name: Add a new BFD Multihop Interface Profile - normal mode - aci_bfd_multihop_interface_profile: + cisco.aci.aci_bfd_multihop_interface_profile: <<: *present_bfd_mh_int_profile state: present register: nm_add_bfd_mh_int_prof @@ -114,7 +114,7 @@ - cm_add_bfd_mh_int_prof.proposed.bfdMhIfP.attributes.type == nm_add_bfd_mh_int_prof.proposed.bfdMhIfP.attributes.type == "none" - name: Add BFD Multihop Interface Profile again- idempotency - aci_bfd_multihop_interface_profile: + cisco.aci.aci_bfd_multihop_interface_profile: <<: *present_bfd_mh_int_profile state: present register: add_bfd_mh_int_prof_again @@ -132,11 +132,11 @@ name: ansible_bfd_multihop_interface_policy description: Ansible BFD Multihop Interface Policy state: present - register: cm_add_bfd_multihop_interface_pol + register: add_bfd_multihop_interface_pol # Update BFD Multihop Interface Profile - name: Update BFD Multihop Interface Profile - aci_bfd_multihop_interface_profile: + cisco.aci.aci_bfd_multihop_interface_profile: <<: *present_bfd_mh_int_profile interface_profile_type: sha1 key: "abc*123" @@ -155,19 +155,19 @@ - update_bfd_mh_int_prof.sent.bfdMhIfP.children.0.bfdRsMhIfPol.attributes.tnBfdMhIfPolName == "ansible_bfd_multihop_interface_policy" - name: Query BFD Multihop Interface Profile - aci_bfd_multihop_interface_profile: + cisco.aci.aci_bfd_multihop_interface_profile: <<: *present_bfd_mh_int_profile state: query register: query_bfd_mh_int_prof - name: Query all BFD Multihop Interface Profile - aci_bfd_multihop_interface_profile: + cisco.aci.aci_bfd_multihop_interface_profile: <<: *aci_info state: query register: query_all_bfd_mh_int_prof - name: Delete BFD Multihop Interface Profile - check mode - aci_bfd_multihop_interface_profile: + cisco.aci.aci_bfd_multihop_interface_profile: <<: *present_bfd_mh_int_profile state: absent check_mode: true diff --git a/tests/integration/targets/aci_bfd_multihop_node_policy/tasks/main.yml b/tests/integration/targets/aci_bfd_multihop_node_policy/tasks/main.yml index b1e1f1685..a7b7edf40 100644 --- a/tests/integration/targets/aci_bfd_multihop_node_policy/tasks/main.yml +++ b/tests/integration/targets/aci_bfd_multihop_node_policy/tasks/main.yml @@ -178,4 +178,52 @@ - remove_bfd_multihop_node_pol.previous != [] - remove_bfd_multihop_node_pol.current == [] +# Validating out of rage parameters. +# Added BFD Multihop Node policy with out of the range detection_multiplier + - name: Add a new BFD Multihop Node policy - out of the range detection_multiplier + cisco.aci.aci_bfd_multihop_node_policy: + <<: *add_bfd_multihop_node_pol + name: ansible_bfd_multihop_node_policy_3 + detection_multiplier: 256 + state: present + ignore_errors: true + register: add_bfd_multihop_node_pol_3 + + - name: Verify BFD Multihop Node Policy creation + assert: + that: + - add_bfd_multihop_node_pol_3 is not changed + - add_bfd_multihop_node_pol_3.msg == "The \"detection_multiplier\" must be a value between 1 and 50" + +# Added BFD Multihop Node policy with out of the range min_transmit_interval + - name: Add a new BFD Multihop Node policy - out of the range min_transmit_interval + cisco.aci.aci_bfd_multihop_node_policy: + <<: *add_bfd_multihop_node_pol + name: ansible_bfd_multihop_node_policy_3 + min_transmit_interval: 50 + state: present + ignore_errors: true + register: add_bfd_multihop_node_pol_3 + + - name: Verify BFD Multihop Node Policy creation + assert: + that: + - add_bfd_multihop_node_pol_3 is not changed + - add_bfd_multihop_node_pol_3.msg == "The \"min_transmit_interval\" must be a value between 250 and 999" + +# Added BFD Multihop Node policy with out of the range min_receive_interval + - name: Add a new BFD Multihop Node policy - out of the range min_receive_interval + cisco.aci.aci_bfd_multihop_node_policy: + <<: *add_bfd_multihop_node_pol + name: ansible_bfd_multihop_node_policy_3 + min_receive_interval: 1000 + state: present + ignore_errors: true + register: add_bfd_multihop_node_pol_3 + + - name: Verify BFD Multihop Node Policy creation + assert: + that: + - add_bfd_multihop_node_pol_3 is not changed + - add_bfd_multihop_node_pol_3.msg == "The \"min_receive_interval\" must be a value between 250 and 999" diff --git a/tests/integration/targets/aci_l3out_bfd_interface_profile/aliases b/tests/integration/targets/aci_l3out_bfd_interface_profile/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/tests/integration/targets/aci_l3out_bfd_interface_profile/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/tests/integration/targets/aci_l3out_bfd_interface_profile/tasks/main.yml b/tests/integration/targets/aci_l3out_bfd_interface_profile/tasks/main.yml new file mode 100644 index 000000000..89f7a3eaa --- /dev/null +++ b/tests/integration/targets/aci_l3out_bfd_interface_profile/tasks/main.yml @@ -0,0 +1,174 @@ +# Test code for the ACI modules +# Copyright: (c) 2023, Anvitha Jain (@anvjain) + +# 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 + +- 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: debug + +- name: Query system information + cisco.aci.aci_system: + <<: *aci_info + id: 1 + state: query + register: version + +- name: Execute tasks only for non-cloud sites + when: version.current.0.topSystem.attributes.version is version('5.2', '>=') # This condition will execute only when APIC version >= 5.2 + block: # block specifies execution of tasks within, based on conditions + + # CLEAN ENVIRONMENT + - name: Remove the ansible_tenant + cisco.aci.aci_tenant: + <<: *aci_info + tenant: ansible_tenant + state: absent + + # Add a tenant + - name: Add a new tenant + cisco.aci.aci_tenant: + <<: *aci_info + tenant: ansible_tenant + description: Ansible tenant + state: present + + # Add VRF + - name: Add a new VRF + cisco.aci.aci_vrf: + <<: *aci_info + tenant: ansible_tenant + name: ansible_vrf + description: Ansible VRF + state: present + + # Add L3Out + - name: Add a new L3 Outside + cisco.aci.cisco.aci.aci_l3out: + <<: *aci_info + tenant: ansible_tenant + name: ansible_l3out + description: Ansible L3 Outside + domain: ansible_dom + vrf: ansible_vrf + l3protocol: bgp + state: present + + # ADD l3out logical node profile + - name: l3out logical node profile + cisco.aci.cisco.aci.aci_l3out_logical_node_profile: + <<: *aci_info + tenant: ansible_tenant + l3out: ansible_l3out + node_profile: ansible_node_profile + state: present + + # ADD l3out logical interface profile + - name: l3out logical interface profile + cisco.aci.aci_l3out_logical_interface_profile: + <<: *aci_info + tenant: ansible_tenant + l3out: ansible_l3out + node_profile: ansible_node_profile + interface_profile: ansible_interface_profile + state: present + + # Add L3Out BFD Interface Profile + - name: Add a new L3Out BFD Interface Profile - check mode + cisco.aci.aci_l3out_bfd_interface_profile: &present_l3out_bfd_int_profile + <<: *aci_info + tenant: ansible_tenant + l3out: ansible_l3out + l3out_logical_node_profile: ansible_node_profile + l3out_logical_interface_profile: ansible_interface_profile + state: present + check_mode: true + register: cm_add_l3out_bfd_int_prof + + - name: Add a new L3Out BFD Interface Profile - normal mode + cisco.aci.aci_l3out_bfd_interface_profile: + <<: *present_l3out_bfd_int_profile + state: present + register: nm_add_l3out_bfd_int_prof + + - name: Verify adding L3Out BFD Interface Profile + assert: + that: + - cm_add_l3out_bfd_int_prof is changed + - nm_add_l3out_bfd_int_prof is changed + - cm_add_l3out_bfd_int_prof.previous == nm_add_l3out_bfd_int_prof.previous == [] + - cm_add_l3out_bfd_int_prof.proposed.bfdIfP.attributes.dn == nm_add_l3out_bfd_int_prof.proposed.bfdIfP.attributes.dn == "uni/tn-ansible_tenant/out-ansible_l3out/lnodep-ansible_node_profile/lifp-ansible_interface_profile/bfdIfP" + - cm_add_l3out_bfd_int_prof.proposed.bfdIfP.attributes.keyId == nm_add_l3out_bfd_int_prof.proposed.bfdIfP.attributes.keyId == "3" + - cm_add_l3out_bfd_int_prof.proposed.bfdIfP.attributes.type == nm_add_l3out_bfd_int_prof.proposed.bfdIfP.attributes.type == "none" + + - name: Add L3Out BFD Interface Profile again- idempotency + cisco.aci.aci_l3out_bfd_interface_profile: + <<: *present_l3out_bfd_int_profile + state: present + register: add_l3out_bfd_int_prof_again + + - name: Verify adding L3Out BFD Interface Profile again - idempotency + assert: + that: + - add_l3out_bfd_int_prof_again is not changed + + # CREATE L3Out BFD Interface policy + - name: Add a new L3Out BFD Interface policy + cisco.aci.aci_bfd_interface_policy: + <<: *aci_info + tenant: ansible_tenant + name: ansible_bfd__interface_policy + description: Ansible BFD Interface Policy + state: present + register: add_bfd_interface_pol + + # Update L3Out BFD Interface Profile + - name: Update L3Out BFD Interface Profile + cisco.aci.aci_l3out_bfd_interface_profile: + <<: *present_l3out_bfd_int_profile + interface_profile_type: sha1 + key: "abc*123" + key_id: 15 + bfd_interface_policy: ansible_bfd_interface_policy + state: present + register: update_l3out_bfd_int_prof + + - name: Verify updating L3Out BFD Interface Profile + assert: + that: + - update_l3out_bfd_int_prof is changed + - update_l3out_bfd_int_prof.sent.bfdIfP.attributes.keyId == "15" + - update_l3out_bfd_int_prof.sent.bfdIfP.attributes.key == "abc*123" + - update_l3out_bfd_int_prof.sent.bfdIfP.attributes.type == "sha1" + - update_l3out_bfd_int_prof.sent.bfdIfP.children.0.bfdIfPol.attributes.tnBfdIfPolName == "ansible_bfd_interface_policy" + + - name: Query L3Out BFD Interface Profile + cisco.aci.aci_l3out_bfd_interface_profile: + <<: *present_l3out_bfd_int_profile + state: query + register: query_l3out_bfd_int_prof + + - name: Query all L3Out BFD Interface Profile + cisco.aci.aci_l3out_bfd_interface_profile: + <<: *aci_info + state: query + register: query_all_l3out_bfd_int_prof + + - name: Delete L3Out BFD Interface Profile - check mode + cisco.aci.aci_l3out_bfd_interface_profile: + <<: *present_l3out_bfd_int_profile + state: absent + check_mode: true + register: cm_remove_l3out_bfd_int_prof \ No newline at end of file From f77a8c789f90ce1c10afcf104022aade7f707a36 Mon Sep 17 00:00:00 2001 From: anvitha-jain Date: Wed, 8 Nov 2023 10:09:53 -0800 Subject: [PATCH 05/10] [ignore_changes] Fixing sanity issues --- plugins/modules/aci_bfd_interface_policy.py | 23 ++++---- .../aci_bfd_multihop_interface_policy.py | 17 +++--- .../aci_bfd_multihop_interface_profile.py | 10 ++-- .../modules/aci_bfd_multihop_node_policy.py | 15 +++--- .../aci_l3out_bfd_interface_profile.py | 9 +++- .../aci_bfd_interface_policy/tasks/main.yml | 54 +++++++++++++------ .../tasks/main.yml | 46 +++++++++++----- .../tasks/main.yml | 46 ++++++++++++++-- .../tasks/main.yml | 46 +++++++++++----- .../tasks/main.yml | 52 +++++++++++++++--- 10 files changed, 230 insertions(+), 88 deletions(-) diff --git a/plugins/modules/aci_bfd_interface_policy.py b/plugins/modules/aci_bfd_interface_policy.py index 4afb3df77..f2b303241 100644 --- a/plugins/modules/aci_bfd_interface_policy.py +++ b/plugins/modules/aci_bfd_interface_policy.py @@ -26,7 +26,7 @@ description: - Name of the BFD Interface policy type: str - aliases: [ bfd_multihop_interface_policy ] + aliases: [ bfd_interface_policy ] description: description: - Description of the BFD Interface policy @@ -48,13 +48,13 @@ - Minimum transmit (Tx) interval of the BFD Interface policy - Allowed range is 250-999. type: int - default: 250 + default: 50 min_receive_interval: description: - Minimum receive (Rx) interval of the BFD Interface policy - Allowed range is 250-999. type: int - default: 250 + default: 50 state: description: - Use C(present) or C(absent) for adding or removing. @@ -79,14 +79,13 @@ EXAMPLES = r""" - name: Add a new BFD Interface policy - cisco.aci.aci_bfd_interface_policy: - host: apic - username: admin - password: SomeSecretPassword - tenant: ansible_tenant - name: ansible_bfd_interface_policy - description: Ansible BFD Interface Policy - state: present + cisco.aci.aci_bfd_interface_policy: + host: apic + username: admin + password: SomeSecretPassword + tenant: ansible_tenant + name: ansible_bfd_interface_policy + description: Ansible BFD Interface Policy state: present delegate_to: localhost @@ -109,7 +108,6 @@ name: ansible_bfd_interface_policy state: query delegate_to: localhost - register: query_result - name: Query all BFD Interface policies in a specific tenant cisco.aci.aci_bfd_interface_policy: @@ -119,7 +117,6 @@ tenant: ansible_tenant state: query delegate_to: localhost - register: query_result """ RETURN = r""" diff --git a/plugins/modules/aci_bfd_multihop_interface_policy.py b/plugins/modules/aci_bfd_multihop_interface_policy.py index 8dab45fcc..43005d67e 100644 --- a/plugins/modules/aci_bfd_multihop_interface_policy.py +++ b/plugins/modules/aci_bfd_multihop_interface_policy.py @@ -79,14 +79,13 @@ EXAMPLES = r""" - name: Add a new BFD Multihop Interface policy - cisco.aci.aci_bfd_multihop_interface_policy: - host: apic - username: admin - password: SomeSecretPassword - tenant: ansible_tenant - name: ansible_bfd_multihop_interface_policy - description: Ansible BFD Multihop Interface Policy - state: present + cisco.aci.aci_bfd_multihop_interface_policy: + host: apic + username: admin + password: SomeSecretPassword + tenant: ansible_tenant + name: ansible_bfd_multihop_interface_policy + description: Ansible BFD Multihop Interface Policy state: present delegate_to: localhost @@ -109,7 +108,6 @@ name: ansible_bfd_multihop_interface_policy state: query delegate_to: localhost - register: query_result - name: Query all BFD Multihop Interface policies in a specific tenant cisco.aci.aci_bfd_multihop_interface_policy: @@ -119,7 +117,6 @@ tenant: ansible_tenant state: query delegate_to: localhost - register: query_result """ RETURN = r""" diff --git a/plugins/modules/aci_bfd_multihop_interface_profile.py b/plugins/modules/aci_bfd_multihop_interface_profile.py index aec0faa1e..50dc063e4 100644 --- a/plugins/modules/aci_bfd_multihop_interface_profile.py +++ b/plugins/modules/aci_bfd_multihop_interface_profile.py @@ -16,16 +16,18 @@ short_description: Manage BFD Multihop Interface profile. description: - Manage BFD Multihop Interface profile (bfdMhIfP) configuration on Cisco ACI fabrics. -- Only available in APIC version 5.2 or later. +- Only available in APIC version 5.2 or later and for non-cloud APICs. options: tenant: description: - Name of an existing tenant. type: str + aliases: [ tenant_name ] l3out: description: - Name of an existing L3Out. type: str + aliases: [ l3out_name ] l3out_logical_node_profile: description: - Name of an existing L3Out Logical Node profile. @@ -49,6 +51,7 @@ description: - Description of the BFD Multihop Interface Profile object. type: str + aliases: [ descr ] interface_profile_type: description: - Authentication Type of the BFD Multihop Interface Profile object. @@ -255,7 +258,7 @@ def main(): name_alias=dict(type="str"), description=dict(type="str", aliases=["descr"]), interface_profile_type=dict(type="str", default="none", choices=["none", "sha1"]), - key=dict(type="str"), + key=dict(type="str", no_log=True), key_id=dict(type="int", default=3), bfd_multihop_interface_policy=dict(type="str", aliases=["multihop_interface_policy", "multihop_interface_policy_name"]), state=dict(type="str", default="present", choices=["absent", "present", "query"]), @@ -280,11 +283,12 @@ def main(): interface_profile_type = module.params.get("interface_profile_type") key = module.params.get("key") key_id = module.params.get("key_id") + if key_id is not None and key_id not in range(1, 255): + module.fail_json(msg='The "key_id" must be a value between 1 and 255') bfd_multihop_interface_policy = module.params.get("bfd_multihop_interface_policy") state = module.params.get("state") aci = ACIModule(module) - aci.stdout = str("CHECK MODE: ") + str(bfd_multihop_interface_policy) aci.construct_url( root_class=dict( aci_class="fvTenant", diff --git a/plugins/modules/aci_bfd_multihop_node_policy.py b/plugins/modules/aci_bfd_multihop_node_policy.py index f15eac081..6a1453c92 100644 --- a/plugins/modules/aci_bfd_multihop_node_policy.py +++ b/plugins/modules/aci_bfd_multihop_node_policy.py @@ -79,14 +79,13 @@ EXAMPLES = r""" - name: Add a new BFD Multihop Node policy - cisco.aci.aci_bfd_multihop_node_policy: - host: apic - username: admin - password: SomeSecretPassword - tenant: ansible_tenant - name: ansible_bfd_multihop_node_policy - description: Ansible BFD Multihop Node Policy - state: present + cisco.aci.aci_bfd_multihop_node_policy: + host: apic + username: admin + password: SomeSecretPassword + tenant: ansible_tenant + name: ansible_bfd_multihop_node_policy + description: Ansible BFD Multihop Node Policy state: present delegate_to: localhost diff --git a/plugins/modules/aci_l3out_bfd_interface_profile.py b/plugins/modules/aci_l3out_bfd_interface_profile.py index 6eadbbfd8..0b04e3031 100644 --- a/plugins/modules/aci_l3out_bfd_interface_profile.py +++ b/plugins/modules/aci_l3out_bfd_interface_profile.py @@ -16,16 +16,18 @@ short_description: Manage L3Out BFD Interface profile. description: - Manage L3Out BFD Interface profile (bfdIfP) configuration on Cisco ACI fabrics. -- Only available in APIC version 5.2 or later. +- Only available in APIC version 5.2 or later and for non-cloud APICs. options: tenant: description: - Name of an existing tenant. type: str + aliases: [ tenant_name ] l3out: description: - Name of an existing L3Out. type: str + aliases: [ l3out_name ] l3out_logical_node_profile: description: - Name of an existing L3Out Logical Node profile. @@ -49,6 +51,7 @@ description: - Description of the L3Out BFD Interface profile object. type: str + aliases: [ descr ] interface_profile_type: description: - Authentication Type of the L3Out BFD Interface profile object. @@ -255,7 +258,7 @@ def main(): name_alias=dict(type="str"), description=dict(type="str", aliases=["descr"]), interface_profile_type=dict(type="str", default="none", choices=["none", "sha1"]), - key=dict(type="str"), + key=dict(type="str", no_log=True), key_id=dict(type="int", default=3), bfd_interface_policy=dict(type="str", aliases=["interface_policy", "interface_policy_name"]), state=dict(type="str", default="present", choices=["absent", "present", "query"]), @@ -280,6 +283,8 @@ def main(): interface_profile_type = module.params.get("interface_profile_type") key = module.params.get("key") key_id = module.params.get("key_id") + if key_id is not None and key_id not in range(1, 255): + module.fail_json(msg='The "key_id" must be a value between 1 and 255') bfd_interface_policy = module.params.get("bfd_interface_policy") state = module.params.get("state") diff --git a/tests/integration/targets/aci_bfd_interface_policy/tasks/main.yml b/tests/integration/targets/aci_bfd_interface_policy/tasks/main.yml index 21f659f91..0ffffe0ea 100644 --- a/tests/integration/targets/aci_bfd_interface_policy/tasks/main.yml +++ b/tests/integration/targets/aci_bfd_interface_policy/tasks/main.yml @@ -9,7 +9,7 @@ when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -32,13 +32,13 @@ # CLEAN ENVIRONMENT - name: Remove the ansible_tenant - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_info tenant: ansible_tenant state: absent - name: Add a new tenant - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_info tenant: ansible_tenant description: Ansible tenant @@ -67,13 +67,13 @@ - cm_add_bfd_interface_pol is changed - nm_add_bfd_interface_pol is changed - cm_add_bfd_interface_pol.previous == nm_add_bfd_interface_pol.previous == [] - - nm_add_bfd_interface_pol.current.0.bfdIfPol.attributes.dn == "uni/tn-ansible_tenant/bfdIfPol-ansible_bfd_interface_policy" - - nm_add_bfd_interface_pol.current.0.bfdIfPol.attributes.name == "ansible_bfd_interface_policy" - - nm_add_bfd_interface_pol.current.0.bfdIfPol.attributes.descr == "Ansible BFD Interface Policy" - - nm_add_bfd_interface_pol.current.0.bfdIfPol.attributes.adminSt == "enabled" - - nm_add_bfd_interface_pol.current.0.bfdIfPol.attributes.detectMult == "3" - - nm_add_bfd_interface_pol.current.0.bfdIfPol.attributes.minRxIntvl == "50" - - nm_add_bfd_interface_pol.current.0.bfdIfPol.attributes.minTxIntvl == "50" + - cm_add_bfd_interface_pol.proposed.bfdIfPol.attributes.dn == nm_add_bfd_interface_pol.current.0.bfdIfPol.attributes.dn == "uni/tn-ansible_tenant/bfdIfPol-ansible_bfd_interface_policy" + - cm_add_bfd_interface_pol.proposed.bfdIfPol.attributes.name == nm_add_bfd_interface_pol.current.0.bfdIfPol.attributes.name == "ansible_bfd_interface_policy" + - cm_add_bfd_interface_pol.proposed.bfdIfPol.attributes.descr == nm_add_bfd_interface_pol.current.0.bfdIfPol.attributes.descr == "Ansible BFD Interface Policy" + - cm_add_bfd_interface_pol.proposed.bfdIfPol.attributes.adminSt == nm_add_bfd_interface_pol.current.0.bfdIfPol.attributes.adminSt == "enabled" + - cm_add_bfd_interface_pol.proposed.bfdIfPol.attributes.detectMult == nm_add_bfd_interface_pol.current.0.bfdIfPol.attributes.detectMult == "3" + - cm_add_bfd_interface_pol.proposed.bfdIfPol.attributes.minRxIntvl == nm_add_bfd_interface_pol.current.0.bfdIfPol.attributes.minRxIntvl == "50" + - cm_add_bfd_interface_pol.proposed.bfdIfPol.attributes.minTxIntvl == nm_add_bfd_interface_pol.current.0.bfdIfPol.attributes.minTxIntvl == "50" - name: Add a new BFD Interface policy again - idempotency cisco.aci.aci_bfd_interface_policy: @@ -163,22 +163,42 @@ - query_result.current.0.bfdIfPol.attributes.dn == "uni/tn-ansible_tenant/bfdIfPol-ansible_bfd_interface_policy" - query_result.current.0.bfdIfPol.attributes.name == "ansible_bfd_interface_policy" - - name: Remove a BFD Interface policy + - name: Remove a BFD Interface policy - check mode cisco.aci.aci_bfd_interface_policy: <<: *aci_info tenant: ansible_tenant name: ansible_bfd_interface_policy state: absent - register: remove_bfd_interface_pol + check_mode: true + register: cm_remove_bfd_interface_pol + + - name: Remove a BFD Interface policy - normal mode + cisco.aci.aci_bfd_interface_policy: + <<: *aci_info + tenant: ansible_tenant + name: ansible_bfd_interface_policy + state: absent + register: nm_remove_bfd_interface_pol + + - name: Remove a BFD Interface policy again + cisco.aci.aci_bfd_interface_policy: + <<: *aci_info + tenant: ansible_tenant + name: ansible_bfd_interface_policy + state: absent + register: remove_bfd_interface_pol_again - name: Verify removing BFD Interface Policies assert: that: - - remove_bfd_interface_pol is changed - - remove_bfd_interface_pol.previous != [] - - remove_bfd_interface_pol.current == [] - -# Validating out of rage parameters. + - nm_remove_bfd_interface_pol is changed + - cm_remove_bfd_interface_pol is changed + - cm_remove_bfd_interface_pol.proposed == {} + - nm_remove_bfd_interface_pol.previous != [] + - remove_bfd_interface_pol_again is not changed + - nm_remove_bfd_interface_pol.current == remove_bfd_interface_pol_again.current == [] + +# Validating out of range parameters. # Added BFD Interface policy with out of the range detection_multiplier - name: Add a new BFD Interface policy - out of the range detection_multiplier diff --git a/tests/integration/targets/aci_bfd_multihop_interface_policy/tasks/main.yml b/tests/integration/targets/aci_bfd_multihop_interface_policy/tasks/main.yml index 8e7be35a7..11f66b13c 100644 --- a/tests/integration/targets/aci_bfd_multihop_interface_policy/tasks/main.yml +++ b/tests/integration/targets/aci_bfd_multihop_interface_policy/tasks/main.yml @@ -9,7 +9,7 @@ when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -67,13 +67,13 @@ - cm_add_bfd_multihop_interface_pol is changed - nm_add_bfd_multihop_interface_pol is changed - cm_add_bfd_multihop_interface_pol.previous == nm_add_bfd_multihop_interface_pol.previous == [] - - nm_add_bfd_multihop_interface_pol.current.0.bfdMhIfPol.attributes.dn == "uni/tn-ansible_tenant/bfdMhIfPol-ansible_bfd_multihop_interface_policy" - - nm_add_bfd_multihop_interface_pol.current.0.bfdMhIfPol.attributes.name == "ansible_bfd_multihop_interface_policy" - - nm_add_bfd_multihop_interface_pol.current.0.bfdMhIfPol.attributes.descr == "Ansible BFD Multihop Interface Policy" - - nm_add_bfd_multihop_interface_pol.current.0.bfdMhIfPol.attributes.adminSt == "enabled" - - nm_add_bfd_multihop_interface_pol.current.0.bfdMhIfPol.attributes.detectMult == "3" - - nm_add_bfd_multihop_interface_pol.current.0.bfdMhIfPol.attributes.minRxIntvl == "250" - - nm_add_bfd_multihop_interface_pol.current.0.bfdMhIfPol.attributes.minTxIntvl == "250" + - cm_add_bfd_multihop_interface_pol.proposed.bfdMhIfPol.attributes.dn == nm_add_bfd_multihop_interface_pol.current.0.bfdMhIfPol.attributes.dn == "uni/tn-ansible_tenant/bfdMhIfPol-ansible_bfd_multihop_interface_policy" + - cm_add_bfd_multihop_interface_pol.proposed.bfdMhIfPol.attributes.name == nm_add_bfd_multihop_interface_pol.current.0.bfdMhIfPol.attributes.name == "ansible_bfd_multihop_interface_policy" + - cm_add_bfd_multihop_interface_pol.proposed.bfdMhIfPol.attributes.descr == nm_add_bfd_multihop_interface_pol.current.0.bfdMhIfPol.attributes.descr == "Ansible BFD Multihop Interface Policy" + - cm_add_bfd_multihop_interface_pol.proposed.bfdMhIfPol.attributes.adminSt == nm_add_bfd_multihop_interface_pol.current.0.bfdMhIfPol.attributes.adminSt == "enabled" + - cm_add_bfd_multihop_interface_pol.proposed.bfdMhIfPol.attributes.detectMult == nm_add_bfd_multihop_interface_pol.current.0.bfdMhIfPol.attributes.detectMult == "3" + - cm_add_bfd_multihop_interface_pol.proposed.bfdMhIfPol.attributes.minRxIntvl == nm_add_bfd_multihop_interface_pol.current.0.bfdMhIfPol.attributes.minRxIntvl == "250" + - cm_add_bfd_multihop_interface_pol.proposed.bfdMhIfPol.attributes.minTxIntvl == nm_add_bfd_multihop_interface_pol.current.0.bfdMhIfPol.attributes.minTxIntvl == "250" - name: Add a new BFD Multihop Interface policy again - idempotency cisco.aci.aci_bfd_multihop_interface_policy: @@ -163,20 +163,40 @@ - query_result.current.0.bfdMhIfPol.attributes.dn == "uni/tn-ansible_tenant/bfdMhIfPol-ansible_bfd_multihop_interface_policy" - query_result.current.0.bfdMhIfPol.attributes.name == "ansible_bfd_multihop_interface_policy" - - name: Remove a BFD Multihop Interface policy + - name: Remove a BFD Multihop Interface policy - check mode cisco.aci.aci_bfd_multihop_interface_policy: <<: *aci_info tenant: ansible_tenant name: ansible_bfd_multihop_interface_policy state: absent - register: remove_bfd_multihop_interface_pol + check_mode: true + register: cm_remove_bfd_multihop_interface_pol + + - name: Remove a BFD Multihop Interface policy - normal mode + cisco.aci.aci_bfd_multihop_interface_policy: + <<: *aci_info + tenant: ansible_tenant + name: ansible_bfd_multihop_interface_policy + state: absent + register: nm_remove_bfd_multihop_interface_pol + + - name: Remove a BFD Multihop Interface policy again - idempotency + cisco.aci.aci_bfd_multihop_interface_policy: + <<: *aci_info + tenant: ansible_tenant + name: ansible_bfd_multihop_interface_policy + state: absent + register: remove_bfd_multihop_interface_pol_again - name: Verify removing BFD Multihop Interface Policies assert: that: - - remove_bfd_multihop_interface_pol is changed - - remove_bfd_multihop_interface_pol.previous != [] - - remove_bfd_multihop_interface_pol.current == [] + - nm_remove_bfd_multihop_interface_pol is changed + - cm_remove_bfd_multihop_interface_pol is changed + - cm_remove_bfd_multihop_interface_pol.proposed == nm_remove_bfd_multihop_interface_pol.proposed == {} + - nm_remove_bfd_multihop_interface_pol.previous != [] + - remove_bfd_multihop_interface_pol_again is not changed + - nm_remove_bfd_multihop_interface_pol.current == remove_bfd_multihop_interface_pol_again.current == [] # Validating out of rage parameters. diff --git a/tests/integration/targets/aci_bfd_multihop_interface_profile/tasks/main.yml b/tests/integration/targets/aci_bfd_multihop_interface_profile/tasks/main.yml index 1785e87da..4c91d9ecb 100644 --- a/tests/integration/targets/aci_bfd_multihop_interface_profile/tasks/main.yml +++ b/tests/integration/targets/aci_bfd_multihop_interface_profile/tasks/main.yml @@ -9,7 +9,7 @@ when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -26,8 +26,12 @@ state: query register: version +- name: Verify Cloud and Non-Cloud Sites in use. + include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + - name: Execute tasks only for non-cloud sites - when: version.current.0.topSystem.attributes.version is version('5.2', '>=') # This condition will execute only when APIC version >= 5.2 + # This condition will execute only when APIC version >= 5.2 and for non-cloud APICs + when: version.current.0.topSystem.attributes.version is version('5.2', '>=') and query_cloud.current == [] block: # block specifies execution of tasks within, based on conditions # CLEAN ENVIRONMENT @@ -166,9 +170,45 @@ state: query register: query_all_bfd_mh_int_prof + # Validating out of range parameters. + - name: Add out of range key_id + cisco.aci.aci_bfd_multihop_interface_profile: + <<: *present_bfd_mh_int_profile + key_id: 256 + state: present + ignore_errors: true + register: out_of_range_key_id + + - name: Verify out of range key_id + assert: + that: + - out_of_range_key_id is not changed + - out_of_range_key_id.msg == "The \"key_id\" must be a value between 1 and 255" + - name: Delete BFD Multihop Interface Profile - check mode cisco.aci.aci_bfd_multihop_interface_profile: <<: *present_bfd_mh_int_profile state: absent check_mode: true - register: cm_remove_bfd_mh_int_prof \ No newline at end of file + register: cm_remove_bfd_mh_int_prof + + - name: Delete BFD Multihop Interface Profile - normal mode + cisco.aci.aci_bfd_multihop_interface_profile: + <<: *present_bfd_mh_int_profile + state: absent + register: nm_remove_bfd_mh_int_prof + + - name: Delete BFD Multihop Interface Profile again - idempotency + cisco.aci.aci_bfd_multihop_interface_profile: + <<: *present_bfd_mh_int_profile + state: absent + register: remove_bfd_mh_int_prof_again + + - name: Verify removing BFD Multihop Interface Profile + assert: + that: + - cm_remove_bfd_mh_int_prof is changed + - nm_remove_bfd_mh_int_prof is changed + - cm_remove_bfd_mh_int_prof.proposed == nm_remove_bfd_mh_int_prof.proposed == {} + - remove_bfd_mh_int_prof_again is not changed + - nm_remove_bfd_mh_int_prof.current == remove_bfd_mh_int_prof_again.current == [] \ No newline at end of file diff --git a/tests/integration/targets/aci_bfd_multihop_node_policy/tasks/main.yml b/tests/integration/targets/aci_bfd_multihop_node_policy/tasks/main.yml index a7b7edf40..98a96aac7 100644 --- a/tests/integration/targets/aci_bfd_multihop_node_policy/tasks/main.yml +++ b/tests/integration/targets/aci_bfd_multihop_node_policy/tasks/main.yml @@ -9,7 +9,7 @@ when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -67,13 +67,13 @@ - cm_add_bfd_multihop_node_pol is changed - nm_add_bfd_multihop_node_pol is changed - cm_add_bfd_multihop_node_pol.previous == nm_add_bfd_multihop_node_pol.previous == [] - - nm_add_bfd_multihop_node_pol.current.0.bfdMhNodePol.attributes.dn == "uni/tn-ansible_tenant/bfdMhNodePol-ansible_bfd_multihop_node_policy" - - nm_add_bfd_multihop_node_pol.current.0.bfdMhNodePol.attributes.name == "ansible_bfd_multihop_node_policy" - - nm_add_bfd_multihop_node_pol.current.0.bfdMhNodePol.attributes.descr == "Ansible BFD Multihop Node Policy" - - nm_add_bfd_multihop_node_pol.current.0.bfdMhNodePol.attributes.adminSt == "enabled" - - nm_add_bfd_multihop_node_pol.current.0.bfdMhNodePol.attributes.detectMult == "3" - - nm_add_bfd_multihop_node_pol.current.0.bfdMhNodePol.attributes.minRxIntvl == "250" - - nm_add_bfd_multihop_node_pol.current.0.bfdMhNodePol.attributes.minTxIntvl == "250" + - cm_add_bfd_multihop_node_pol.proposed.bfdMhNodePol.attributes.dn == nm_add_bfd_multihop_node_pol.current.0.bfdMhNodePol.attributes.dn == "uni/tn-ansible_tenant/bfdMhNodePol-ansible_bfd_multihop_node_policy" + - cm_add_bfd_multihop_node_pol.proposed.bfdMhNodePol.attributes.name == nm_add_bfd_multihop_node_pol.current.0.bfdMhNodePol.attributes.name == "ansible_bfd_multihop_node_policy" + - cm_add_bfd_multihop_node_pol.proposed.bfdMhNodePol.attributes.descr == nm_add_bfd_multihop_node_pol.current.0.bfdMhNodePol.attributes.descr == "Ansible BFD Multihop Node Policy" + - cm_add_bfd_multihop_node_pol.proposed.bfdMhNodePol.attributes.adminSt == nm_add_bfd_multihop_node_pol.current.0.bfdMhNodePol.attributes.adminSt == "enabled" + - cm_add_bfd_multihop_node_pol.proposed.bfdMhNodePol.attributes.detectMult == nm_add_bfd_multihop_node_pol.current.0.bfdMhNodePol.attributes.detectMult == "3" + - cm_add_bfd_multihop_node_pol.proposed.bfdMhNodePol.attributes.minRxIntvl == nm_add_bfd_multihop_node_pol.current.0.bfdMhNodePol.attributes.minRxIntvl == "250" + - cm_add_bfd_multihop_node_pol.proposed.bfdMhNodePol.attributes.minTxIntvl == nm_add_bfd_multihop_node_pol.current.0.bfdMhNodePol.attributes.minTxIntvl == "250" - name: Add a new BFD Multihop Node policy again - idempotency cisco.aci.aci_bfd_multihop_node_policy: @@ -163,20 +163,40 @@ - query_result.current.0.bfdMhNodePol.attributes.dn == "uni/tn-ansible_tenant/bfdMhNodePol-ansible_bfd_multihop_node_policy" - query_result.current.0.bfdMhNodePol.attributes.name == "ansible_bfd_multihop_node_policy" - - name: Remove a BFD Multihop Node policy + - name: Remove a BFD Multihop Node policy - check mode cisco.aci.aci_bfd_multihop_node_policy: <<: *aci_info tenant: ansible_tenant name: ansible_bfd_multihop_node_policy state: absent - register: remove_bfd_multihop_node_pol + check_mode: true + register: cm_remove_bfd_multihop_node_pol + + - name: Remove a BFD Multihop Node policy - normal mode + cisco.aci.aci_bfd_multihop_node_policy: + <<: *aci_info + tenant: ansible_tenant + name: ansible_bfd_multihop_node_policy + state: absent + register: nm_remove_bfd_multihop_node_pol + + - name: Remove a BFD Multihop Node policy again + cisco.aci.aci_bfd_multihop_node_policy: + <<: *aci_info + tenant: ansible_tenant + name: ansible_bfd_multihop_node_policy + state: absent + register: remove_bfd_multihop_node_pol_again - name: Verify removing BFD Multihop Node Policies assert: that: - - remove_bfd_multihop_node_pol is changed - - remove_bfd_multihop_node_pol.previous != [] - - remove_bfd_multihop_node_pol.current == [] + - nm_remove_bfd_multihop_node_pol is changed + - cm_remove_bfd_multihop_node_pol is changed + - cm_remove_bfd_multihop_node_pol.proposed == {} + - nm_remove_bfd_multihop_node_pol.previous != [] + - remove_bfd_multihop_node_pol_again is not changed + - remove_bfd_multihop_node_pol_again.current == nm_remove_bfd_multihop_node_pol.current == [] # Validating out of rage parameters. diff --git a/tests/integration/targets/aci_l3out_bfd_interface_profile/tasks/main.yml b/tests/integration/targets/aci_l3out_bfd_interface_profile/tasks/main.yml index 89f7a3eaa..11e1ef26c 100644 --- a/tests/integration/targets/aci_l3out_bfd_interface_profile/tasks/main.yml +++ b/tests/integration/targets/aci_l3out_bfd_interface_profile/tasks/main.yml @@ -9,7 +9,7 @@ when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -26,8 +26,12 @@ state: query register: version +- name: Verify Cloud and Non-Cloud Sites in use. + include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + - name: Execute tasks only for non-cloud sites - when: version.current.0.topSystem.attributes.version is version('5.2', '>=') # This condition will execute only when APIC version >= 5.2 + # This condition will execute only when APIC version >= 5.2 and for non-cloud APICs + when: version.current.0.topSystem.attributes.version is version('5.2', '>=') and query_cloud.current == [] block: # block specifies execution of tasks within, based on conditions # CLEAN ENVIRONMENT @@ -56,7 +60,7 @@ # Add L3Out - name: Add a new L3 Outside - cisco.aci.cisco.aci.aci_l3out: + cisco.aci.aci_l3out: <<: *aci_info tenant: ansible_tenant name: ansible_l3out @@ -68,7 +72,7 @@ # ADD l3out logical node profile - name: l3out logical node profile - cisco.aci.cisco.aci.aci_l3out_logical_node_profile: + cisco.aci.aci_l3out_logical_node_profile: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -152,7 +156,7 @@ - update_l3out_bfd_int_prof.sent.bfdIfP.attributes.keyId == "15" - update_l3out_bfd_int_prof.sent.bfdIfP.attributes.key == "abc*123" - update_l3out_bfd_int_prof.sent.bfdIfP.attributes.type == "sha1" - - update_l3out_bfd_int_prof.sent.bfdIfP.children.0.bfdIfPol.attributes.tnBfdIfPolName == "ansible_bfd_interface_policy" + - update_l3out_bfd_int_prof.sent.bfdIfP.children.0.bfdRsIfPol.attributes.tnBfdIfPolName == "ansible_bfd_interface_policy" - name: Query L3Out BFD Interface Profile cisco.aci.aci_l3out_bfd_interface_profile: @@ -166,9 +170,45 @@ state: query register: query_all_l3out_bfd_int_prof + # Validating out of range parameters. + - name: Add out of range key_id + cisco.aci.aci_l3out_bfd_interface_profile: + <<: *present_l3out_bfd_int_profile + key_id: 256 + state: present + ignore_errors: true + register: out_of_range_key_id + + - name: Verify out of range key_id + assert: + that: + - out_of_range_key_id is not changed + - out_of_range_key_id.msg == "The \"key_id\" must be a value between 1 and 255" + - name: Delete L3Out BFD Interface Profile - check mode cisco.aci.aci_l3out_bfd_interface_profile: <<: *present_l3out_bfd_int_profile state: absent check_mode: true - register: cm_remove_l3out_bfd_int_prof \ No newline at end of file + register: cm_remove_l3out_bfd_int_prof + + - name: Delete L3Out BFD Interface Profile - normal mode + cisco.aci.aci_l3out_bfd_interface_profile: + <<: *present_l3out_bfd_int_profile + state: absent + register: nm_remove_l3out_bfd_int_prof + + - name: Delete L3Out BFD Interface Profile again - idempotency + cisco.aci.aci_l3out_bfd_interface_profile: + <<: *present_l3out_bfd_int_profile + state: absent + register: remove_l3out_bfd_int_prof_again + + - name: Verify removing L3Out BFD Interface Profile + assert: + that: + - cm_remove_l3out_bfd_int_prof is changed + - nm_remove_l3out_bfd_int_prof is changed + - cm_remove_l3out_bfd_int_prof.proposed == nm_remove_l3out_bfd_int_prof.proposed == {} + - remove_l3out_bfd_int_prof_again is not changed + - nm_add_l3out_bfd_int_prof.current == remove_l3out_bfd_int_prof_again.current == [] \ No newline at end of file From 1f2958436cc5303cce7eca1f9863db2ed680407d Mon Sep 17 00:00:00 2001 From: anvitha-jain Date: Wed, 15 Nov 2023 04:56:23 -0800 Subject: [PATCH 06/10] [ignore_changes] Changed default values since APIC sets the value. --- plugins/modules/aci_bfd_interface_policy.py | 46 +++++++++++-------- .../aci_bfd_multihop_interface_policy.py | 40 +++++++++------- .../aci_bfd_multihop_interface_profile.py | 32 +++++++------ .../modules/aci_bfd_multihop_node_policy.py | 46 +++++++++++-------- .../aci_l3out_bfd_interface_profile.py | 34 ++++++++------ .../aci_bfd_interface_policy/tasks/main.yml | 3 -- .../tasks/main.yml | 3 -- .../tasks/main.yml | 4 +- .../tasks/main.yml | 3 -- .../tasks/main.yml | 6 +-- 10 files changed, 116 insertions(+), 101 deletions(-) diff --git a/plugins/modules/aci_bfd_interface_policy.py b/plugins/modules/aci_bfd_interface_policy.py index f2b303241..b29c7a76e 100644 --- a/plugins/modules/aci_bfd_interface_policy.py +++ b/plugins/modules/aci_bfd_interface_policy.py @@ -40,21 +40,21 @@ detection_multiplier: description: - Detection multiplier of the BFD Interface policy + - APIC sets the default value to 3. - Allowed range is 1-50. type: int - default: 3 min_transmit_interval: description: - Minimum transmit (Tx) interval of the BFD Interface policy + - APIC sets the default value to 50. - Allowed range is 250-999. type: int - default: 50 min_receive_interval: description: - Minimum receive (Rx) interval of the BFD Interface policy + - APIC sets the default value to 50. - Allowed range is 250-999. type: int - default: 50 state: description: - Use C(present) or C(absent) for adding or removing. @@ -235,9 +235,9 @@ def main(): name=dict(type="str", aliases=["bfd_interface_policy"]), description=dict(type="str"), admin_state=dict(type="str", default="enabled", choices=["enabled", "disabled"]), - detection_multiplier=dict(type="int", default=3), - min_transmit_interval=dict(type="int", default=50), - min_receive_interval=dict(type="int", default=50), + detection_multiplier=dict(type="int"), + min_transmit_interval=dict(type="int"), + min_receive_interval=dict(type="int"), state=dict(type="str", default="present", choices=["absent", "present", "query"]), tenant=dict(type="str"), ) @@ -257,14 +257,8 @@ def main(): tenant = module.params.get("tenant") admin_state = module.params.get("admin_state") detection_multiplier = module.params.get("detection_multiplier") - if detection_multiplier is not None and detection_multiplier not in range(1, 50): - module.fail_json(msg='The "detection_multiplier" must be a value between 1 and 50') min_transmit_interval = module.params.get("min_transmit_interval") - if min_transmit_interval is not None and min_transmit_interval not in range(50, 999): - module.fail_json(msg='The "min_transmit_interval" must be a value between 50 and 999') min_receive_interval = module.params.get("min_receive_interval") - if min_receive_interval is not None and min_receive_interval not in range(50, 999): - module.fail_json(msg='The "min_receive_interval" must be a value between 50 and 999') aci = ACIModule(module) aci.construct_url( @@ -285,16 +279,28 @@ def main(): aci.get_existing() if state == "present": + class_config=dict( + name=name, + descr=description, + adminSt=admin_state, + ) + + if detection_multiplier and detection_multiplier not in range(1, 50): + module.fail_json(msg='The "detection_multiplier" must be a value between 1 and 50') + else: + class_config["detectMult"] = detection_multiplier + if min_transmit_interval and min_transmit_interval not in range(50, 999): + module.fail_json(msg='The "min_transmit_interval" must be a value between 50 and 999') + else: + class_config["minTxIntvl"] = min_transmit_interval + if min_receive_interval and min_receive_interval not in range(50, 999): + module.fail_json(msg='The "min_receive_interval" must be a value between 50 and 999') + else: + class_config["minRxIntvl"] = min_receive_interval + aci.payload( aci_class="bfdIfPol", - class_config=dict( - name=name, - descr=description, - adminSt=admin_state, - detectMult=detection_multiplier, - minTxIntvl=min_transmit_interval, - minRxIntvl=min_receive_interval, - ), + class_config=class_config, ) aci.get_diff(aci_class="bfdIfPol") diff --git a/plugins/modules/aci_bfd_multihop_interface_policy.py b/plugins/modules/aci_bfd_multihop_interface_policy.py index 43005d67e..48d876bc6 100644 --- a/plugins/modules/aci_bfd_multihop_interface_policy.py +++ b/plugins/modules/aci_bfd_multihop_interface_policy.py @@ -40,21 +40,21 @@ detection_multiplier: description: - Detection multiplier of the BFD Multihop Interface policy + - APIC sets the default value to 3. - Allowed range is 1-50. type: int - default: 3 min_transmit_interval: description: - Minimum transmit (Tx) interval of the BFD Multihop Interface policy + - APIC sets the default value to 250. - Allowed range is 250-999. type: int - default: 250 min_receive_interval: description: - Minimum receive (Rx) interval of the BFD Multihop Interface policy + - APIC sets the default value to 250. - Allowed range is 250-999. type: int - default: 250 state: description: - Use C(present) or C(absent) for adding or removing. @@ -257,14 +257,8 @@ def main(): tenant = module.params.get("tenant") admin_state = module.params.get("admin_state") detection_multiplier = module.params.get("detection_multiplier") - if detection_multiplier is not None and detection_multiplier not in range(1, 50): - module.fail_json(msg='The "detection_multiplier" must be a value between 1 and 50') min_transmit_interval = module.params.get("min_transmit_interval") - if min_transmit_interval is not None and min_transmit_interval not in range(250, 999): - module.fail_json(msg='The "min_transmit_interval" must be a value between 250 and 999') min_receive_interval = module.params.get("min_receive_interval") - if min_receive_interval is not None and min_receive_interval not in range(250, 999): - module.fail_json(msg='The "min_receive_interval" must be a value between 250 and 999') aci = ACIModule(module) aci.construct_url( @@ -285,16 +279,28 @@ def main(): aci.get_existing() if state == "present": + class_config=dict( + name=name, + descr=description, + adminSt=admin_state, + ) + + if detection_multiplier and detection_multiplier not in range(1, 50): + module.fail_json(msg='The "detection_multiplier" must be a value between 1 and 50') + else: + class_config["detectMult"] = detection_multiplier + if min_transmit_interval and min_transmit_interval not in range(250, 999): + module.fail_json(msg='The "min_transmit_interval" must be a value between 250 and 999') + else: + class_config["minTxIntvl"] = min_transmit_interval + if min_receive_interval and min_receive_interval not in range(250, 999): + module.fail_json(msg='The "min_receive_interval" must be a value between 250 and 999') + else: + class_config["minRxIntvl"] = min_receive_interval + aci.payload( aci_class="bfdMhIfPol", - class_config=dict( - name=name, - descr=description, - adminSt=admin_state, - detectMult=detection_multiplier, - minTxIntvl=min_transmit_interval, - minRxIntvl=min_receive_interval, - ), + class_config=class_config, ) aci.get_diff(aci_class="bfdMhIfPol") diff --git a/plugins/modules/aci_bfd_multihop_interface_profile.py b/plugins/modules/aci_bfd_multihop_interface_profile.py index 50dc063e4..bf4e0b80d 100644 --- a/plugins/modules/aci_bfd_multihop_interface_profile.py +++ b/plugins/modules/aci_bfd_multihop_interface_profile.py @@ -55,9 +55,9 @@ interface_profile_type: description: - Authentication Type of the BFD Multihop Interface Profile object. + - APIC sets the default value to none. type: str choices: [ none, sha1 ] - default: none key: description: - Authentication Key of the BFD Multihop Interface Profile object. @@ -65,9 +65,9 @@ key_id: description: - Authentication Key ID of the BFD Multihop Interface Profile object. + - APIC sets the default value to 3. - Allowed range is 1-255 type: int - default: 3 bfd_multihop_interface_policy: description: - The name of the BFD Multihop Interface policy. @@ -257,9 +257,9 @@ def main(): name=dict(type="str", aliases=["bfd_multihop_interface_profile"]), name_alias=dict(type="str"), description=dict(type="str", aliases=["descr"]), - interface_profile_type=dict(type="str", default="none", choices=["none", "sha1"]), + interface_profile_type=dict(type="str", choices=["none", "sha1"]), key=dict(type="str", no_log=True), - key_id=dict(type="int", default=3), + key_id=dict(type="int"), bfd_multihop_interface_policy=dict(type="str", aliases=["multihop_interface_policy", "multihop_interface_policy_name"]), state=dict(type="str", default="present", choices=["absent", "present", "query"]), ) @@ -283,8 +283,6 @@ def main(): interface_profile_type = module.params.get("interface_profile_type") key = module.params.get("key") key_id = module.params.get("key_id") - if key_id is not None and key_id not in range(1, 255): - module.fail_json(msg='The "key_id" must be a value between 1 and 255') bfd_multihop_interface_policy = module.params.get("bfd_multihop_interface_policy") state = module.params.get("state") @@ -326,16 +324,22 @@ def main(): aci.get_existing() if state == "present": + class_config = dict( + name=name, + nameAlias=name_alias, + descr=description, + type=interface_profile_type, + key=key, + ) + + if key_id and key_id not in range(1, 255): + module.fail_json(msg='The "key_id" must be a value between 1 and 255') + else: + class_config["keyId"] = key_id + aci.payload( aci_class="bfdMhIfP", - class_config=dict( - name=name, - nameAlias=name_alias, - descr=description, - type=interface_profile_type, - key=key, - keyId=key_id, - ), + class_config=class_config, child_configs=[dict(bfdRsMhIfPol=dict(attributes=dict(tnBfdMhIfPolName=bfd_multihop_interface_policy)))], ) diff --git a/plugins/modules/aci_bfd_multihop_node_policy.py b/plugins/modules/aci_bfd_multihop_node_policy.py index 6a1453c92..58fd06297 100644 --- a/plugins/modules/aci_bfd_multihop_node_policy.py +++ b/plugins/modules/aci_bfd_multihop_node_policy.py @@ -40,21 +40,21 @@ detection_multiplier: description: - Detection multiplier of the BFD Multihop Node policy + - APIC sets the default value to 3. - Allowed range is 1-50. type: int - default: 3 min_transmit_interval: description: - Minimum transmit (Tx) interval of the BFD Multihop Node policy + - APIC sets the default value to 250. - Allowed range is 250-999. type: int - default: 250 min_receive_interval: description: - Minimum receive (Rx) interval of the BFD Multihop Node policy + - APIC sets the default value to 250. - Allowed range is 250-999. type: int - default: 250 state: description: - Use C(present) or C(absent) for adding or removing. @@ -237,9 +237,9 @@ def main(): name=dict(type="str", aliases=["bfd_multihop_node_policy"]), description=dict(type="str"), admin_state=dict(type="str", default="enabled", choices=["enabled", "disabled"]), - detection_multiplier=dict(type="int", default=3), - min_transmit_interval=dict(type="int", default=250), - min_receive_interval=dict(type="int", default=250), + detection_multiplier=dict(type="int"), + min_transmit_interval=dict(type="int"), + min_receive_interval=dict(type="int"), state=dict(type="str", default="present", choices=["absent", "present", "query"]), tenant=dict(type="str"), ) @@ -259,14 +259,8 @@ def main(): tenant = module.params.get("tenant") admin_state = module.params.get("admin_state") detection_multiplier = module.params.get("detection_multiplier") - if detection_multiplier is not None and detection_multiplier not in range(1, 50): - module.fail_json(msg='The "detection_multiplier" must be a value between 1 and 50') min_transmit_interval = module.params.get("min_transmit_interval") - if min_transmit_interval is not None and min_transmit_interval not in range(250, 999): - module.fail_json(msg='The "min_transmit_interval" must be a value between 250 and 999') min_receive_interval = module.params.get("min_receive_interval") - if min_receive_interval is not None and min_receive_interval not in range(250, 999): - module.fail_json(msg='The "min_receive_interval" must be a value between 250 and 999') aci = ACIModule(module) aci.construct_url( @@ -287,16 +281,28 @@ def main(): aci.get_existing() if state == "present": + class_config = dict( + name=name, + descr=description, + adminSt=admin_state, + ) + + if detection_multiplier and detection_multiplier not in range(1, 50): + aci.fail_json(msg='The "detection_multiplier" must be a value between 1 and 50') + else: + class_config["detectMult"] = detection_multiplier + if min_transmit_interval and min_transmit_interval not in range(250, 999): + aci.fail_json(msg='The "min_transmit_interval" must be a value between 250 and 999') + else: + class_config["minTxIntvl"] = min_transmit_interval + if min_receive_interval and min_receive_interval not in range(250, 999): + aci.fail_json(msg='The "min_receive_interval" must be a value between 250 and 999') + else: + class_config["minRxIntvl"] = min_receive_interval + aci.payload( aci_class="bfdMhNodePol", - class_config=dict( - name=name, - descr=description, - adminSt=admin_state, - detectMult=detection_multiplier, - minTxIntvl=min_transmit_interval, - minRxIntvl=min_receive_interval, - ), + class_config=class_config, ) aci.get_diff(aci_class="bfdMhNodePol") diff --git a/plugins/modules/aci_l3out_bfd_interface_profile.py b/plugins/modules/aci_l3out_bfd_interface_profile.py index 0b04e3031..3d16cbf53 100644 --- a/plugins/modules/aci_l3out_bfd_interface_profile.py +++ b/plugins/modules/aci_l3out_bfd_interface_profile.py @@ -55,9 +55,9 @@ interface_profile_type: description: - Authentication Type of the L3Out BFD Interface profile object. + - APIC sets the default value to none. type: str choices: [ none, sha1 ] - default: none key: description: - Authentication Key of the L3Out BFD Interface profile object. @@ -65,9 +65,9 @@ key_id: description: - Authentication Key ID of the L3Out BFD Interface profile object. + - APIC sets the default value to 3. - Allowed range is 1-255 type: int - default: 3 bfd_interface_policy: description: - The name of the Interface policy. @@ -257,9 +257,9 @@ def main(): name=dict(type="str", aliases=["bfd_multihop_interface_profile"]), name_alias=dict(type="str"), description=dict(type="str", aliases=["descr"]), - interface_profile_type=dict(type="str", default="none", choices=["none", "sha1"]), + interface_profile_type=dict(type="str", choices=["none", "sha1"]), key=dict(type="str", no_log=True), - key_id=dict(type="int", default=3), + key_id=dict(type="int"), bfd_interface_policy=dict(type="str", aliases=["interface_policy", "interface_policy_name"]), state=dict(type="str", default="present", choices=["absent", "present", "query"]), ) @@ -283,8 +283,6 @@ def main(): interface_profile_type = module.params.get("interface_profile_type") key = module.params.get("key") key_id = module.params.get("key_id") - if key_id is not None and key_id not in range(1, 255): - module.fail_json(msg='The "key_id" must be a value between 1 and 255') bfd_interface_policy = module.params.get("bfd_interface_policy") state = module.params.get("state") @@ -326,16 +324,24 @@ def main(): aci.get_existing() if state == "present": + class_config=dict( + name=name, + nameAlias=name_alias, + descr=description, + key=key, + ) + + if key_id and key_id not in range(1, 255): + module.fail_json(msg='The "key_id" must be a value between 1 and 255') + else: + class_config["keyId"] = key_id + + if interface_profile_type: + class_config["type"] = interface_profile_type + aci.payload( aci_class="bfdIfP", - class_config=dict( - name=name, - nameAlias=name_alias, - descr=description, - type=interface_profile_type, - key=key, - keyId=key_id, - ), + class_config=class_config, child_configs=[dict(bfdRsIfPol=dict(attributes=dict(tnBfdIfPolName=bfd_interface_policy)))], ) diff --git a/tests/integration/targets/aci_bfd_interface_policy/tasks/main.yml b/tests/integration/targets/aci_bfd_interface_policy/tasks/main.yml index 0ffffe0ea..ecd838862 100644 --- a/tests/integration/targets/aci_bfd_interface_policy/tasks/main.yml +++ b/tests/integration/targets/aci_bfd_interface_policy/tasks/main.yml @@ -71,9 +71,6 @@ - cm_add_bfd_interface_pol.proposed.bfdIfPol.attributes.name == nm_add_bfd_interface_pol.current.0.bfdIfPol.attributes.name == "ansible_bfd_interface_policy" - cm_add_bfd_interface_pol.proposed.bfdIfPol.attributes.descr == nm_add_bfd_interface_pol.current.0.bfdIfPol.attributes.descr == "Ansible BFD Interface Policy" - cm_add_bfd_interface_pol.proposed.bfdIfPol.attributes.adminSt == nm_add_bfd_interface_pol.current.0.bfdIfPol.attributes.adminSt == "enabled" - - cm_add_bfd_interface_pol.proposed.bfdIfPol.attributes.detectMult == nm_add_bfd_interface_pol.current.0.bfdIfPol.attributes.detectMult == "3" - - cm_add_bfd_interface_pol.proposed.bfdIfPol.attributes.minRxIntvl == nm_add_bfd_interface_pol.current.0.bfdIfPol.attributes.minRxIntvl == "50" - - cm_add_bfd_interface_pol.proposed.bfdIfPol.attributes.minTxIntvl == nm_add_bfd_interface_pol.current.0.bfdIfPol.attributes.minTxIntvl == "50" - name: Add a new BFD Interface policy again - idempotency cisco.aci.aci_bfd_interface_policy: diff --git a/tests/integration/targets/aci_bfd_multihop_interface_policy/tasks/main.yml b/tests/integration/targets/aci_bfd_multihop_interface_policy/tasks/main.yml index 11f66b13c..79967e070 100644 --- a/tests/integration/targets/aci_bfd_multihop_interface_policy/tasks/main.yml +++ b/tests/integration/targets/aci_bfd_multihop_interface_policy/tasks/main.yml @@ -71,9 +71,6 @@ - cm_add_bfd_multihop_interface_pol.proposed.bfdMhIfPol.attributes.name == nm_add_bfd_multihop_interface_pol.current.0.bfdMhIfPol.attributes.name == "ansible_bfd_multihop_interface_policy" - cm_add_bfd_multihop_interface_pol.proposed.bfdMhIfPol.attributes.descr == nm_add_bfd_multihop_interface_pol.current.0.bfdMhIfPol.attributes.descr == "Ansible BFD Multihop Interface Policy" - cm_add_bfd_multihop_interface_pol.proposed.bfdMhIfPol.attributes.adminSt == nm_add_bfd_multihop_interface_pol.current.0.bfdMhIfPol.attributes.adminSt == "enabled" - - cm_add_bfd_multihop_interface_pol.proposed.bfdMhIfPol.attributes.detectMult == nm_add_bfd_multihop_interface_pol.current.0.bfdMhIfPol.attributes.detectMult == "3" - - cm_add_bfd_multihop_interface_pol.proposed.bfdMhIfPol.attributes.minRxIntvl == nm_add_bfd_multihop_interface_pol.current.0.bfdMhIfPol.attributes.minRxIntvl == "250" - - cm_add_bfd_multihop_interface_pol.proposed.bfdMhIfPol.attributes.minTxIntvl == nm_add_bfd_multihop_interface_pol.current.0.bfdMhIfPol.attributes.minTxIntvl == "250" - name: Add a new BFD Multihop Interface policy again - idempotency cisco.aci.aci_bfd_multihop_interface_policy: diff --git a/tests/integration/targets/aci_bfd_multihop_interface_profile/tasks/main.yml b/tests/integration/targets/aci_bfd_multihop_interface_profile/tasks/main.yml index 4c91d9ecb..97f83cdbd 100644 --- a/tests/integration/targets/aci_bfd_multihop_interface_profile/tasks/main.yml +++ b/tests/integration/targets/aci_bfd_multihop_interface_profile/tasks/main.yml @@ -114,8 +114,6 @@ - nm_add_bfd_mh_int_prof is changed - cm_add_bfd_mh_int_prof.previous == nm_add_bfd_mh_int_prof.previous == [] - cm_add_bfd_mh_int_prof.proposed.bfdMhIfP.attributes.dn == nm_add_bfd_mh_int_prof.proposed.bfdMhIfP.attributes.dn == "uni/tn-ansible_tenant/out-ansible_l3out/lnodep-ansible_node_profile/lifp-ansible_interface_profile/bfdMhIfP" - - cm_add_bfd_mh_int_prof.proposed.bfdMhIfP.attributes.keyId == nm_add_bfd_mh_int_prof.proposed.bfdMhIfP.attributes.keyId == "3" - - cm_add_bfd_mh_int_prof.proposed.bfdMhIfP.attributes.type == nm_add_bfd_mh_int_prof.proposed.bfdMhIfP.attributes.type == "none" - name: Add BFD Multihop Interface Profile again- idempotency cisco.aci.aci_bfd_multihop_interface_profile: @@ -154,7 +152,7 @@ that: - update_bfd_mh_int_prof is changed - update_bfd_mh_int_prof.sent.bfdMhIfP.attributes.keyId == "15" - - update_bfd_mh_int_prof.sent.bfdMhIfP.attributes.key == "abc*123" + - update_bfd_mh_int_prof.sent.bfdMhIfP.attributes.key == "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER" - update_bfd_mh_int_prof.sent.bfdMhIfP.attributes.type == "sha1" - update_bfd_mh_int_prof.sent.bfdMhIfP.children.0.bfdRsMhIfPol.attributes.tnBfdMhIfPolName == "ansible_bfd_multihop_interface_policy" diff --git a/tests/integration/targets/aci_bfd_multihop_node_policy/tasks/main.yml b/tests/integration/targets/aci_bfd_multihop_node_policy/tasks/main.yml index 98a96aac7..cbcb2c478 100644 --- a/tests/integration/targets/aci_bfd_multihop_node_policy/tasks/main.yml +++ b/tests/integration/targets/aci_bfd_multihop_node_policy/tasks/main.yml @@ -71,9 +71,6 @@ - cm_add_bfd_multihop_node_pol.proposed.bfdMhNodePol.attributes.name == nm_add_bfd_multihop_node_pol.current.0.bfdMhNodePol.attributes.name == "ansible_bfd_multihop_node_policy" - cm_add_bfd_multihop_node_pol.proposed.bfdMhNodePol.attributes.descr == nm_add_bfd_multihop_node_pol.current.0.bfdMhNodePol.attributes.descr == "Ansible BFD Multihop Node Policy" - cm_add_bfd_multihop_node_pol.proposed.bfdMhNodePol.attributes.adminSt == nm_add_bfd_multihop_node_pol.current.0.bfdMhNodePol.attributes.adminSt == "enabled" - - cm_add_bfd_multihop_node_pol.proposed.bfdMhNodePol.attributes.detectMult == nm_add_bfd_multihop_node_pol.current.0.bfdMhNodePol.attributes.detectMult == "3" - - cm_add_bfd_multihop_node_pol.proposed.bfdMhNodePol.attributes.minRxIntvl == nm_add_bfd_multihop_node_pol.current.0.bfdMhNodePol.attributes.minRxIntvl == "250" - - cm_add_bfd_multihop_node_pol.proposed.bfdMhNodePol.attributes.minTxIntvl == nm_add_bfd_multihop_node_pol.current.0.bfdMhNodePol.attributes.minTxIntvl == "250" - name: Add a new BFD Multihop Node policy again - idempotency cisco.aci.aci_bfd_multihop_node_policy: diff --git a/tests/integration/targets/aci_l3out_bfd_interface_profile/tasks/main.yml b/tests/integration/targets/aci_l3out_bfd_interface_profile/tasks/main.yml index 11e1ef26c..0ec6478f6 100644 --- a/tests/integration/targets/aci_l3out_bfd_interface_profile/tasks/main.yml +++ b/tests/integration/targets/aci_l3out_bfd_interface_profile/tasks/main.yml @@ -114,8 +114,6 @@ - nm_add_l3out_bfd_int_prof is changed - cm_add_l3out_bfd_int_prof.previous == nm_add_l3out_bfd_int_prof.previous == [] - cm_add_l3out_bfd_int_prof.proposed.bfdIfP.attributes.dn == nm_add_l3out_bfd_int_prof.proposed.bfdIfP.attributes.dn == "uni/tn-ansible_tenant/out-ansible_l3out/lnodep-ansible_node_profile/lifp-ansible_interface_profile/bfdIfP" - - cm_add_l3out_bfd_int_prof.proposed.bfdIfP.attributes.keyId == nm_add_l3out_bfd_int_prof.proposed.bfdIfP.attributes.keyId == "3" - - cm_add_l3out_bfd_int_prof.proposed.bfdIfP.attributes.type == nm_add_l3out_bfd_int_prof.proposed.bfdIfP.attributes.type == "none" - name: Add L3Out BFD Interface Profile again- idempotency cisco.aci.aci_l3out_bfd_interface_profile: @@ -154,7 +152,7 @@ that: - update_l3out_bfd_int_prof is changed - update_l3out_bfd_int_prof.sent.bfdIfP.attributes.keyId == "15" - - update_l3out_bfd_int_prof.sent.bfdIfP.attributes.key == "abc*123" + - update_l3out_bfd_int_prof.sent.bfdIfP.attributes.key == "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER" - update_l3out_bfd_int_prof.sent.bfdIfP.attributes.type == "sha1" - update_l3out_bfd_int_prof.sent.bfdIfP.children.0.bfdRsIfPol.attributes.tnBfdIfPolName == "ansible_bfd_interface_policy" @@ -211,4 +209,4 @@ - nm_remove_l3out_bfd_int_prof is changed - cm_remove_l3out_bfd_int_prof.proposed == nm_remove_l3out_bfd_int_prof.proposed == {} - remove_l3out_bfd_int_prof_again is not changed - - nm_add_l3out_bfd_int_prof.current == remove_l3out_bfd_int_prof_again.current == [] \ No newline at end of file + - nm_remove_l3out_bfd_int_prof.current == remove_l3out_bfd_int_prof_again.current == [] \ No newline at end of file From a0e55b3fd21ce9cd2ef70e2792b5e21a5688d0a3 Mon Sep 17 00:00:00 2001 From: anvitha-jain Date: Tue, 21 Nov 2023 16:08:20 -0800 Subject: [PATCH 07/10] [minor_changes] Accomodated removing the children by setting them to empty string - the value is set to default by the UI --- plugins/modules/aci_bfd_interface_policy.py | 19 ++++---- .../aci_bfd_multihop_interface_policy.py | 25 ++++++----- .../modules/aci_bfd_multihop_node_policy.py | 11 ++--- .../aci_l3out_bfd_interface_profile.py | 26 +++++++---- ...i_l3out_bfd_multihop_interface_profile.py} | 35 +++++++++------ .../tasks/main.yml | 45 ++++++++++++++----- .../tasks/main.yml | 38 +++++++++++----- 7 files changed, 127 insertions(+), 72 deletions(-) rename plugins/modules/{aci_bfd_multihop_interface_profile.py => aci_l3out_bfd_multihop_interface_profile.py} (90%) diff --git a/plugins/modules/aci_bfd_interface_policy.py b/plugins/modules/aci_bfd_interface_policy.py index b29c7a76e..93d32c6b8 100644 --- a/plugins/modules/aci_bfd_interface_policy.py +++ b/plugins/modules/aci_bfd_interface_policy.py @@ -1,7 +1,7 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -# Copyright: (c) 2023, Anvitha Jain (@anvjain) +# Copyright: (c) 2023, Anvitha Jain (@anvjain) # 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 @@ -15,7 +15,7 @@ module: aci_bfd_interface_policy short_description: Manage BFD Interface policies. description: -- Manage BFD Interface policy (bfdMhIfPol) configuration on Cisco ACI fabrics. +- Manage BFD Interface policy (bfd:IfPol) configuration on Cisco ACI fabrics. - Only available in APIC version 5.2 or later. options: tenant: @@ -34,9 +34,9 @@ admin_state: description: - Admin state of the BFD Interface policy + - APIC sets the default value to enabled. type: str choices: [ enabled, disabled ] - default: enabled detection_multiplier: description: - Detection multiplier of the BFD Interface policy @@ -71,8 +71,9 @@ The M(cisco.aci.aci_tenant) modules can be used for this. seealso: - name: APIC Management Information Model reference - description: More information about the internal APIC class B(bfdMhIfPol). + description: More information about the internal APIC class B(bfd:IfPol). link: https://developer.cisco.com/docs/apic-mim-ref/ +- module: cisco.aci.aci_tenant author: - Anvitha Jain (@anvjain) """ @@ -234,7 +235,7 @@ def main(): argument_spec.update( name=dict(type="str", aliases=["bfd_interface_policy"]), description=dict(type="str"), - admin_state=dict(type="str", default="enabled", choices=["enabled", "disabled"]), + admin_state=dict(type="str", choices=["enabled", "disabled"]), detection_multiplier=dict(type="int"), min_transmit_interval=dict(type="int"), min_receive_interval=dict(type="int"), @@ -279,22 +280,22 @@ def main(): aci.get_existing() if state == "present": - class_config=dict( + class_config = dict( name=name, descr=description, adminSt=admin_state, ) if detection_multiplier and detection_multiplier not in range(1, 50): - module.fail_json(msg='The "detection_multiplier" must be a value between 1 and 50') + module.fail_json(msg='The "detection_multiplier" must be a value between 1 and 50') else: class_config["detectMult"] = detection_multiplier if min_transmit_interval and min_transmit_interval not in range(50, 999): - module.fail_json(msg='The "min_transmit_interval" must be a value between 50 and 999') + module.fail_json(msg='The "min_transmit_interval" must be a value between 50 and 999') else: class_config["minTxIntvl"] = min_transmit_interval if min_receive_interval and min_receive_interval not in range(50, 999): - module.fail_json(msg='The "min_receive_interval" must be a value between 50 and 999') + module.fail_json(msg='The "min_receive_interval" must be a value between 50 and 999') else: class_config["minRxIntvl"] = min_receive_interval diff --git a/plugins/modules/aci_bfd_multihop_interface_policy.py b/plugins/modules/aci_bfd_multihop_interface_policy.py index 48d876bc6..f2c8c4830 100644 --- a/plugins/modules/aci_bfd_multihop_interface_policy.py +++ b/plugins/modules/aci_bfd_multihop_interface_policy.py @@ -1,7 +1,7 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -# Copyright: (c) 2023, Anvitha Jain (@anvjain) +# Copyright: (c) 2023, Anvitha Jain (@anvjain) # 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 @@ -15,7 +15,7 @@ module: aci_bfd_multihop_interface_policy short_description: Manage BFD Multihop Interface policies. description: -- Manage BFD Multihop Interface policy (bfdMhIfPol) configuration on Cisco ACI fabrics. +- Manage BFD Multihop Interface policy (bfd:MhIfPol) configuration on Cisco ACI fabrics. - Only available in APIC version 5.2 or later. options: tenant: @@ -34,9 +34,9 @@ admin_state: description: - Admin state of the BFD Multihop Interface policy + - APIC sets the default value to enabled. type: str choices: [ enabled, disabled ] - default: enabled detection_multiplier: description: - Detection multiplier of the BFD Multihop Interface policy @@ -71,8 +71,9 @@ The M(cisco.aci.aci_tenant) modules can be used for this. seealso: - name: APIC Management Information Model reference - description: More information about the internal APIC class B(bfdMhIfPol). + description: More information about the internal APIC class B(bfd:MhIfPol). link: https://developer.cisco.com/docs/apic-mim-ref/ +- module: cisco.aci.aci_tenant author: - Anvitha Jain (@anvjain) """ @@ -234,10 +235,10 @@ def main(): argument_spec.update( name=dict(type="str", aliases=["bfd_multihop_interface_policy"]), description=dict(type="str"), - admin_state=dict(type="str", default="enabled", choices=["enabled", "disabled"]), - detection_multiplier=dict(type="int", default=3), - min_transmit_interval=dict(type="int", default=250), - min_receive_interval=dict(type="int", default=250), + admin_state=dict(type="str", choices=["enabled", "disabled"]), + detection_multiplier=dict(type="int"), + min_transmit_interval=dict(type="int"), + min_receive_interval=dict(type="int"), state=dict(type="str", default="present", choices=["absent", "present", "query"]), tenant=dict(type="str"), ) @@ -279,22 +280,22 @@ def main(): aci.get_existing() if state == "present": - class_config=dict( + class_config = dict( name=name, descr=description, adminSt=admin_state, ) if detection_multiplier and detection_multiplier not in range(1, 50): - module.fail_json(msg='The "detection_multiplier" must be a value between 1 and 50') + module.fail_json(msg='The "detection_multiplier" must be a value between 1 and 50') else: class_config["detectMult"] = detection_multiplier if min_transmit_interval and min_transmit_interval not in range(250, 999): - module.fail_json(msg='The "min_transmit_interval" must be a value between 250 and 999') + module.fail_json(msg='The "min_transmit_interval" must be a value between 250 and 999') else: class_config["minTxIntvl"] = min_transmit_interval if min_receive_interval and min_receive_interval not in range(250, 999): - module.fail_json(msg='The "min_receive_interval" must be a value between 250 and 999') + module.fail_json(msg='The "min_receive_interval" must be a value between 250 and 999') else: class_config["minRxIntvl"] = min_receive_interval diff --git a/plugins/modules/aci_bfd_multihop_node_policy.py b/plugins/modules/aci_bfd_multihop_node_policy.py index 58fd06297..300b9e75d 100644 --- a/plugins/modules/aci_bfd_multihop_node_policy.py +++ b/plugins/modules/aci_bfd_multihop_node_policy.py @@ -1,7 +1,7 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -# Copyright: (c) 2023, Anvitha Jain (@anvjain) +# Copyright: (c) 2023, Anvitha Jain (@anvjain) # 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 @@ -15,7 +15,7 @@ module: aci_bfd_multihop_node_policy short_description: Manage BFD Multihop Node policies. description: -- Manage BFD Multihop Node policy (bfdMhNodePol) configuration on Cisco ACI fabrics. +- Manage BFD Multihop Node policy (bfd:MhNodePol) configuration on Cisco ACI fabrics. - Only available in APIC version 5.2 or later. options: tenant: @@ -34,9 +34,9 @@ admin_state: description: - Admin state of the BFD Multihop Node policy + - APIC sets the default value to enabled. type: str choices: [ enabled, disabled ] - default: enabled detection_multiplier: description: - Detection multiplier of the BFD Multihop Node policy @@ -71,8 +71,9 @@ The M(cisco.aci.aci_tenant) modules can be used for this. seealso: - name: APIC Management Information Model reference - description: More information about the internal APIC class B(bfdMhNodePol). + description: More information about the internal APIC class B(bfd:MhNodePol). link: https://developer.cisco.com/docs/apic-mim-ref/ +- module: cisco.aci.aci_tenant author: - Anvitha Jain (@anvjain) """ @@ -236,7 +237,7 @@ def main(): argument_spec.update( name=dict(type="str", aliases=["bfd_multihop_node_policy"]), description=dict(type="str"), - admin_state=dict(type="str", default="enabled", choices=["enabled", "disabled"]), + admin_state=dict(type="str", choices=["enabled", "disabled"]), detection_multiplier=dict(type="int"), min_transmit_interval=dict(type="int"), min_receive_interval=dict(type="int"), diff --git a/plugins/modules/aci_l3out_bfd_interface_profile.py b/plugins/modules/aci_l3out_bfd_interface_profile.py index 3d16cbf53..ce993f922 100644 --- a/plugins/modules/aci_l3out_bfd_interface_profile.py +++ b/plugins/modules/aci_l3out_bfd_interface_profile.py @@ -1,7 +1,7 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -# Copyright: (c) 2023, Anvitha Jain (@anvjain) +# Copyright: (c) 2023, Anvitha Jain (@anvjain) # 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 @@ -15,7 +15,7 @@ module: aci_l3out_bfd_interface_profile short_description: Manage L3Out BFD Interface profile. description: -- Manage L3Out BFD Interface profile (bfdIfP) configuration on Cisco ACI fabrics. +- Manage L3Out BFD Interface profile (bfd:IfP) configuration on Cisco ACI fabrics. - Only available in APIC version 5.2 or later and for non-cloud APICs. options: tenant: @@ -89,8 +89,13 @@ The M(cisco.aci.aci_tenant) modules can be used for this. seealso: - name: APIC Management Information Model reference - description: More information about the internal APIC class B(bfdIfP). + description: More information about the internal APIC class B(bfd:IfP). link: https://developer.cisco.com/docs/apic-mim-ref/ +- module: cisco.aci.aci_tenant +- module: cisco.aci.aci_l3out +- module: cisco.aci.aci_l3out_logical_node_profile +- module: cisco.aci.aci_l3out_logical_interface_profile +- module: cisco.aci.aci_bfd_interface_policy author: - Anvitha Jain (@anvjain) """ @@ -269,7 +274,8 @@ def main(): supports_check_mode=True, required_if=[ ["state", "absent", ["tenant", "l3out", "l3out_logical_node_profile", "l3out_logical_interface_profile"]], - ["state", "present", ["tenant", "l3out", "l3out_logical_node_profile", "l3out_logical_interface_profile"]], + ["state", "present", ["tenant", "l3out", "l3out_logical_node_profile", "l3out_logical_interface_profile", "bfd_interface_policy"]], + ["interface_profile_type", "sha1", ["key"]], ], ) @@ -316,7 +322,7 @@ def main(): aci_class="bfdIfP", aci_rn="bfdIfP", module_object="bfdIfP", - target_filter={"name": ""}, + target_filter={"name": name}, ), child_classes=["bfdRsIfPol"], ) @@ -324,11 +330,13 @@ def main(): aci.get_existing() if state == "present": - class_config=dict( + child_configs = [] + class_config = dict( name=name, nameAlias=name_alias, descr=description, key=key, + type=interface_profile_type, ) if key_id and key_id not in range(1, 255): @@ -336,13 +344,13 @@ def main(): else: class_config["keyId"] = key_id - if interface_profile_type: - class_config["type"] = interface_profile_type + if bfd_interface_policy is not None: + child_configs.append(dict(bfdRsIfPol=dict(attributes=dict(tnBfdIfPolName=bfd_interface_policy)))) aci.payload( aci_class="bfdIfP", class_config=class_config, - child_configs=[dict(bfdRsIfPol=dict(attributes=dict(tnBfdIfPolName=bfd_interface_policy)))], + child_configs=child_configs, ) aci.get_diff(aci_class="bfdIfP") diff --git a/plugins/modules/aci_bfd_multihop_interface_profile.py b/plugins/modules/aci_l3out_bfd_multihop_interface_profile.py similarity index 90% rename from plugins/modules/aci_bfd_multihop_interface_profile.py rename to plugins/modules/aci_l3out_bfd_multihop_interface_profile.py index bf4e0b80d..84869b2b8 100644 --- a/plugins/modules/aci_bfd_multihop_interface_profile.py +++ b/plugins/modules/aci_l3out_bfd_multihop_interface_profile.py @@ -1,7 +1,7 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -# Copyright: (c) 2023, Anvitha Jain (@anvjain) +# Copyright: (c) 2023, Anvitha Jain (@anvjain) # 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 @@ -12,10 +12,10 @@ DOCUMENTATION = r""" --- -module: aci_bfd_multihop_interface_profile +module: aci_l3out_bfd_multihop_interface_profile short_description: Manage BFD Multihop Interface profile. description: -- Manage BFD Multihop Interface profile (bfdMhIfP) configuration on Cisco ACI fabrics. +- Manage BFD Multihop Interface profile (bfd:MhIfP) configuration on Cisco ACI fabrics. - Only available in APIC version 5.2 or later and for non-cloud APICs. options: tenant: @@ -89,15 +89,20 @@ The M(cisco.aci.aci_tenant) modules can be used for this. seealso: - name: APIC Management Information Model reference - description: More information about the internal APIC class B(bfdMhIfP). + description: More information about the internal APIC class B(bfd:MhIfP). link: https://developer.cisco.com/docs/apic-mim-ref/ +- module: cisco.aci.aci_tenant +- module: cisco.aci.aci_l3out +- module: cisco.aci.aci_l3out_logical_node_profile +- module: cisco.aci.aci_l3out_logical_interface_profile +- module: cisco.aci.aci_bfd_multihop_interface_policy author: - Anvitha Jain (@anvjain) """ EXAMPLES = r""" - name: Add a new L3Out BFD Multihop Interface Profile - cisco.aci.aci_bfd_multihop_interface_profile: + cisco.aci.aci_l3out_bfd_multihop_interface_profile: username: admin password: SomeSecretPassword tenant: ansible_tenant @@ -108,7 +113,7 @@ delegate_to: localhost - name: Query a new L3Out BFD Multihop Interface Profile - cisco.aci.aci_bfd_multihop_interface_profile: + cisco.aci.aci_l3out_bfd_multihop_interface_profile: username: admin password: SomeSecretPassword tenant: ansible_tenant @@ -119,14 +124,14 @@ delegate_to: localhost - name: Query all L3Out BFD Multihop Interface Profile - cisco.aci.aci_bfd_multihop_interface_profile: + cisco.aci.aci_l3out_bfd_multihop_interface_profile: username: admin password: SomeSecretPassword state: query delegate_to: localhost - name: Delete L3Out BFD Multihop Interface Profile - cisco.aci.aci_bfd_multihop_interface_profile: + cisco.aci.aci_l3out_bfd_multihop_interface_profile: username: admin password: SomeSecretPassword tenant: ansible_tenant @@ -269,7 +274,7 @@ def main(): supports_check_mode=True, required_if=[ ["state", "absent", ["tenant", "l3out", "l3out_logical_node_profile", "l3out_logical_interface_profile"]], - ["state", "present", ["tenant", "l3out", "l3out_logical_node_profile", "l3out_logical_interface_profile"]], + ["state", "present", ["tenant", "l3out", "l3out_logical_node_profile", "l3out_logical_interface_profile", "bfd_multihop_interface_policy"]], ], ) @@ -316,14 +321,15 @@ def main(): aci_class="bfdMhIfP", aci_rn="bfdMhIfP", module_object="bfdMhIfP", - target_filter={"name": ""}, + target_filter={"name": name}, ), - child_classes=["bfdMhIfPol"], + child_classes=["bfdRsMhIfPol"], ) aci.get_existing() - + aci.stdout = str(aci.get_existing()) if state == "present": + child_configs = [] class_config = dict( name=name, nameAlias=name_alias, @@ -337,10 +343,13 @@ def main(): else: class_config["keyId"] = key_id + if bfd_multihop_interface_policy is not None: + child_configs.append(dict(bfdRsMhIfPol=dict(attributes=dict(tnBfdMhIfPolName=bfd_multihop_interface_policy)))) + aci.payload( aci_class="bfdMhIfP", class_config=class_config, - child_configs=[dict(bfdRsMhIfPol=dict(attributes=dict(tnBfdMhIfPolName=bfd_multihop_interface_policy)))], + child_configs=child_configs, ) aci.get_diff(aci_class="bfdMhIfP") diff --git a/tests/integration/targets/aci_bfd_multihop_interface_profile/tasks/main.yml b/tests/integration/targets/aci_bfd_multihop_interface_profile/tasks/main.yml index 97f83cdbd..824ffd2d4 100644 --- a/tests/integration/targets/aci_bfd_multihop_interface_profile/tasks/main.yml +++ b/tests/integration/targets/aci_bfd_multihop_interface_profile/tasks/main.yml @@ -89,6 +89,16 @@ interface_profile: ansible_interface_profile state: present + # CREATE BFD Multihop Interface policy + - name: Add a new BFD Multihop Interface policy + cisco.aci.aci_bfd_multihop_interface_policy: + <<: *aci_info + tenant: ansible_tenant + name: ansible_bfd_multihop_interface_policy + description: Ansible BFD Multihop Interface Policy + state: present + register: add_bfd_multihop_interface_pol + # Add BFD Multihop Interface Profile - name: Add a new BFD Multihop Interface Profile - check mode cisco.aci.aci_bfd_multihop_interface_profile: &present_bfd_mh_int_profile @@ -97,6 +107,7 @@ l3out: ansible_l3out l3out_logical_node_profile: ansible_node_profile l3out_logical_interface_profile: ansible_interface_profile + bfd_multihop_interface_policy: ansible_bfd_multihop_interface_policy state: present check_mode: true register: cm_add_bfd_mh_int_prof @@ -114,6 +125,14 @@ - nm_add_bfd_mh_int_prof is changed - cm_add_bfd_mh_int_prof.previous == nm_add_bfd_mh_int_prof.previous == [] - cm_add_bfd_mh_int_prof.proposed.bfdMhIfP.attributes.dn == nm_add_bfd_mh_int_prof.proposed.bfdMhIfP.attributes.dn == "uni/tn-ansible_tenant/out-ansible_l3out/lnodep-ansible_node_profile/lifp-ansible_interface_profile/bfdMhIfP" + - cm_add_bfd_mh_int_prof.proposed.bfdMhIfP.children.0.bfdRsMhIfPol.attributes.tnBfdMhIfPolName == nm_add_bfd_mh_int_prof.proposed.bfdMhIfP.children.0.bfdRsMhIfPol.attributes.tnBfdMhIfPolName == "ansible_bfd_multihop_interface_policy" + + # Query BFD Multihop Interface Profile + - name: Query BFD Multihop Interface Profile + cisco.aci.aci_bfd_multihop_interface_profile: + <<: *present_bfd_mh_int_profile + state: query + register: query_bfd_mh_int_prof - name: Add BFD Multihop Interface Profile again- idempotency cisco.aci.aci_bfd_multihop_interface_profile: @@ -126,16 +145,6 @@ that: - add_bfd_mh_int_prof_again is not changed - # CREATE BFD Multihop Interface policy - - name: Add a new BFD Multihop Interface policy - cisco.aci.aci_bfd_multihop_interface_policy: - <<: *aci_info - tenant: ansible_tenant - name: ansible_bfd_multihop_interface_policy - description: Ansible BFD Multihop Interface Policy - state: present - register: add_bfd_multihop_interface_pol - # Update BFD Multihop Interface Profile - name: Update BFD Multihop Interface Profile cisco.aci.aci_bfd_multihop_interface_profile: @@ -143,7 +152,6 @@ interface_profile_type: sha1 key: "abc*123" key_id: 15 - bfd_multihop_interface_policy: ansible_bfd_multihop_interface_policy state: present register: update_bfd_mh_int_prof @@ -154,8 +162,21 @@ - update_bfd_mh_int_prof.sent.bfdMhIfP.attributes.keyId == "15" - update_bfd_mh_int_prof.sent.bfdMhIfP.attributes.key == "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER" - update_bfd_mh_int_prof.sent.bfdMhIfP.attributes.type == "sha1" - - update_bfd_mh_int_prof.sent.bfdMhIfP.children.0.bfdRsMhIfPol.attributes.tnBfdMhIfPolName == "ansible_bfd_multihop_interface_policy" + # Remove children from L3Out BFD Interface Profile + - name: Remove children from BFD Multihop Interface Profile + cisco.aci.aci_bfd_multihop_interface_profile: + <<: *present_bfd_mh_int_profile + bfd_multihop_interface_policy: "" + register: remove_children_bfd_mh_int_prof + + - name: Asserts for children removal tasks for the from BFD Multihop Interface Profile + ansible.builtin.assert: + that: + - remove_children_bfd_mh_int_prof is changed + - remove_children_bfd_mh_int_prof.sent.bfdMhIfP.children.0.bfdRsMhIfPol.attributes.tnBfdMhIfPolName == "" + + # Query BFD Multihop Interface Profile - name: Query BFD Multihop Interface Profile cisco.aci.aci_bfd_multihop_interface_profile: <<: *present_bfd_mh_int_profile diff --git a/tests/integration/targets/aci_l3out_bfd_interface_profile/tasks/main.yml b/tests/integration/targets/aci_l3out_bfd_interface_profile/tasks/main.yml index 0ec6478f6..2c5383ead 100644 --- a/tests/integration/targets/aci_l3out_bfd_interface_profile/tasks/main.yml +++ b/tests/integration/targets/aci_l3out_bfd_interface_profile/tasks/main.yml @@ -89,6 +89,16 @@ interface_profile: ansible_interface_profile state: present + # CREATE L3Out BFD Interface policy + - name: Add a new L3Out BFD Interface policy + cisco.aci.aci_bfd_interface_policy: + <<: *aci_info + tenant: ansible_tenant + name: ansible_bfd__interface_policy + description: Ansible BFD Interface Policy + state: present + register: add_bfd_interface_pol + # Add L3Out BFD Interface Profile - name: Add a new L3Out BFD Interface Profile - check mode cisco.aci.aci_l3out_bfd_interface_profile: &present_l3out_bfd_int_profile @@ -97,6 +107,7 @@ l3out: ansible_l3out l3out_logical_node_profile: ansible_node_profile l3out_logical_interface_profile: ansible_interface_profile + bfd_interface_policy: ansible_bfd_interface_policy state: present check_mode: true register: cm_add_l3out_bfd_int_prof @@ -114,6 +125,7 @@ - nm_add_l3out_bfd_int_prof is changed - cm_add_l3out_bfd_int_prof.previous == nm_add_l3out_bfd_int_prof.previous == [] - cm_add_l3out_bfd_int_prof.proposed.bfdIfP.attributes.dn == nm_add_l3out_bfd_int_prof.proposed.bfdIfP.attributes.dn == "uni/tn-ansible_tenant/out-ansible_l3out/lnodep-ansible_node_profile/lifp-ansible_interface_profile/bfdIfP" + - cm_add_l3out_bfd_int_prof.proposed.bfdIfP.children.0.bfdRsIfPol.attributes.tnBfdIfPolName == cm_add_l3out_bfd_int_prof.proposed.bfdIfP.children.0.bfdRsIfPol.attributes.tnBfdIfPolName == "ansible_bfd_interface_policy" - name: Add L3Out BFD Interface Profile again- idempotency cisco.aci.aci_l3out_bfd_interface_profile: @@ -126,16 +138,6 @@ that: - add_l3out_bfd_int_prof_again is not changed - # CREATE L3Out BFD Interface policy - - name: Add a new L3Out BFD Interface policy - cisco.aci.aci_bfd_interface_policy: - <<: *aci_info - tenant: ansible_tenant - name: ansible_bfd__interface_policy - description: Ansible BFD Interface Policy - state: present - register: add_bfd_interface_pol - # Update L3Out BFD Interface Profile - name: Update L3Out BFD Interface Profile cisco.aci.aci_l3out_bfd_interface_profile: @@ -143,7 +145,6 @@ interface_profile_type: sha1 key: "abc*123" key_id: 15 - bfd_interface_policy: ansible_bfd_interface_policy state: present register: update_l3out_bfd_int_prof @@ -154,8 +155,21 @@ - update_l3out_bfd_int_prof.sent.bfdIfP.attributes.keyId == "15" - update_l3out_bfd_int_prof.sent.bfdIfP.attributes.key == "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER" - update_l3out_bfd_int_prof.sent.bfdIfP.attributes.type == "sha1" - - update_l3out_bfd_int_prof.sent.bfdIfP.children.0.bfdRsIfPol.attributes.tnBfdIfPolName == "ansible_bfd_interface_policy" + # Remove children from L3Out BFD Interface Profile + - name: Remove children from L3Out BFD Interface Profile + cisco.aci.aci_l3out_bfd_interface_profile: + <<: *present_l3out_bfd_int_profile + bfd_interface_policy: "" + register: remove_children_l3out_bfd_int_prof + + - name: Asserts for children removal tasks for the from L3Out BFD Interface Profile + ansible.builtin.assert: + that: + - remove_children_l3out_bfd_int_prof is changed + - remove_children_l3out_bfd_int_prof.sent.bfdIfP.children.0.bfdRsIfPol.attributes.tnBfdIfPolName == "" + + # Query L3Out BFD Interface Profile - name: Query L3Out BFD Interface Profile cisco.aci.aci_l3out_bfd_interface_profile: <<: *present_l3out_bfd_int_profile From df9420d5c4e10a7f1679d1a6863ea677e2b5b534 Mon Sep 17 00:00:00 2001 From: anvitha-jain Date: Thu, 30 Nov 2023 17:29:26 -0800 Subject: [PATCH 08/10] [minor_changes] Renamed policy modules --- .../modules/aci_bfd_multihop_node_policy.py | 30 ++++++------- ..._policy.py => aci_interface_policy_bfd.py} | 38 ++++++++--------- ...y => aci_interface_policy_bfd_multihop.py} | 30 ++++++------- .../aci_l3out_bfd_interface_profile.py | 40 +++++++++--------- ...ci_l3out_bfd_multihop_interface_profile.py | 42 +++++++++---------- .../tasks/main.yml | 1 - .../aliases | 0 .../tasks/main.yml | 27 ++++++------ .../aliases | 0 .../tasks/main.yml | 27 ++++++------ .../tasks/main.yml | 2 +- .../aliases | 0 .../tasks/main.yml | 26 ++++++------ 13 files changed, 130 insertions(+), 133 deletions(-) rename plugins/modules/{aci_bfd_interface_policy.py => aci_interface_policy_bfd.py} (92%) rename plugins/modules/{aci_bfd_multihop_interface_policy.py => aci_interface_policy_bfd_multihop.py} (93%) rename tests/integration/targets/{aci_bfd_interface_policy => aci_interface_policy_bfd}/aliases (100%) rename tests/integration/targets/{aci_bfd_interface_policy => aci_interface_policy_bfd}/tasks/main.yml (93%) rename tests/integration/targets/{aci_bfd_multihop_interface_policy => aci_interface_policy_bfd_multihop}/aliases (100%) rename tests/integration/targets/{aci_bfd_multihop_interface_policy => aci_interface_policy_bfd_multihop}/tasks/main.yml (92%) rename tests/integration/targets/{aci_bfd_multihop_interface_profile => aci_l3out_bfd_multihop_interface_profile}/aliases (100%) rename tests/integration/targets/{aci_bfd_multihop_interface_profile => aci_l3out_bfd_multihop_interface_profile}/tasks/main.yml (91%) diff --git a/plugins/modules/aci_bfd_multihop_node_policy.py b/plugins/modules/aci_bfd_multihop_node_policy.py index 300b9e75d..0e9cce0c5 100644 --- a/plugins/modules/aci_bfd_multihop_node_policy.py +++ b/plugins/modules/aci_bfd_multihop_node_policy.py @@ -13,14 +13,14 @@ DOCUMENTATION = r""" --- module: aci_bfd_multihop_node_policy -short_description: Manage BFD Multihop Node policies. +short_description: Manage BFD Multihop Node policies description: -- Manage BFD Multihop Node policy (bfd:MhNodePol) configuration on Cisco ACI fabrics. -- Only available in APIC version 5.2 or later. +- Manage BFD Multihop Node policy (bfd:MhNodePol) configuration on Cisco ACI fabrics +- Only available in APIC version 5.2 or later options: tenant: description: - - Name of an existing tenant. + - Name of an existing tenant type: str name: description: @@ -34,31 +34,31 @@ admin_state: description: - Admin state of the BFD Multihop Node policy - - APIC sets the default value to enabled. + - APIC sets the default value to enabled type: str choices: [ enabled, disabled ] detection_multiplier: description: - Detection multiplier of the BFD Multihop Node policy - - APIC sets the default value to 3. - - Allowed range is 1-50. + - APIC sets the default value to 3 + - Allowed range is 1-50 type: int min_transmit_interval: description: - Minimum transmit (Tx) interval of the BFD Multihop Node policy - - APIC sets the default value to 250. - - Allowed range is 250-999. + - APIC sets the default value to 250 + - Allowed range is 250-999 type: int min_receive_interval: description: - Minimum receive (Rx) interval of the BFD Multihop Node policy - - APIC sets the default value to 250. - - Allowed range is 250-999. + - APIC sets the default value to 250 + - Allowed range is 250-999 type: int state: description: - - Use C(present) or C(absent) for adding or removing. - - Use C(query) for listing an object or multiple objects. + - 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 @@ -67,8 +67,8 @@ - cisco.aci.annotation notes: -- The C(tenant) must exist before using this module in your playbook. - The M(cisco.aci.aci_tenant) modules can be used for this. +- The C(tenant) must exist before using this module in your playbook + The M(cisco.aci.aci_tenant) modules can be used for this seealso: - name: APIC Management Information Model reference description: More information about the internal APIC class B(bfd:MhNodePol). diff --git a/plugins/modules/aci_bfd_interface_policy.py b/plugins/modules/aci_interface_policy_bfd.py similarity index 92% rename from plugins/modules/aci_bfd_interface_policy.py rename to plugins/modules/aci_interface_policy_bfd.py index 93d32c6b8..89b4eedf4 100644 --- a/plugins/modules/aci_bfd_interface_policy.py +++ b/plugins/modules/aci_interface_policy_bfd.py @@ -12,15 +12,15 @@ DOCUMENTATION = r""" --- -module: aci_bfd_interface_policy -short_description: Manage BFD Interface policies. +module: aci_interface_policy_bfd +short_description: Manage BFD Interface policies description: -- Manage BFD Interface policy (bfd:IfPol) configuration on Cisco ACI fabrics. -- Only available in APIC version 5.2 or later. +- Manage BFD Interface policy (bfd:IfPol) configuration on Cisco ACI fabrics +- Only available in APIC version 5.2 or later options: tenant: description: - - Name of an existing tenant. + - Name of an existing tenant type: str name: description: @@ -34,26 +34,26 @@ admin_state: description: - Admin state of the BFD Interface policy - - APIC sets the default value to enabled. + - APIC sets the default value to enabled type: str choices: [ enabled, disabled ] detection_multiplier: description: - Detection multiplier of the BFD Interface policy - - APIC sets the default value to 3. - - Allowed range is 1-50. + - APIC sets the default value to 3 + - Allowed range is 1-50 type: int min_transmit_interval: description: - Minimum transmit (Tx) interval of the BFD Interface policy - - APIC sets the default value to 50. - - Allowed range is 250-999. + - APIC sets the default value to 50 + - Allowed range is 250-999 type: int min_receive_interval: description: - Minimum receive (Rx) interval of the BFD Interface policy - - APIC sets the default value to 50. - - Allowed range is 250-999. + - APIC sets the default value to 50 + - Allowed range is 250-999 type: int state: description: @@ -67,11 +67,11 @@ - cisco.aci.annotation notes: -- The C(tenant) must exist before using this module in your playbook. - The M(cisco.aci.aci_tenant) modules can be used for this. +- The C(tenant) must exist before using this module in your playbook + The M(cisco.aci.aci_tenant) modules can be used for this seealso: - name: APIC Management Information Model reference - description: More information about the internal APIC class B(bfd:IfPol). + description: More information about the internal APIC class B(bfd:IfPol) link: https://developer.cisco.com/docs/apic-mim-ref/ - module: cisco.aci.aci_tenant author: @@ -80,7 +80,7 @@ EXAMPLES = r""" - name: Add a new BFD Interface policy - cisco.aci.aci_bfd_interface_policy: + cisco.aci.aci_interface_policy_bfd: host: apic username: admin password: SomeSecretPassword @@ -91,7 +91,7 @@ delegate_to: localhost - name: Remove a BFD Interface policy - cisco.aci.aci_bfd_interface_policy: + cisco.aci.aci_interface_policy_bfd: host: apic username: admin password: SomeSecretPassword @@ -101,7 +101,7 @@ delegate_to: localhost - name: Query a BFD Interface policy - cisco.aci.aci_bfd_interface_policy: + cisco.aci.aci_interface_policy_bfd: host: apic username: admin password: SomeSecretPassword @@ -111,7 +111,7 @@ delegate_to: localhost - name: Query all BFD Interface policies in a specific tenant - cisco.aci.aci_bfd_interface_policy: + cisco.aci.aci_interface_policy_bfd: host: apic username: admin password: SomeSecretPassword diff --git a/plugins/modules/aci_bfd_multihop_interface_policy.py b/plugins/modules/aci_interface_policy_bfd_multihop.py similarity index 93% rename from plugins/modules/aci_bfd_multihop_interface_policy.py rename to plugins/modules/aci_interface_policy_bfd_multihop.py index f2c8c4830..67f827838 100644 --- a/plugins/modules/aci_bfd_multihop_interface_policy.py +++ b/plugins/modules/aci_interface_policy_bfd_multihop.py @@ -12,15 +12,15 @@ DOCUMENTATION = r""" --- -module: aci_bfd_multihop_interface_policy -short_description: Manage BFD Multihop Interface policies. +module: aci_interface_policy_bfd_multihop +short_description: Manage BFD Multihop Interface policies description: -- Manage BFD Multihop Interface policy (bfd:MhIfPol) configuration on Cisco ACI fabrics. -- Only available in APIC version 5.2 or later. +- Manage BFD Multihop Interface policy (bfd:MhIfPol) configuration on Cisco ACI fabrics +- Only available in APIC version 5.2 or later options: tenant: description: - - Name of an existing tenant. + - Name of an existing tenant type: str name: description: @@ -46,19 +46,19 @@ min_transmit_interval: description: - Minimum transmit (Tx) interval of the BFD Multihop Interface policy - - APIC sets the default value to 250. - - Allowed range is 250-999. + - APIC sets the default value to 250 + - Allowed range is 250-999 type: int min_receive_interval: description: - Minimum receive (Rx) interval of the BFD Multihop Interface policy - - APIC sets the default value to 250. - - Allowed range is 250-999. + - APIC sets the default value to 250 + - Allowed range is 250-999 type: int state: description: - - Use C(present) or C(absent) for adding or removing. - - Use C(query) for listing an object or multiple objects. + - 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 @@ -80,7 +80,7 @@ EXAMPLES = r""" - name: Add a new BFD Multihop Interface policy - cisco.aci.aci_bfd_multihop_interface_policy: + cisco.aci.aci_interface_policy_bfd_multihop: host: apic username: admin password: SomeSecretPassword @@ -91,7 +91,7 @@ delegate_to: localhost - name: Remove a BFD Multihop Interface policy - cisco.aci.aci_bfd_multihop_interface_policy: + cisco.aci.aci_interface_policy_bfd_multihop: host: apic username: admin password: SomeSecretPassword @@ -101,7 +101,7 @@ delegate_to: localhost - name: Query a BFD Multihop Interface policy - cisco.aci.aci_bfd_multihop_interface_policy: + cisco.aci.aci_interface_policy_bfd_multihop: host: apic username: admin password: SomeSecretPassword @@ -111,7 +111,7 @@ delegate_to: localhost - name: Query all BFD Multihop Interface policies in a specific tenant - cisco.aci.aci_bfd_multihop_interface_policy: + cisco.aci.aci_interface_policy_bfd_multihop: host: apic username: admin password: SomeSecretPassword diff --git a/plugins/modules/aci_l3out_bfd_interface_profile.py b/plugins/modules/aci_l3out_bfd_interface_profile.py index ce993f922..8e4bf9dbf 100644 --- a/plugins/modules/aci_l3out_bfd_interface_profile.py +++ b/plugins/modules/aci_l3out_bfd_interface_profile.py @@ -13,70 +13,70 @@ DOCUMENTATION = r""" --- module: aci_l3out_bfd_interface_profile -short_description: Manage L3Out BFD Interface profile. +short_description: Manage L3Out BFD Interface profiles description: -- Manage L3Out BFD Interface profile (bfd:IfP) configuration on Cisco ACI fabrics. -- Only available in APIC version 5.2 or later and for non-cloud APICs. +- Manage L3Out BFD Interface profile (bfd:IfP) configuration on Cisco ACI fabrics +- Only available in APIC version 5.2 or later and for non-cloud APICs options: tenant: description: - - Name of an existing tenant. + - Name of an existing tenant type: str aliases: [ tenant_name ] l3out: description: - - Name of an existing L3Out. + - Name of an existing L3Out type: str aliases: [ l3out_name ] l3out_logical_node_profile: description: - - Name of an existing L3Out Logical Node profile. + - Name of an existing L3Out Logical Node profile type: str aliases: [ logical_node_profile, logical_node_profile_name ] l3out_logical_interface_profile: description: - - Name of an existing L3Out Logical Interface profile. + - Name of an existing L3Out Logical Interface profile type: str aliases: [ logical_interface_profile, logical_interface_profile_name ] name: description: - - Name of the L3Out BFD Interface profile object. + - Name of the L3Out BFD Interface profile object type: str aliases: [ bfd_multihop_interface_profile ] name_alias: description: - - Name Alias of the L3Out BFD Interface profile object. + - Name Alias of the L3Out BFD Interface profile object type: str description: description: - - Description of the L3Out BFD Interface profile object. + - Description of the L3Out BFD Interface profile object type: str aliases: [ descr ] interface_profile_type: description: - - Authentication Type of the L3Out BFD Interface profile object. - - APIC sets the default value to none. + - Authentication Type of the L3Out BFD Interface profile object + - APIC sets the default value to none type: str choices: [ none, sha1 ] key: description: - - Authentication Key of the L3Out BFD Interface profile object. + - Authentication Key of the L3Out BFD Interface profile object type: str key_id: description: - - Authentication Key ID of the L3Out BFD Interface profile object. - - APIC sets the default value to 3. + - Authentication Key ID of the L3Out BFD Interface profile object + - APIC sets the default value to 3 - Allowed range is 1-255 type: int bfd_interface_policy: description: - - The name of the Interface policy. + - The name of the Interface policy type: str aliases: [ interface_policy, interface_policy_name ] state: description: - Use C(present) or C(absent) for adding or removing. - - Use C(query) for listing an object or multiple objects. + - Use C(query) for listing an object or multiple objects type: str choices: [ absent, present, query ] default: present @@ -85,8 +85,8 @@ - cisco.aci.annotation notes: -- The C(tenant), c(l3out), C(l3out_logical_node_profile) and C(l3out_logical_interface_profile) must exist before using this module in your playbook. - The M(cisco.aci.aci_tenant) modules can be used for this. +- The C(tenant), c(l3out), C(l3out_logical_node_profile) and C(l3out_logical_interface_profile) must exist before using this module in your playbook + The M(cisco.aci.aci_tenant) modules can be used for this seealso: - name: APIC Management Information Model reference description: More information about the internal APIC class B(bfd:IfP). @@ -95,7 +95,7 @@ - module: cisco.aci.aci_l3out - module: cisco.aci.aci_l3out_logical_node_profile - module: cisco.aci.aci_l3out_logical_interface_profile -- module: cisco.aci.aci_bfd_interface_policy +- module: cisco.aci.aci_interface_policy_bfd author: - Anvitha Jain (@anvjain) """ diff --git a/plugins/modules/aci_l3out_bfd_multihop_interface_profile.py b/plugins/modules/aci_l3out_bfd_multihop_interface_profile.py index 84869b2b8..0431f082c 100644 --- a/plugins/modules/aci_l3out_bfd_multihop_interface_profile.py +++ b/plugins/modules/aci_l3out_bfd_multihop_interface_profile.py @@ -13,70 +13,70 @@ DOCUMENTATION = r""" --- module: aci_l3out_bfd_multihop_interface_profile -short_description: Manage BFD Multihop Interface profile. +short_description: Manage BFD Multihop Interface profiles description: -- Manage BFD Multihop Interface profile (bfd:MhIfP) configuration on Cisco ACI fabrics. -- Only available in APIC version 5.2 or later and for non-cloud APICs. +- Manage BFD Multihop Interface profile (bfd:MhIfP) configuration on Cisco ACI fabrics +- Only available in APIC version 5.2 or later and for non-cloud APICs options: tenant: description: - - Name of an existing tenant. + - Name of an existing tenant type: str aliases: [ tenant_name ] l3out: description: - - Name of an existing L3Out. + - Name of an existing L3Out type: str aliases: [ l3out_name ] l3out_logical_node_profile: description: - - Name of an existing L3Out Logical Node profile. + - Name of an existing L3Out Logical Node profile type: str aliases: [ logical_node_profile, logical_node_profile_name ] l3out_logical_interface_profile: description: - - Name of an existing L3Out Logical Interface profile. + - Name of an existing L3Out Logical Interface profile type: str aliases: [ logical_interface_profile, logical_interface_profile_name ] name: description: - - Name of the BFD Multihop Interface Profile object. + - Name of the BFD Multihop Interface Profile object type: str aliases: [ bfd_multihop_interface_profile ] name_alias: description: - - Name Alias of the BFD Multihop Interface Profile object. + - Name Alias of the BFD Multihop Interface Profile object type: str description: description: - - Description of the BFD Multihop Interface Profile object. + - Description of the BFD Multihop Interface Profile object type: str aliases: [ descr ] interface_profile_type: description: - - Authentication Type of the BFD Multihop Interface Profile object. + - Authentication Type of the BFD Multihop Interface Profile object - APIC sets the default value to none. type: str choices: [ none, sha1 ] key: description: - - Authentication Key of the BFD Multihop Interface Profile object. + - Authentication Key of the BFD Multihop Interface Profile object type: str key_id: description: - - Authentication Key ID of the BFD Multihop Interface Profile object. - - APIC sets the default value to 3. + - Authentication Key ID of the BFD Multihop Interface Profile object + - APIC sets the default value to 3 - Allowed range is 1-255 type: int bfd_multihop_interface_policy: description: - - The name of the BFD Multihop Interface policy. + - The name of the BFD Multihop Interface policy type: str aliases: [ multihop_interface_policy, multihop_interface_policy_name ] state: description: - - Use C(present) or C(absent) for adding or removing. - - Use C(query) for listing an object or multiple objects. + - 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 @@ -85,17 +85,17 @@ - cisco.aci.annotation notes: -- The C(tenant), c(l3out), C(l3out_logical_node_profile) and C(l3out_logical_interface_profile) must exist before using this module in your playbook. - The M(cisco.aci.aci_tenant) modules can be used for this. +- The C(tenant), c(l3out), C(l3out_logical_node_profile) and C(l3out_logical_interface_profile) must exist before using this module in your playbook + The M(cisco.aci.aci_tenant) modules can be used for this seealso: - name: APIC Management Information Model reference - description: More information about the internal APIC class B(bfd:MhIfP). + description: More information about the internal APIC class B(bfd:MhIfP) link: https://developer.cisco.com/docs/apic-mim-ref/ - module: cisco.aci.aci_tenant - module: cisco.aci.aci_l3out - module: cisco.aci.aci_l3out_logical_node_profile - module: cisco.aci.aci_l3out_logical_interface_profile -- module: cisco.aci.aci_bfd_multihop_interface_policy +- module: cisco.aci.aci_interface_policy_bfd_multihop author: - Anvitha Jain (@anvjain) """ diff --git a/tests/integration/targets/aci_bfd_multihop_node_policy/tasks/main.yml b/tests/integration/targets/aci_bfd_multihop_node_policy/tasks/main.yml index cbcb2c478..99f853680 100644 --- a/tests/integration/targets/aci_bfd_multihop_node_policy/tasks/main.yml +++ b/tests/integration/targets/aci_bfd_multihop_node_policy/tasks/main.yml @@ -70,7 +70,6 @@ - cm_add_bfd_multihop_node_pol.proposed.bfdMhNodePol.attributes.dn == nm_add_bfd_multihop_node_pol.current.0.bfdMhNodePol.attributes.dn == "uni/tn-ansible_tenant/bfdMhNodePol-ansible_bfd_multihop_node_policy" - cm_add_bfd_multihop_node_pol.proposed.bfdMhNodePol.attributes.name == nm_add_bfd_multihop_node_pol.current.0.bfdMhNodePol.attributes.name == "ansible_bfd_multihop_node_policy" - cm_add_bfd_multihop_node_pol.proposed.bfdMhNodePol.attributes.descr == nm_add_bfd_multihop_node_pol.current.0.bfdMhNodePol.attributes.descr == "Ansible BFD Multihop Node Policy" - - cm_add_bfd_multihop_node_pol.proposed.bfdMhNodePol.attributes.adminSt == nm_add_bfd_multihop_node_pol.current.0.bfdMhNodePol.attributes.adminSt == "enabled" - name: Add a new BFD Multihop Node policy again - idempotency cisco.aci.aci_bfd_multihop_node_policy: diff --git a/tests/integration/targets/aci_bfd_interface_policy/aliases b/tests/integration/targets/aci_interface_policy_bfd/aliases similarity index 100% rename from tests/integration/targets/aci_bfd_interface_policy/aliases rename to tests/integration/targets/aci_interface_policy_bfd/aliases diff --git a/tests/integration/targets/aci_bfd_interface_policy/tasks/main.yml b/tests/integration/targets/aci_interface_policy_bfd/tasks/main.yml similarity index 93% rename from tests/integration/targets/aci_bfd_interface_policy/tasks/main.yml rename to tests/integration/targets/aci_interface_policy_bfd/tasks/main.yml index ecd838862..2d688f2c6 100644 --- a/tests/integration/targets/aci_bfd_interface_policy/tasks/main.yml +++ b/tests/integration/targets/aci_interface_policy_bfd/tasks/main.yml @@ -46,7 +46,7 @@ # CREATE BFD Interface policy - name: Add a new BFD Interface policy - check mode - cisco.aci.aci_bfd_interface_policy: &add_bfd_interface_pol + cisco.aci.aci_interface_policy_bfd: &add_bfd_interface_pol <<: *aci_info tenant: ansible_tenant name: ansible_bfd_interface_policy @@ -56,7 +56,7 @@ register: cm_add_bfd_interface_pol - name: Add a new BFD Interface policy - normal mode - cisco.aci.aci_bfd_interface_policy: + cisco.aci.aci_interface_policy_bfd: <<: *add_bfd_interface_pol state: present register: nm_add_bfd_interface_pol @@ -70,10 +70,9 @@ - cm_add_bfd_interface_pol.proposed.bfdIfPol.attributes.dn == nm_add_bfd_interface_pol.current.0.bfdIfPol.attributes.dn == "uni/tn-ansible_tenant/bfdIfPol-ansible_bfd_interface_policy" - cm_add_bfd_interface_pol.proposed.bfdIfPol.attributes.name == nm_add_bfd_interface_pol.current.0.bfdIfPol.attributes.name == "ansible_bfd_interface_policy" - cm_add_bfd_interface_pol.proposed.bfdIfPol.attributes.descr == nm_add_bfd_interface_pol.current.0.bfdIfPol.attributes.descr == "Ansible BFD Interface Policy" - - cm_add_bfd_interface_pol.proposed.bfdIfPol.attributes.adminSt == nm_add_bfd_interface_pol.current.0.bfdIfPol.attributes.adminSt == "enabled" - name: Add a new BFD Interface policy again - idempotency - cisco.aci.aci_bfd_interface_policy: + cisco.aci.aci_interface_policy_bfd: <<: *add_bfd_interface_pol state: present register: add_bfd_interface_pol_again @@ -87,7 +86,7 @@ - add_bfd_interface_pol_again.previous | length == 1 - name: Modify a BFD Interface policy - cisco.aci.aci_bfd_interface_policy: + cisco.aci.aci_interface_policy_bfd: <<: *add_bfd_interface_pol admin_state: disabled detection_multiplier: 5 @@ -111,7 +110,7 @@ # Added another BFD Interface policy - name: Add a new BFD Interface policy - normal mode - cisco.aci.aci_bfd_interface_policy: + cisco.aci.aci_interface_policy_bfd: <<: *add_bfd_interface_pol name: ansible_bfd_interface_policy_2 state: present @@ -131,7 +130,7 @@ - add_bfd_interface_pol_2.current.0.bfdIfPol.attributes.minTxIntvl == "50" - name: Query all BFD Interface policies in a specific tenant - cisco.aci.aci_bfd_interface_policy: + cisco.aci.aci_interface_policy_bfd: <<: *aci_info tenant: ansible_tenant state: query @@ -146,7 +145,7 @@ - query_all_result.current.0.fvTenant.children[1].bfdIfPol.attributes.name == "ansible_bfd_interface_policy" - name: Query 'ansible_bfd_interface_policy' BFD Interface policies in a specific tenant - cisco.aci.aci_bfd_interface_policy: + cisco.aci.aci_interface_policy_bfd: <<: *aci_info tenant: ansible_tenant name: ansible_bfd_interface_policy @@ -161,7 +160,7 @@ - query_result.current.0.bfdIfPol.attributes.name == "ansible_bfd_interface_policy" - name: Remove a BFD Interface policy - check mode - cisco.aci.aci_bfd_interface_policy: + cisco.aci.aci_interface_policy_bfd: <<: *aci_info tenant: ansible_tenant name: ansible_bfd_interface_policy @@ -170,7 +169,7 @@ register: cm_remove_bfd_interface_pol - name: Remove a BFD Interface policy - normal mode - cisco.aci.aci_bfd_interface_policy: + cisco.aci.aci_interface_policy_bfd: <<: *aci_info tenant: ansible_tenant name: ansible_bfd_interface_policy @@ -178,7 +177,7 @@ register: nm_remove_bfd_interface_pol - name: Remove a BFD Interface policy again - cisco.aci.aci_bfd_interface_policy: + cisco.aci.aci_interface_policy_bfd: <<: *aci_info tenant: ansible_tenant name: ansible_bfd_interface_policy @@ -199,7 +198,7 @@ # Added BFD Interface policy with out of the range detection_multiplier - name: Add a new BFD Interface policy - out of the range detection_multiplier - cisco.aci.aci_bfd_interface_policy: + cisco.aci.aci_interface_policy_bfd: <<: *add_bfd_interface_pol name: ansible_bfd_interface_policy_3 detection_multiplier: 256 @@ -215,7 +214,7 @@ # Added BFD Interface policy with out of the range min_transmit_interval - name: Add a new BFD Interface policy - out of the range min_transmit_interval - cisco.aci.aci_bfd_interface_policy: + cisco.aci.aci_interface_policy_bfd: <<: *add_bfd_interface_pol name: ansible_bfd_interface_policy_3 min_transmit_interval: 10 @@ -231,7 +230,7 @@ # Added BFD Interface policy with out of the range min_receive_interval - name: Add a new BFD Interface policy - out of the range min_receive_interval - cisco.aci.aci_bfd_interface_policy: + cisco.aci.aci_interface_policy_bfd: <<: *add_bfd_interface_pol name: ansible_bfd_interface_policy_3 min_receive_interval: 1000 diff --git a/tests/integration/targets/aci_bfd_multihop_interface_policy/aliases b/tests/integration/targets/aci_interface_policy_bfd_multihop/aliases similarity index 100% rename from tests/integration/targets/aci_bfd_multihop_interface_policy/aliases rename to tests/integration/targets/aci_interface_policy_bfd_multihop/aliases diff --git a/tests/integration/targets/aci_bfd_multihop_interface_policy/tasks/main.yml b/tests/integration/targets/aci_interface_policy_bfd_multihop/tasks/main.yml similarity index 92% rename from tests/integration/targets/aci_bfd_multihop_interface_policy/tasks/main.yml rename to tests/integration/targets/aci_interface_policy_bfd_multihop/tasks/main.yml index 79967e070..8454803ec 100644 --- a/tests/integration/targets/aci_bfd_multihop_interface_policy/tasks/main.yml +++ b/tests/integration/targets/aci_interface_policy_bfd_multihop/tasks/main.yml @@ -46,7 +46,7 @@ # CREATE BFD Multihop Interface policy - name: Add a new BFD Multihop Interface policy - check mode - cisco.aci.aci_bfd_multihop_interface_policy: &add_bfd_multihop_interface_pol + cisco.aci.aci_interface_policy_bfd_multihop: &add_bfd_multihop_interface_pol <<: *aci_info tenant: ansible_tenant name: ansible_bfd_multihop_interface_policy @@ -56,7 +56,7 @@ register: cm_add_bfd_multihop_interface_pol - name: Add a new BFD Multihop Interface policy - normal mode - cisco.aci.aci_bfd_multihop_interface_policy: + cisco.aci.aci_interface_policy_bfd_multihop: <<: *add_bfd_multihop_interface_pol state: present register: nm_add_bfd_multihop_interface_pol @@ -70,10 +70,9 @@ - cm_add_bfd_multihop_interface_pol.proposed.bfdMhIfPol.attributes.dn == nm_add_bfd_multihop_interface_pol.current.0.bfdMhIfPol.attributes.dn == "uni/tn-ansible_tenant/bfdMhIfPol-ansible_bfd_multihop_interface_policy" - cm_add_bfd_multihop_interface_pol.proposed.bfdMhIfPol.attributes.name == nm_add_bfd_multihop_interface_pol.current.0.bfdMhIfPol.attributes.name == "ansible_bfd_multihop_interface_policy" - cm_add_bfd_multihop_interface_pol.proposed.bfdMhIfPol.attributes.descr == nm_add_bfd_multihop_interface_pol.current.0.bfdMhIfPol.attributes.descr == "Ansible BFD Multihop Interface Policy" - - cm_add_bfd_multihop_interface_pol.proposed.bfdMhIfPol.attributes.adminSt == nm_add_bfd_multihop_interface_pol.current.0.bfdMhIfPol.attributes.adminSt == "enabled" - name: Add a new BFD Multihop Interface policy again - idempotency - cisco.aci.aci_bfd_multihop_interface_policy: + cisco.aci.aci_interface_policy_bfd_multihop: <<: *add_bfd_multihop_interface_pol state: present register: add_bfd_multihop_interface_pol_again @@ -87,7 +86,7 @@ - add_bfd_multihop_interface_pol_again.previous | length == 1 - name: Modify a BFD Multihop Interface policy - cisco.aci.aci_bfd_multihop_interface_policy: + cisco.aci.aci_interface_policy_bfd_multihop: <<: *add_bfd_multihop_interface_pol admin_state: disabled detection_multiplier: 5 @@ -111,7 +110,7 @@ # Added another BFD Multihop Interface policy - name: Add a new BFD Multihop Interface policy - normal mode - cisco.aci.aci_bfd_multihop_interface_policy: + cisco.aci.aci_interface_policy_bfd_multihop: <<: *add_bfd_multihop_interface_pol name: ansible_bfd_multihop_interface_policy_2 state: present @@ -131,7 +130,7 @@ - add_bfd_multihop_interface_pol_2.current.0.bfdMhIfPol.attributes.minTxIntvl == "250" - name: Query all BFD Multihop Interface policies in a specific tenant - cisco.aci.aci_bfd_multihop_interface_policy: + cisco.aci.aci_interface_policy_bfd_multihop: <<: *aci_info tenant: ansible_tenant state: query @@ -146,7 +145,7 @@ - query_all_result.current.0.fvTenant.children[1].bfdMhIfPol.attributes.name == "ansible_bfd_multihop_interface_policy" - name: Query 'ansible_bfd_multihop_interface_policy' BFD Multihop Interface policies in a specific tenant - cisco.aci.aci_bfd_multihop_interface_policy: + cisco.aci.aci_interface_policy_bfd_multihop: <<: *aci_info tenant: ansible_tenant name: ansible_bfd_multihop_interface_policy @@ -161,7 +160,7 @@ - query_result.current.0.bfdMhIfPol.attributes.name == "ansible_bfd_multihop_interface_policy" - name: Remove a BFD Multihop Interface policy - check mode - cisco.aci.aci_bfd_multihop_interface_policy: + cisco.aci.aci_interface_policy_bfd_multihop: <<: *aci_info tenant: ansible_tenant name: ansible_bfd_multihop_interface_policy @@ -170,7 +169,7 @@ register: cm_remove_bfd_multihop_interface_pol - name: Remove a BFD Multihop Interface policy - normal mode - cisco.aci.aci_bfd_multihop_interface_policy: + cisco.aci.aci_interface_policy_bfd_multihop: <<: *aci_info tenant: ansible_tenant name: ansible_bfd_multihop_interface_policy @@ -178,7 +177,7 @@ register: nm_remove_bfd_multihop_interface_pol - name: Remove a BFD Multihop Interface policy again - idempotency - cisco.aci.aci_bfd_multihop_interface_policy: + cisco.aci.aci_interface_policy_bfd_multihop: <<: *aci_info tenant: ansible_tenant name: ansible_bfd_multihop_interface_policy @@ -199,7 +198,7 @@ # Added BFD Multihop Interface policy with out of the range detection_multiplier - name: Add a new BFD Multihop Interface policy - out of the range detection_multiplier - cisco.aci.aci_bfd_multihop_interface_policy: + cisco.aci.aci_interface_policy_bfd_multihop: <<: *add_bfd_multihop_interface_pol name: ansible_bfd_multihop_interface_policy_3 detection_multiplier: 256 @@ -215,7 +214,7 @@ # Added BFD Multihop Interface policy with out of the range min_transmit_interval - name: Add a new BFD Multihop Interface policy - out of the range min_transmit_interval - cisco.aci.aci_bfd_multihop_interface_policy: + cisco.aci.aci_interface_policy_bfd_multihop: <<: *add_bfd_multihop_interface_pol name: ansible_bfd_multihop_interface_policy_3 min_transmit_interval: 50 @@ -231,7 +230,7 @@ # Added BFD Multihop Interface policy with out of the range min_receive_interval - name: Add a new BFD Multihop Interface policy - out of the range min_receive_interval - cisco.aci.aci_bfd_multihop_interface_policy: + cisco.aci.aci_interface_policy_bfd_multihop: <<: *add_bfd_multihop_interface_pol name: ansible_bfd_multihop_interface_policy_3 min_receive_interval: 1000 diff --git a/tests/integration/targets/aci_l3out_bfd_interface_profile/tasks/main.yml b/tests/integration/targets/aci_l3out_bfd_interface_profile/tasks/main.yml index 2c5383ead..00e0e733d 100644 --- a/tests/integration/targets/aci_l3out_bfd_interface_profile/tasks/main.yml +++ b/tests/integration/targets/aci_l3out_bfd_interface_profile/tasks/main.yml @@ -91,7 +91,7 @@ # CREATE L3Out BFD Interface policy - name: Add a new L3Out BFD Interface policy - cisco.aci.aci_bfd_interface_policy: + cisco.aci.aci_interface_policy_bfd: <<: *aci_info tenant: ansible_tenant name: ansible_bfd__interface_policy diff --git a/tests/integration/targets/aci_bfd_multihop_interface_profile/aliases b/tests/integration/targets/aci_l3out_bfd_multihop_interface_profile/aliases similarity index 100% rename from tests/integration/targets/aci_bfd_multihop_interface_profile/aliases rename to tests/integration/targets/aci_l3out_bfd_multihop_interface_profile/aliases diff --git a/tests/integration/targets/aci_bfd_multihop_interface_profile/tasks/main.yml b/tests/integration/targets/aci_l3out_bfd_multihop_interface_profile/tasks/main.yml similarity index 91% rename from tests/integration/targets/aci_bfd_multihop_interface_profile/tasks/main.yml rename to tests/integration/targets/aci_l3out_bfd_multihop_interface_profile/tasks/main.yml index 824ffd2d4..18d903d8e 100644 --- a/tests/integration/targets/aci_bfd_multihop_interface_profile/tasks/main.yml +++ b/tests/integration/targets/aci_l3out_bfd_multihop_interface_profile/tasks/main.yml @@ -91,7 +91,7 @@ # CREATE BFD Multihop Interface policy - name: Add a new BFD Multihop Interface policy - cisco.aci.aci_bfd_multihop_interface_policy: + cisco.aci.aci_interface_policy_bfd_multihop: <<: *aci_info tenant: ansible_tenant name: ansible_bfd_multihop_interface_policy @@ -101,7 +101,7 @@ # Add BFD Multihop Interface Profile - name: Add a new BFD Multihop Interface Profile - check mode - cisco.aci.aci_bfd_multihop_interface_profile: &present_bfd_mh_int_profile + cisco.aci.aci_l3out_bfd_multihop_interface_profile: &present_bfd_mh_int_profile <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -113,7 +113,7 @@ register: cm_add_bfd_mh_int_prof - name: Add a new BFD Multihop Interface Profile - normal mode - cisco.aci.aci_bfd_multihop_interface_profile: + cisco.aci.aci_l3out_bfd_multihop_interface_profile: <<: *present_bfd_mh_int_profile state: present register: nm_add_bfd_mh_int_prof @@ -129,13 +129,13 @@ # Query BFD Multihop Interface Profile - name: Query BFD Multihop Interface Profile - cisco.aci.aci_bfd_multihop_interface_profile: + cisco.aci.aci_l3out_bfd_multihop_interface_profile: <<: *present_bfd_mh_int_profile state: query register: query_bfd_mh_int_prof - name: Add BFD Multihop Interface Profile again- idempotency - cisco.aci.aci_bfd_multihop_interface_profile: + cisco.aci.aci_l3out_bfd_multihop_interface_profile: <<: *present_bfd_mh_int_profile state: present register: add_bfd_mh_int_prof_again @@ -147,7 +147,7 @@ # Update BFD Multihop Interface Profile - name: Update BFD Multihop Interface Profile - cisco.aci.aci_bfd_multihop_interface_profile: + cisco.aci.aci_l3out_bfd_multihop_interface_profile: <<: *present_bfd_mh_int_profile interface_profile_type: sha1 key: "abc*123" @@ -165,7 +165,7 @@ # Remove children from L3Out BFD Interface Profile - name: Remove children from BFD Multihop Interface Profile - cisco.aci.aci_bfd_multihop_interface_profile: + cisco.aci.aci_l3out_bfd_multihop_interface_profile: <<: *present_bfd_mh_int_profile bfd_multihop_interface_policy: "" register: remove_children_bfd_mh_int_prof @@ -178,20 +178,20 @@ # Query BFD Multihop Interface Profile - name: Query BFD Multihop Interface Profile - cisco.aci.aci_bfd_multihop_interface_profile: + cisco.aci.aci_l3out_bfd_multihop_interface_profile: <<: *present_bfd_mh_int_profile state: query register: query_bfd_mh_int_prof - name: Query all BFD Multihop Interface Profile - cisco.aci.aci_bfd_multihop_interface_profile: + cisco.aci.aci_l3out_bfd_multihop_interface_profile: <<: *aci_info state: query register: query_all_bfd_mh_int_prof # Validating out of range parameters. - name: Add out of range key_id - cisco.aci.aci_bfd_multihop_interface_profile: + cisco.aci.aci_l3out_bfd_multihop_interface_profile: <<: *present_bfd_mh_int_profile key_id: 256 state: present @@ -205,20 +205,20 @@ - out_of_range_key_id.msg == "The \"key_id\" must be a value between 1 and 255" - name: Delete BFD Multihop Interface Profile - check mode - cisco.aci.aci_bfd_multihop_interface_profile: + cisco.aci.aci_l3out_bfd_multihop_interface_profile: <<: *present_bfd_mh_int_profile state: absent check_mode: true register: cm_remove_bfd_mh_int_prof - name: Delete BFD Multihop Interface Profile - normal mode - cisco.aci.aci_bfd_multihop_interface_profile: + cisco.aci.aci_l3out_bfd_multihop_interface_profile: <<: *present_bfd_mh_int_profile state: absent register: nm_remove_bfd_mh_int_prof - name: Delete BFD Multihop Interface Profile again - idempotency - cisco.aci.aci_bfd_multihop_interface_profile: + cisco.aci.aci_l3out_bfd_multihop_interface_profile: <<: *present_bfd_mh_int_profile state: absent register: remove_bfd_mh_int_prof_again From 1f2b32ecba08ebfa345d599f751130079ef4937b Mon Sep 17 00:00:00 2001 From: anvitha-jain Date: Fri, 1 Dec 2023 09:58:30 -0800 Subject: [PATCH 09/10] [ignore]Fixing documents by removing fullstop --- plugins/modules/aci_bfd_multihop_node_policy.py | 2 +- plugins/modules/aci_interface_policy_bfd.py | 4 ++-- plugins/modules/aci_interface_policy_bfd_multihop.py | 6 +++--- plugins/modules/aci_l3out_bfd_interface_profile.py | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/plugins/modules/aci_bfd_multihop_node_policy.py b/plugins/modules/aci_bfd_multihop_node_policy.py index 0e9cce0c5..b6d1f9172 100644 --- a/plugins/modules/aci_bfd_multihop_node_policy.py +++ b/plugins/modules/aci_bfd_multihop_node_policy.py @@ -71,7 +71,7 @@ The M(cisco.aci.aci_tenant) modules can be used for this seealso: - name: APIC Management Information Model reference - description: More information about the internal APIC class B(bfd:MhNodePol). + description: More information about the internal APIC class B(bfd:MhNodePol) link: https://developer.cisco.com/docs/apic-mim-ref/ - module: cisco.aci.aci_tenant author: diff --git a/plugins/modules/aci_interface_policy_bfd.py b/plugins/modules/aci_interface_policy_bfd.py index 89b4eedf4..8a16c7bd7 100644 --- a/plugins/modules/aci_interface_policy_bfd.py +++ b/plugins/modules/aci_interface_policy_bfd.py @@ -57,8 +57,8 @@ type: int state: description: - - Use C(present) or C(absent) for adding or removing. - - Use C(query) for listing an object or multiple objects. + - 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 diff --git a/plugins/modules/aci_interface_policy_bfd_multihop.py b/plugins/modules/aci_interface_policy_bfd_multihop.py index 67f827838..cf972c562 100644 --- a/plugins/modules/aci_interface_policy_bfd_multihop.py +++ b/plugins/modules/aci_interface_policy_bfd_multihop.py @@ -67,11 +67,11 @@ - cisco.aci.annotation notes: -- The C(tenant) must exist before using this module in your playbook. - The M(cisco.aci.aci_tenant) modules can be used for this. +- The C(tenant) must exist before using this module in your playbook + The M(cisco.aci.aci_tenant) modules can be used for this seealso: - name: APIC Management Information Model reference - description: More information about the internal APIC class B(bfd:MhIfPol). + description: More information about the internal APIC class B(bfd:MhIfPol) link: https://developer.cisco.com/docs/apic-mim-ref/ - module: cisco.aci.aci_tenant author: diff --git a/plugins/modules/aci_l3out_bfd_interface_profile.py b/plugins/modules/aci_l3out_bfd_interface_profile.py index 8e4bf9dbf..b56a859e0 100644 --- a/plugins/modules/aci_l3out_bfd_interface_profile.py +++ b/plugins/modules/aci_l3out_bfd_interface_profile.py @@ -89,7 +89,7 @@ The M(cisco.aci.aci_tenant) modules can be used for this seealso: - name: APIC Management Information Model reference - description: More information about the internal APIC class B(bfd:IfP). + description: More information about the internal APIC class B(bfd:IfP) link: https://developer.cisco.com/docs/apic-mim-ref/ - module: cisco.aci.aci_tenant - module: cisco.aci.aci_l3out From 832f48581542080e03f1689fa51e829b50e1bf42 Mon Sep 17 00:00:00 2001 From: anvitha-jain Date: Wed, 20 Dec 2023 09:25:56 -0800 Subject: [PATCH 10/10] [ignore] Renamed interface_profile_type parameter to authentication_type. --- plugins/modules/aci_l3out_bfd_interface_profile.py | 10 +++++----- .../aci_l3out_bfd_multihop_interface_profile.py | 8 ++++---- .../aci_l3out_bfd_interface_profile/tasks/main.yml | 2 +- .../tasks/main.yml | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/plugins/modules/aci_l3out_bfd_interface_profile.py b/plugins/modules/aci_l3out_bfd_interface_profile.py index b56a859e0..703b48c8e 100644 --- a/plugins/modules/aci_l3out_bfd_interface_profile.py +++ b/plugins/modules/aci_l3out_bfd_interface_profile.py @@ -52,7 +52,7 @@ - Description of the L3Out BFD Interface profile object type: str aliases: [ descr ] - interface_profile_type: + authentication_type: description: - Authentication Type of the L3Out BFD Interface profile object - APIC sets the default value to none @@ -262,7 +262,7 @@ def main(): name=dict(type="str", aliases=["bfd_multihop_interface_profile"]), name_alias=dict(type="str"), description=dict(type="str", aliases=["descr"]), - interface_profile_type=dict(type="str", choices=["none", "sha1"]), + authentication_type=dict(type="str", choices=["none", "sha1"]), key=dict(type="str", no_log=True), key_id=dict(type="int"), bfd_interface_policy=dict(type="str", aliases=["interface_policy", "interface_policy_name"]), @@ -275,7 +275,7 @@ def main(): required_if=[ ["state", "absent", ["tenant", "l3out", "l3out_logical_node_profile", "l3out_logical_interface_profile"]], ["state", "present", ["tenant", "l3out", "l3out_logical_node_profile", "l3out_logical_interface_profile", "bfd_interface_policy"]], - ["interface_profile_type", "sha1", ["key"]], + ["authentication_type", "sha1", ["key"]], ], ) @@ -286,7 +286,7 @@ def main(): name = module.params.get("name") name_alias = module.params.get("name_alias") description = module.params.get("description") - interface_profile_type = module.params.get("interface_profile_type") + authentication_type = module.params.get("authentication_type") key = module.params.get("key") key_id = module.params.get("key_id") bfd_interface_policy = module.params.get("bfd_interface_policy") @@ -336,7 +336,7 @@ def main(): nameAlias=name_alias, descr=description, key=key, - type=interface_profile_type, + type=authentication_type, ) if key_id and key_id not in range(1, 255): diff --git a/plugins/modules/aci_l3out_bfd_multihop_interface_profile.py b/plugins/modules/aci_l3out_bfd_multihop_interface_profile.py index 0431f082c..fe6d94bab 100644 --- a/plugins/modules/aci_l3out_bfd_multihop_interface_profile.py +++ b/plugins/modules/aci_l3out_bfd_multihop_interface_profile.py @@ -52,7 +52,7 @@ - Description of the BFD Multihop Interface Profile object type: str aliases: [ descr ] - interface_profile_type: + authentication_type: description: - Authentication Type of the BFD Multihop Interface Profile object - APIC sets the default value to none. @@ -262,7 +262,7 @@ def main(): name=dict(type="str", aliases=["bfd_multihop_interface_profile"]), name_alias=dict(type="str"), description=dict(type="str", aliases=["descr"]), - interface_profile_type=dict(type="str", choices=["none", "sha1"]), + authentication_type=dict(type="str", choices=["none", "sha1"]), key=dict(type="str", no_log=True), key_id=dict(type="int"), bfd_multihop_interface_policy=dict(type="str", aliases=["multihop_interface_policy", "multihop_interface_policy_name"]), @@ -285,7 +285,7 @@ def main(): name = module.params.get("name") name_alias = module.params.get("name_alias") description = module.params.get("description") - interface_profile_type = module.params.get("interface_profile_type") + authentication_type = module.params.get("authentication_type") key = module.params.get("key") key_id = module.params.get("key_id") bfd_multihop_interface_policy = module.params.get("bfd_multihop_interface_policy") @@ -334,7 +334,7 @@ def main(): name=name, nameAlias=name_alias, descr=description, - type=interface_profile_type, + type=authentication_type, key=key, ) diff --git a/tests/integration/targets/aci_l3out_bfd_interface_profile/tasks/main.yml b/tests/integration/targets/aci_l3out_bfd_interface_profile/tasks/main.yml index 00e0e733d..19c034eb8 100644 --- a/tests/integration/targets/aci_l3out_bfd_interface_profile/tasks/main.yml +++ b/tests/integration/targets/aci_l3out_bfd_interface_profile/tasks/main.yml @@ -142,7 +142,7 @@ - name: Update L3Out BFD Interface Profile cisco.aci.aci_l3out_bfd_interface_profile: <<: *present_l3out_bfd_int_profile - interface_profile_type: sha1 + authentication_type: sha1 key: "abc*123" key_id: 15 state: present diff --git a/tests/integration/targets/aci_l3out_bfd_multihop_interface_profile/tasks/main.yml b/tests/integration/targets/aci_l3out_bfd_multihop_interface_profile/tasks/main.yml index 18d903d8e..920453708 100644 --- a/tests/integration/targets/aci_l3out_bfd_multihop_interface_profile/tasks/main.yml +++ b/tests/integration/targets/aci_l3out_bfd_multihop_interface_profile/tasks/main.yml @@ -149,7 +149,7 @@ - name: Update BFD Multihop Interface Profile cisco.aci.aci_l3out_bfd_multihop_interface_profile: <<: *present_bfd_mh_int_profile - interface_profile_type: sha1 + authentication_type: sha1 key: "abc*123" key_id: 15 state: present