From b257ba49b8f27792868cacc221e44c2577424543 Mon Sep 17 00:00:00 2001 From: Sabari Jaganathan <93724860+sajagana@users.noreply.github.com> Date: Tue, 17 Oct 2023 08:23:52 +0530 Subject: [PATCH] [ignore] Added service_package_host variable to the inventory.networking file --- plugins/modules/nd_service.py | 10 +++---- plugins/modules/nd_service_instance.py | 2 +- tests/integration/inventory.networking | 3 +- .../targets/nd_service/tasks/main.yml | 28 +++++++++---------- .../nd_service_instance/tasks/main.yml | 4 +-- 5 files changed, 23 insertions(+), 24 deletions(-) diff --git a/plugins/modules/nd_service.py b/plugins/modules/nd_service.py index e9533df..6eeee83 100644 --- a/plugins/modules/nd_service.py +++ b/plugins/modules/nd_service.py @@ -32,7 +32,7 @@ state: description: - Use C(present) for importing a Service Package. The C(present) state is not idempotent. - - Use C(query) for listing all Service Packages. + - Use C(query) for listing all the Service Packages. - Use C(absent) for deleting a Service Package. type: str choices: [ present, query, absent ] @@ -64,10 +64,9 @@ import_id: "{{ query_result_import_id.current.metadata.id }}" state: absent -# When the import_url has exactly one match -- name: Remove a service package with import_url +- name: Remove a service package with import_url that has one match cisco.nd.nd_service: - import_url: "http://173.36.219.254/cisco-terraform-v0.1.15.aci" + import_url: "http://nd_service.cisco.com/cisco-terraform-v0.1.15.aci" state: absent - name: Query all service packages with import_url @@ -76,8 +75,7 @@ state: query register: query_reseult_import_url -# When the query_reseult_import_url has more than one match -- name: Remove all query_reseult_import_url result service packages with import_id +- name: Remove all service packages with import_id when the query_result_import_url has more than one match cisco.nd.nd_service: import_id: "{{ item.metadata.id }}" state: absent diff --git a/plugins/modules/nd_service_instance.py b/plugins/modules/nd_service_instance.py index 5ef6b97..5e0030c 100644 --- a/plugins/modules/nd_service_instance.py +++ b/plugins/modules/nd_service_instance.py @@ -37,7 +37,7 @@ state: description: - Use C(enable) for enabling a Service Instance. - - Use C(query) for listing all Service Instance. + - Use C(query) for listing all Service Instances. - Use C(restart) for restarting a Service Instance. - Use C(update) for upgrading a Service Instance. - Use C(disable) for disabling a Service Instance. diff --git a/tests/integration/inventory.networking b/tests/integration/inventory.networking index df00b73..472d97b 100644 --- a/tests/integration/inventory.networking +++ b/tests/integration/inventory.networking @@ -25,4 +25,5 @@ deployment_password= management_ip= management_gateway= data_ip= -data_gateway= \ No newline at end of file +data_gateway= +service_package_host=173.36.219.254 diff --git a/tests/integration/targets/nd_service/tasks/main.yml b/tests/integration/targets/nd_service/tasks/main.yml index bcfed01..4977afe 100644 --- a/tests/integration/targets/nd_service/tasks/main.yml +++ b/tests/integration/targets/nd_service/tasks/main.yml @@ -28,7 +28,7 @@ - name: Import cisco-terraform v0.1.16 from the remote location with check mode cisco.nd.nd_service: &cm_imp_v16 <<: *nd_info - import_url: "http://173.36.219.254/cisco-terraform-v0.1.16.aci" + import_url: "http://{{ service_package_host }}/cisco-terraform-v0.1.16.aci" state: present register: cm_imp_v16 check_mode: true @@ -38,7 +38,7 @@ that: - cm_imp_v16 is changed - cm_imp_v16.current != {} - - cm_imp_v16.current.spec.importURL == "http{{':'}}//173.36.219.254/cisco-terraform-v0.1.16.aci" + - cm_imp_v16.current.spec.importURL == "http{{':'}}//{{ service_package_host }}/cisco-terraform-v0.1.16.aci" - cm_imp_v16.previous == [] - name: Import cisco-terraform v0.1.16 from the remote location with normal mode @@ -88,24 +88,24 @@ that: - nm_imp_v16 is changed - nm_imp_v16.current != {} - - nm_imp_v16.current.spec.importURL == "http{{':'}}//173.36.219.254/cisco-terraform-v0.1.16.aci" + - nm_imp_v16.current.spec.importURL == "http{{':'}}//{{ service_package_host }}/cisco-terraform-v0.1.16.aci" - nm_imp_v16.current.status.importStatus == "Downloading" - nm_imp_v16.previous == [] - nm_imp_v16_again is changed - nm_imp_v16_again.current != {} - - nm_imp_v16_again.current.spec.importURL == "http{{':'}}//173.36.219.254/cisco-terraform-v0.1.16.aci" + - nm_imp_v16_again.current.spec.importURL == "http{{':'}}//{{ service_package_host }}/cisco-terraform-v0.1.16.aci" - nm_imp_v16_again.current.status.importStatus == "Downloading" - nm_imp_v16_again.previous != [] - nm_imp_v16_again_1 is changed - nm_imp_v16_again_1.current != {} - - nm_imp_v16_again_1.current.spec.importURL == "http{{':'}}//173.36.219.254/cisco-terraform-v0.1.16.aci" + - nm_imp_v16_again_1.current.spec.importURL == "http{{':'}}//{{ service_package_host }}/cisco-terraform-v0.1.16.aci" - nm_imp_v16_again_1.current.status.importStatus == "Downloading" - nm_imp_v16_again_1.previous != [] - name: Import cisco-terraform v0.1.15 from the remote location with normal mode cisco.nd.nd_service: <<: *cm_imp_v16 - import_url: "http://173.36.219.254/cisco-terraform-v0.1.15.aci" + import_url: "http://{{ service_package_host }}/cisco-terraform-v0.1.15.aci" register: nm_imp_v15 - name: Query all imported service packages @@ -117,7 +117,7 @@ - name: Query all imported service packages with import_url cisco.nd.nd_service: <<: *nd_info - import_url: "http://173.36.219.254/cisco-terraform-v0.1.15.aci" + import_url: "http://{{ service_package_host }}/cisco-terraform-v0.1.15.aci" state: query register: query_all_packages_with_url @@ -135,11 +135,11 @@ - query_all_packages.current != [] - query_package_with_id is not changed - query_package_with_id.current.status.downloadPercentage == 100 - - query_package_with_id.current.spec.importURL == "http://173.36.219.254/cisco-terraform-v0.1.15.aci" + - query_package_with_id.current.spec.importURL == "http://{{ service_package_host }}/cisco-terraform-v0.1.15.aci" - query_all_packages_with_url is not changed - query_all_packages_with_url.current | length == 1 - query_all_packages_with_url.current.0.status.downloadPercentage == 100 - - query_all_packages_with_url.current.0.spec.importURL == "http://173.36.219.254/cisco-terraform-v0.1.15.aci" + - query_all_packages_with_url.current.0.spec.importURL == "http://{{ service_package_host }}/cisco-terraform-v0.1.15.aci" - name: Remove a imported service package with import_id - check mode cisco.nd.nd_service: &cm_rm_package_with_id @@ -166,7 +166,7 @@ - cm_rm_package_with_id is not changed - cm_rm_package_with_id.current != {} - cm_rm_package_with_id.previous != {} - - cm_rm_package_with_id.current.spec.importURL == cm_rm_package_with_id.previous.spec.importURL == "http://173.36.219.254/cisco-terraform-v0.1.16.aci" + - cm_rm_package_with_id.current.spec.importURL == cm_rm_package_with_id.previous.spec.importURL == "http://{{ service_package_host }}/cisco-terraform-v0.1.16.aci" - nm_rm_package_with_id is changed - nm_rm_package_with_id.current == {} - nm_rm_package_with_id.previous != {} @@ -179,7 +179,7 @@ - name: Remove a imported service package with import_url cisco.nd.nd_service: <<: *nd_info - import_url: "http://173.36.219.254/cisco-terraform-v0.1.15.aci" + import_url: "http://{{ service_package_host }}/cisco-terraform-v0.1.15.aci" state: absent register: rm_package_with_url @@ -189,12 +189,12 @@ - rm_package_with_url is changed - rm_package_with_url.current == {} - rm_package_with_url.previous != [] - - rm_package_with_url.previous.0.spec.importURL == "http://173.36.219.254/cisco-terraform-v0.1.15.aci" + - rm_package_with_url.previous.0.spec.importURL == "http://{{ service_package_host }}/cisco-terraform-v0.1.15.aci" - name: Remove a imported service package with import_url to catch errors cisco.nd.nd_service: <<: *nd_info - import_url: "http://173.36.219.254/cisco-terraform-v0.1.16.aci" + import_url: "http://{{ service_package_host }}/cisco-terraform-v0.1.16.aci" state: absent register: nt_rm_package_with_url ignore_errors: true @@ -246,7 +246,7 @@ - name: Invalid test - Remove a imported service package with import_url cisco.nd.nd_service: <<: *nd_info - import_url: "http://173.36.219.254/cisco-terraform-v0.1.15.aci" + import_url: "http://{{ service_package_host }}/cisco-terraform-v0.1.15.aci" import_id: "xyz" state: absent register: nt_rm_package diff --git a/tests/integration/targets/nd_service_instance/tasks/main.yml b/tests/integration/targets/nd_service_instance/tasks/main.yml index 2cf6e8a..4dc4691 100644 --- a/tests/integration/targets/nd_service_instance/tasks/main.yml +++ b/tests/integration/targets/nd_service_instance/tasks/main.yml @@ -62,7 +62,7 @@ - name: Install cisco-terraform v0.1.16 from the remote location cisco.nd.nd_service: <<: *nd_info - import_url: "http://173.36.219.254/cisco-terraform-v0.1.16.aci" + import_url: "http://{{ service_package_host }}/cisco-terraform-v0.1.16.aci" state: present register: install_v16 @@ -82,7 +82,7 @@ - name: Install cisco-terraform v0.1.15 from the remote location cisco.nd.nd_service: <<: *nd_info - import_url: "http://173.36.219.254/cisco-terraform-v0.1.15.aci" + import_url: "http://{{ service_package_host }}/cisco-terraform-v0.1.15.aci" state: present register: install_v15