diff --git a/plugins/modules/aci_oob_contract.py b/plugins/modules/aci_oob_contract.py index af3c85475..e0e886d9d 100644 --- a/plugins/modules/aci_oob_contract.py +++ b/plugins/modules/aci_oob_contract.py @@ -1,5 +1,6 @@ #!/usr/bin/python # -*- coding: utf-8 -*- +# Copyright: (c) 2024, Faiz Mohammad (@Ziaf007) # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) @@ -12,7 +13,7 @@ DOCUMENTATION = r""" --- module: aci_oob_contract -short_description: Manage out-of-band contract resources (vz:OOBBrCP) +short_description: Manage Out-of-Band contract resources (vz:OOBBrCP) description: - Manage out-of-band Contract resources on Cisco ACI fabrics. options: @@ -23,18 +24,18 @@ aliases: [ contract_name, name ] description: description: - - Description for the contract. + - Description for the OOB contract. type: str aliases: [ descr ] scope: description: - - The scope of a service contract. + - The scope of a the OOB contract. - The APIC defaults to C(context) when unset during creation. type: str choices: [ application-profile, context, global, tenant ] priority: description: - - The desired QoS class to be used. + - The desired Quality of Service (QoS) class to be used. - The APIC defaults to C(unspecified) when unset during creation. type: str choices: [ level1, level2, level3, unspecified ] @@ -52,7 +53,7 @@ seealso: - name: APIC Management Information Model reference - description: More information about the internal APIC class B(vz:BrCP). + description: More information about the internal APIC class B(vz:OOBBrCP). link: https://developer.cisco.com/docs/apic-mim-ref/ author: - Faiz Mohammad (@faizmoh) @@ -66,37 +67,38 @@ password: SomeSecretPassword contract: web_to_db description: Communication between web-servers and database + priority: unspecified scope: global state: present delegate_to: localhost -- name: Remove an existing contract - cisco.aci.aci_contract: +- name: Query a specific contract + cisco.aci.aci_oob_contract: host: apic username: admin password: SomeSecretPassword contract: web_to_db - state: absent + state: query delegate_to: localhost + register: query_result -- name: Query a specific contract - cisco.aci.aci_contract: +- name: Query all contracts + cisco.aci.aci_oob_contract: host: apic username: admin password: SomeSecretPassword - contract: web_to_db state: query delegate_to: localhost register: query_result -- name: Query all contracts - cisco.aci.aci_contract: +- name: Remove an existing contract + cisco.aci.aci_oob_contract: host: apic username: admin password: SomeSecretPassword - state: query + contract: web_to_db + state: absent delegate_to: localhost - register: query_result """ RETURN = r""" diff --git a/tests/integration/targets/aci_oob_contract/tasks/main.yml b/tests/integration/targets/aci_oob_contract/tasks/main.yml index be1cc30b0..b795b0d1d 100644 --- a/tests/integration/targets/aci_oob_contract/tasks/main.yml +++ b/tests/integration/targets/aci_oob_contract/tasks/main.yml @@ -1,5 +1,5 @@ # Test code for the ACI modules -# Copyright: (c) 2017, Jacob McGill (@jmcgill298) +# Copyright: (c) 2024, Faiz Mohammad (@Ziaf007) # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) @@ -35,25 +35,29 @@ - version.current.0.topSystem.attributes.version is version('5', '>=') - query_cloud.current == [] # This condition will execute only non-cloud sites block: # block specifies execution of tasks within, based on conditions + + # CLEAN ENVIRONMENT - name: Ensure Contract doesn't exist cisco.aci.aci_oob_contract: <<: *aci_info contract: anstest state: absent description: Ansible Test - + + # CREATE - name: create contract - check mode works - cisco.aci.aci_oob_contract: &aci_oob_contract_present + cisco.aci.aci_oob_contract: &aci_oob_contract_present_CM <<: *aci_info contract: anstest description: Ansible Test - state: present + #state: present >>>> DEFAULTS TO 'PRESENT" ASSERTATION check_mode: true register: present_check_mode - name: create contract - creation works - cisco.aci.aci_oob_contract: - <<: *aci_oob_contract_present + cisco.aci.aci_oob_contract: &aci_oob_contract_present + <<: *aci_oob_contract_present_CM + state: present register: contract_present - name: create contract - idempotency works @@ -61,23 +65,11 @@ <<: *aci_oob_contract_present register: present_idempotent - - name: update contract - update works - cisco.aci.aci_oob_contract: - <<: *aci_oob_contract_present - scope: application-profile - register: present_update - - name: create contract - used for query cisco.aci.aci_oob_contract: <<: *aci_oob_contract_present contract: anstest2 - - name: missing param - failure message works - cisco.aci.aci_oob_contract: - <<: *aci_info - ignore_errors: true - register: present_missing_param - - name: present assertions ansible.builtin.assert: that: @@ -85,16 +77,35 @@ - present_check_mode.previous == [] - present_check_mode.sent.vzOOBBrCP.attributes.name == 'anstest' - present_check_mode.sent.vzOOBBrCP.attributes.descr == 'Ansible Test' + - present_check_mode.invocation.module_args.state == 'present' - contract_present is changed - contract_present.current.0.vzOOBBrCP.attributes.annotation == 'orchestrator:ansible' - contract_present.sent == present_check_mode.sent - present_idempotent is not changed + + # UPDATE + - name: update contract - update works + cisco.aci.aci_oob_contract: + <<: *aci_oob_contract_present + scope: application-profile + register: present_update + + - name: missing param - failure message works + cisco.aci.aci_oob_contract: + <<: *aci_info + ignore_errors: true + register: present_missing_param + + - name: update assertions + ansible.builtin.assert: + that: - present_update is changed - present_update.sent != present_update.proposed - present_update.sent.vzOOBBrCP.attributes.scope == "application-profile" - present_missing_param is failed - 'present_missing_param.msg == "state is present but all of the following are missing: contract"' + # QUERY - name: query contract cisco.aci.aci_oob_contract: &aci_oob_contract_query <<: *aci_oob_contract_present @@ -119,7 +130,7 @@ - '"rsp-subtree-class=vzOOBBrCP" in query_tenant.filter_string' - '"tn-mgmt.json" in query_tenant.url' - + # DELETE - name: delete contract - check mode works cisco.aci.aci_oob_contract: &aci_oob_contract_absent <<: *aci_oob_contract_present