-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
modify provision_vm_test to fit eco CI
- Loading branch information
1 parent
9bf53a7
commit 88c22c5
Showing
24 changed files
with
549 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
22 changes: 0 additions & 22 deletions
22
tests/integration/targets/provision_vm_test/tasks/main.yml
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
27 changes: 27 additions & 0 deletions
27
tests/integration/targets/vmware_ops_provision_vm_test/run.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
- hosts: localhost | ||
gather_facts: no | ||
collections: | ||
- community.general | ||
|
||
tasks: | ||
- name: Import eco-vcenter credentials | ||
ansible.builtin.include_vars: | ||
file: ../../integration_config.yml | ||
tags: eco-vcenter-ci | ||
|
||
- name: Import simulator vars | ||
ansible.builtin.include_vars: | ||
file: vars.yml | ||
tags: integration-ci | ||
|
||
- name: Vcsim | ||
ansible.builtin.import_role: | ||
name: prepare_soap | ||
tags: integration-ci | ||
|
||
- name: Import provision VM role | ||
ansible.builtin.import_role: | ||
name: vmware_ops_provision_vm_test | ||
tags: | ||
- eco-vcenter-ci | ||
- integration-ci |
14 changes: 14 additions & 0 deletions
14
tests/integration/targets/vmware_ops_provision_vm_test/runme.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/env bash | ||
source ../init.sh | ||
|
||
# Extract the ansible_tags from integration_config.yml | ||
ANSIBLE_TAGS=$(awk '/ansible_tags/ {print $2}' ../../integration_config.yml) | ||
|
||
# Check if the ANSIBLE_TAGS variable is set | ||
if [[ -n "$ANSIBLE_TAGS" ]]; then | ||
echo "ANSIBLE_TAGS is set to: $ANSIBLE_TAGS" | ||
exec ansible-playbook run.yml --tags "$ANSIBLE_TAGS" | ||
else | ||
echo "ANSIBLE_TAGS is not set for Eco vCenter. Running on simulator." | ||
exec ansible-playbook run.yml --tags integration-ci | ||
fi |
23 changes: 23 additions & 0 deletions
23
tests/integration/targets/vmware_ops_provision_vm_test/tasks/cleanup_vms.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
- name: Deprovision VM {{ item.provision_vm_name }} | ||
ansible.builtin.include_role: | ||
name: cloud.vmware_ops.provision_vm | ||
vars: | ||
provision_vm_name: "{{ item.provision_vm_name }}" | ||
provision_vm_state: "absent" | ||
provision_vm_force: true | ||
|
||
- name: "Check that the following VM does not exist: {{ item.provision_vm_name }}" | ||
community.vmware.vmware_vm_info: | ||
hostname: "{{ vcenter_hostname }}" | ||
username: "{{ vcenter_username }}" | ||
password: "{{ vcenter_password }}" | ||
validate_certs: "{{ provision_vm_validate_certs }}" | ||
vm_name: "{{ item.provision_vm_name }}" | ||
register: vm_info | ||
ignore_errors: true | ||
|
||
- name: "Fail the task if the following VM exists: {{ item.provision_vm_name }}" | ||
ansible.builtin.fail: | ||
msg: "Provisioned VM {{ item.provision_vm_name }} still exists" | ||
when: not vm_info.failed |
14 changes: 14 additions & 0 deletions
14
tests/integration/targets/vmware_ops_provision_vm_test/tasks/get_vm_info.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
- name: "Check VM existence: {{ vm_name }}" | ||
community.vmware.vmware_vm_info: | ||
hostname: "{{ vcenter_hostname }}" | ||
username: "{{ vcenter_username }}" | ||
password: "{{ vcenter_password }}" | ||
validate_certs: "{{ provision_vm_validate_certs }}" | ||
vm_name: "{{ vm_name }}" | ||
register: vm_info | ||
|
||
- name: Fail the task if the VM doesn't exist | ||
ansible.builtin.fail: | ||
msg: "Provisioned VM does not exist" | ||
when: vm_info is not defined or vm_info.failed |
36 changes: 36 additions & 0 deletions
36
tests/integration/targets/vmware_ops_provision_vm_test/tasks/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- | ||
- name: Provision VM for simulator | ||
ansible.builtin.import_role: | ||
name: cloud.vmware_ops.provision_vm | ||
when: "'integration-ci' in ansible_run_tags" | ||
|
||
- name: Perform VM Lifecycle Operations in vCenter Environment | ||
block: | ||
- name: Provision multiple VMs | ||
loop: "{{ provision_vms }}" | ||
ansible.builtin.include_tasks: provision_vms_with_validation.yml | ||
|
||
- name: Turn one of the provisioned VMs into template | ||
loop: "{{ provision_vms_template }}" | ||
community.vmware.vmware_guest: | ||
hostname: "{{ provision_vm_hostname }}" | ||
username: "{{ provision_vm_username }}" | ||
password: "{{ provision_vm_password }}" | ||
validate_certs: "{{ provision_vm_validate_certs }}" | ||
name: "{{ item.provision_vm_name }}" | ||
is_template: true | ||
folder: "{{ provision_vm_folder }}" | ||
datacenter: "{{ provision_vm_datacenter }}" | ||
|
||
- name: Create a VM from the template | ||
loop: "{{ provision_vms_from_template }}" | ||
ansible.builtin.include_tasks: provision_vms_with_validation.yml | ||
|
||
- name: Update one the provisioned VMs | ||
ansible.builtin.include_tasks: update_vm.yml | ||
|
||
always: | ||
- name: Cleanup VMs and template from the vcenter env | ||
loop: "{{ provision_vms + provision_vms_template + provision_vms_from_template }}" | ||
ansible.builtin.include_tasks: cleanup_vms.yml | ||
when: "'eco-vcenter-ci' in ansible_run_tags" |
22 changes: 22 additions & 0 deletions
22
tests/integration/targets/vmware_ops_provision_vm_test/tasks/post_update_name_validation.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
- name: Collect information about VM with ID {{ vm_moid }} | ||
vmware.vmware_rest.vcenter_vm_info: | ||
vcenter_hostname: "{{ vcenter_hostname }}" | ||
vcenter_username: "{{ vcenter_username }}" | ||
vcenter_password: "{{ vcenter_password }}" | ||
vcenter_validate_certs: "{{ provision_vm_validate_certs }}" | ||
vm: '{{ vm_moid }}' | ||
register: vm_info_updated_name | ||
|
||
- name: Print vm_info_updated_name for {{ vm_moid }} | ||
ansible.builtin.debug: | ||
var: vm_info_updated_name | ||
|
||
- name: Print vm_name | ||
ansible.builtin.debug: | ||
var: vm_name | ||
|
||
- name: Validate name of VM with ID {{ vm_moid }} | ||
ansible.builtin.assert: | ||
that: | ||
- vm_info_updated_name.value.name == vm_name |
68 changes: 68 additions & 0 deletions
68
...ntegration/targets/vmware_ops_provision_vm_test/tasks/post_update_settings_validation.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
--- | ||
- name: Get info about the updated VM | ||
ansible.builtin.include_tasks: | ||
file: get_vm_info.yml | ||
vars: | ||
vm_name: "{{ vm_update_name }}" | ||
|
||
- name: "Get network info about '{{ vm_update_name }}' VM" | ||
community.vmware.vmware_guest_network: | ||
hostname: "{{ vcenter_hostname }}" | ||
username: "{{ vcenter_username }}" | ||
password: "{{ vcenter_password }}" | ||
validate_certs: "{{ provision_vm_validate_certs }}" | ||
uuid: "{{ vm_uuid }}" | ||
gather_network_info: true | ||
register: vm_network_info | ||
|
||
- name: "Print vm_network_info for '{{ vm_update_name }}'" | ||
ansible.builtin.debug: | ||
var: vm_network_info | ||
|
||
- name: "Validate updated network configuration of '{{ vm_update_name }}' VM" | ||
ansible.builtin.assert: | ||
that: | ||
- vm_network_info.network_info[index].name == network.name | ||
- vm_network_info.network_info[index].device_type == network.device_type | ||
- vm_network_info.network_info[index].mac_address == network.mac | ||
loop: "{{ vm_updated_networks }}" | ||
loop_control: | ||
loop_var: network | ||
index_var: index | ||
|
||
- name: Retrieve the CPU information from the VM | ||
vmware.vmware_rest.vcenter_vm_hardware_cpu_info: | ||
vcenter_hostname: "{{ vcenter_hostname }}" | ||
vcenter_username: "{{ vcenter_username }}" | ||
vcenter_password: "{{ vcenter_password }}" | ||
vcenter_validate_certs: "{{ provision_vm_validate_certs }}" | ||
vm: "{{ vm_moid }}" | ||
register: cpu_info | ||
|
||
- name: Retrieve the memory information from the VM | ||
vmware.vmware_rest.vcenter_vm_hardware_memory_info: | ||
vcenter_hostname: "{{ vcenter_hostname }}" | ||
vcenter_username: "{{ vcenter_username }}" | ||
vcenter_password: "{{ vcenter_password }}" | ||
vcenter_validate_certs: "{{ provision_vm_validate_certs }}" | ||
vm: "{{ vm_moid }}" | ||
register: memory_info | ||
|
||
- name: Retrieve disk information using the disk label | ||
vmware.vmware_rest.vcenter_vm_hardware_disk_info: | ||
vcenter_hostname: "{{ vcenter_hostname }}" | ||
vcenter_username: "{{ vcenter_username }}" | ||
vcenter_password: "{{ vcenter_password }}" | ||
vcenter_validate_certs: "{{ provision_vm_validate_certs }}" | ||
vm: "{{ vm_moid }}" | ||
label: Hard disk 1 | ||
register: disk_info | ||
|
||
- name: "Validate updated configuration of '{{ vm_update_name }}' VM" | ||
ansible.builtin.assert: | ||
that: | ||
- vm_info.virtual_machines[0].guest_fullname == guest_fullnames[vm_updated_guest_id] | ||
- cpu_info.value.count == vm_updated_hardware.num_cpus | ||
- cpu_info.value.cores_per_socket == vm_updated_hardware.num_cpu_cores_per_socket | ||
- memory_info.value.size_MiB == vm_updated_hardware.memory_mb | ||
- disk_info.value.capacity == gib_to_bytes * ( vm_enlarge_disk[0].size_gb | int ) |
11 changes: 11 additions & 0 deletions
11
...s/integration/targets/vmware_ops_provision_vm_test/tasks/post_update_state_validation.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
- name: Get info about the updated VM | ||
ansible.builtin.include_tasks: | ||
file: get_vm_info.yml | ||
vars: | ||
vm_name: "{{ vm_update_name }}" | ||
|
||
- name: "Validate that VM is in state {{ vm_state }}" | ||
ansible.builtin.assert: | ||
that: | ||
- vm_info.virtual_machines[0].power_state | lower == vm_state |
46 changes: 46 additions & 0 deletions
46
.../integration/targets/vmware_ops_provision_vm_test/tasks/provision_vms_with_validation.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
--- | ||
- name: Run Provision VM Role | ||
ansible.builtin.include_role: | ||
name: cloud.vmware_ops.provision_vm | ||
vars: | ||
provision_vm_name: "{{ item.provision_vm_name }}" | ||
provision_vm_state: "{{ item.provision_vm_state | default(omit) }}" | ||
provision_vm_cdrom: "{{ item.provision_vm_cdrom | default(omit) }}" | ||
provision_vm_networks: "{{ item.provision_vm_networks | default(omit) }}" | ||
provision_vm_esxi_hostname: "{{ item.provision_vm_esxi_hostname | default(omit) }}" | ||
provision_vm_resource_pool: "{{ item.provision_vm_resource_pool | default(omit) }}" | ||
provision_vm_port: "{{ item.provision_vm_port | default(omit) }}" | ||
provision_vm_disk: "{{ item.provision_vm_disk | default(omit) }}" | ||
provision_vm_hardware: "{{ item.provision_vm_hardware | default(omit) }}" | ||
provision_vm_guest_id: "{{ item.provision_vm_guest_id | default(omit) }}" | ||
provision_vm_datastore: "{{ item.provision_vm_datastore | default(omit) }}" | ||
provision_vm_template: "{{ item.provision_vm_template | default(omit) }}" | ||
|
||
- name: Run post validations for VMs creation | ||
block: | ||
- name: Get info about the VM | ||
ansible.builtin.include_tasks: | ||
file: get_vm_info.yml | ||
vars: | ||
vm_name: "{{ item.provision_vm_name }}" | ||
|
||
- name: "Validate the properties of the following VM: {{ item.provision_vm_name }}" | ||
ansible.builtin.assert: | ||
that: | ||
- vm_info.virtual_machines[0].guest_name == item.provision_vm_name | ||
- vm_info.virtual_machines[0].cluster == provision_vm_cluster | ||
- vm_info.virtual_machines[0].datacenter == provision_vm_datacenter | ||
- vm_info.virtual_machines[0].folder == provision_vm_folder | ||
- vm_info.virtual_machines[0].power_state | lower == item.provision_vm_state | ||
|
||
- name: "Validate the following VM datastore when datastore was defined in provision_vm_datastore: {{ item.provision_vm_name }}" | ||
ansible.builtin.assert: | ||
that: | ||
- vm_info.virtual_machines[0].datastore_url[0].name == item.provision_vm_datastore | ||
when: "'provision_vm_datastore' in item" | ||
|
||
- name: "Validate the following VM datastore when datastore was defined in provision_vm_disk: {{ item.provision_vm_name }}" | ||
ansible.builtin.assert: | ||
that: | ||
- vm_info.virtual_machines[0].datastore_url[0].name == item.provision_vm_disk[0].datastore | ||
when: "'provision_vm_datastore' not in item" |
Oops, something went wrong.