Skip to content

Commit

Permalink
[ignore] Added service_package_host variable to the inventory.network…
Browse files Browse the repository at this point in the history
…ing file
  • Loading branch information
sajagana committed Oct 18, 2023
1 parent adbb694 commit 6a48e14
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 24 deletions.
10 changes: 4 additions & 6 deletions plugins/modules/nd_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ]
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/nd_service_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion tests/integration/inventory.networking
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ deployment_password=<TODO>
management_ip=<TODO>
management_gateway=<TODO>
data_ip=<TODO>
data_gateway=<TODO>
data_gateway=<TODO>
service_package_host=173.36.219.254
28 changes: 14 additions & 14 deletions tests/integration/targets/nd_service/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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
Expand All @@ -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 != {}
Expand All @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/targets/nd_service_instance/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down

0 comments on commit 6a48e14

Please sign in to comment.