forked from ansible-collections/vmware.vmware_rest
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modified vcenter_vm_clone_on_library test (ansible-collections#554)
Modified vcenter_vm_clone_on_library test to run on real vCenter env Reviewed-by: mikemorency Reviewed-by: Polina Rabinovich
- Loading branch information
1 parent
2c2acdf
commit 80f3222
Showing
11 changed files
with
152 additions
and
192 deletions.
There are no files selected for viewing
1 change: 0 additions & 1 deletion
1
tests/integration/targets/vcenter_vm_clone_on_library/.gitignore
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
tests/integration/targets/vcenter_vm_clone_on_library/aliases
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
tests/integration/targets/vcenter_vm_clone_on_library/changelogs/fragments/2.2.0.yml
This file was deleted.
Oops, something went wrong.
Empty file.
10 changes: 0 additions & 10 deletions
10
tests/integration/targets/vcenter_vm_clone_on_library/playbook.yml
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
tests/integration/targets/vcenter_vm_clone_on_library/refresh_RETURN_block.sh
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
tests/integration/targets/vcenter_vm_clone_on_library/runme.sh
This file was deleted.
Oops, something went wrong.
160 changes: 0 additions & 160 deletions
160
tests/integration/targets/vcenter_vm_clone_on_library/tasks/main.yml
This file was deleted.
Oops, something went wrong.
5 changes: 5 additions & 0 deletions
5
tests/integration/targets/vmware_rest_vcenter_vm_clone_on_library/defaults/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,5 @@ | ||
--- | ||
resource_pool_name: "{{ tiny_prefix }}-clone-on-library-resource-pool" | ||
vm_name: "{{ tiny_prefix }}-clone-on-library-vm" | ||
vm_from_template_name: "{{ tiny_prefix }}-vm-from-template" | ||
library_name: "{{ tiny_prefix }}-library-on-datastore" |
14 changes: 14 additions & 0 deletions
14
tests/integration/targets/vmware_rest_vcenter_vm_clone_on_library/playbook.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 @@ | ||
- hosts: localhost | ||
gather_facts: no | ||
|
||
tasks: | ||
- name: Import eco-vcenter credentials | ||
ansible.builtin.include_vars: | ||
file: ../group_vars.yml | ||
tags: eco-vcenter-ci | ||
|
||
- name: Import vmware_rest_lookup_plugin test | ||
ansible.builtin.import_role: | ||
name: vmware_rest_vcenter_vm_clone_on_library | ||
tags: | ||
- eco-vcenter-ci |
133 changes: 133 additions & 0 deletions
133
tests/integration/targets/vmware_rest_vcenter_vm_clone_on_library/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,133 @@ | ||
--- | ||
- name: Test VM clone on library | ||
block: | ||
- name: Create a content library based on a DataStore | ||
vmware.vmware_rest.content_locallibrary: | ||
name: "{{ library_name }}" | ||
description: automated | ||
publish_info: | ||
published: true | ||
authentication_method: 'NONE' | ||
storage_backings: | ||
- datastore_id: "{{ lookup('vmware.vmware_rest.datastore_moid', '/' + vcenter_datacenter + '/' + eco_nfs_datastore_iso) }}" | ||
type: 'DATASTORE' | ||
state: present | ||
register: nfs_lib | ||
|
||
- name: Create a generic resource pool | ||
vmware.vmware_rest.vcenter_resourcepool: | ||
name: "{{ resource_pool_name }}" | ||
parent: "{{ lookup('vmware.vmware_rest.resource_pool_moid', '/' + vcenter_datacenter + '/' + vcenter_cluster_name + '/' + vcenter_resource_pool) }}" | ||
register: resource_pool_info | ||
|
||
- name: Create a VM | ||
vmware.vmware_rest.vcenter_vm: | ||
placement: | ||
cluster: "{{ lookup('vmware.vmware_rest.cluster_moid', '/' + vcenter_datacenter + '/' + vcenter_cluster_name) }}" | ||
datastore: "{{ lookup('vmware.vmware_rest.datastore_moid', '/' + vcenter_datacenter + '/' + shared_storage_01) }}" | ||
folder: "{{ lookup('vmware.vmware_rest.folder_moid', '/' + vcenter_datacenter + '/' + vcenter_vm_folder) }}" | ||
resource_pool: "{{ resource_pool_info.id }}" | ||
name: "{{ vm_name }}" | ||
guest_OS: RHEL_9_64 | ||
hardware_version: VMX_21 | ||
memory: | ||
hot_add_enabled: true | ||
size_MiB: 2000 | ||
nics: | ||
- type: VMXNET3 | ||
backing: | ||
type: DISTRIBUTED_PORTGROUP | ||
network: "{{ lookup('vmware.vmware_rest.network_moid', '/' + vcenter_datacenter + '/' + vm_network_name) }}" | ||
start_connected: true | ||
cdroms: | ||
- backing: | ||
type: ISO_FILE | ||
iso_file: "{{ rhel_9_3_iso_path }}" | ||
start_connected: true | ||
register: test_vm | ||
|
||
- name: Create a VM template on the library | ||
vmware.vmware_rest.vcenter_vmtemplate_libraryitems: | ||
name: "{{ vm_name }}-template" | ||
library: "{{ nfs_lib.id }}" | ||
source_vm: "{{ test_vm.id }}" | ||
placement: | ||
cluster: "{{ lookup('vmware.vmware_rest.cluster_moid', '/' + vcenter_datacenter + '/' + vcenter_cluster_name) }}" | ||
folder: "{{ lookup('vmware.vmware_rest.folder_moid', '/' + vcenter_datacenter + '/' + vcenter_vm_folder) }}" | ||
resource_pool: "{{ resource_pool_info.id }}" | ||
register: nfs_lib_item | ||
|
||
- name: Verify VM template added to the library | ||
ansible.builtin.assert: | ||
that: | ||
- nfs_lib_item is changed | ||
|
||
- name: _Create the same template again | ||
vmware.vmware_rest.vcenter_vmtemplate_libraryitems: | ||
name: "{{ vm_name }}-template" | ||
library: "{{ nfs_lib.id }}" | ||
source_vm: "{{ test_vm.id }}" | ||
placement: | ||
cluster: "{{ lookup('vmware.vmware_rest.cluster_moid', '/' + vcenter_datacenter + '/' + vcenter_cluster_name) }}" | ||
folder: "{{ lookup('vmware.vmware_rest.folder_moid', '/' + vcenter_datacenter + '/' + vcenter_vm_folder) }}" | ||
resource_pool: "{{ resource_pool_info.id }}" | ||
register: _result | ||
|
||
- name: Verify no VM template added to the library | ||
ansible.builtin.assert: | ||
that: | ||
- not (_result is changed) | ||
|
||
- name: Get the list of items of the NFS library | ||
vmware.vmware.content_library_item_info: | ||
library_id: '{{ nfs_lib.id }}' | ||
register: nfs_lib_items | ||
|
||
- name: Verify VM template name | ||
ansible.builtin.assert: | ||
that: | ||
- nfs_lib_items.library_item_info[0].name == "{{ vm_name }}-template" | ||
|
||
- name: Deploy a new VM based on the template | ||
vmware.vmware_rest.vcenter_vmtemplate_libraryitems: | ||
name: "{{ vm_from_template_name }}" | ||
library: "{{ nfs_lib.id }}" | ||
template_library_item: "{{ nfs_lib_item.id }}" | ||
placement: | ||
cluster: "{{ lookup('vmware.vmware_rest.cluster_moid', '/' + vcenter_datacenter + '/' + vcenter_cluster_name) }}" | ||
folder: "{{ lookup('vmware.vmware_rest.folder_moid', '/' + vcenter_datacenter + '/' + vcenter_vm_folder) }}" | ||
resource_pool: "{{ resource_pool_info.id }}" | ||
state: deploy | ||
register: vm_from_template | ||
|
||
- name: Retrieve all the details about the new VM | ||
vmware.vmware_rest.vcenter_vm: | ||
vm: "{{ vm_from_template.value }}" | ||
register: vm_from_template_info | ||
|
||
- name: Verify VM from template name | ||
ansible.builtin.assert: | ||
that: | ||
- vm_from_template_info.value.name == vm_from_template_name | ||
|
||
always: | ||
- name: Delete test VM's | ||
vmware.vmware_rest.vcenter_vm: | ||
vm: "{{ lookup('vmware.vmware_rest.vm_moid', '/' + vcenter_datacenter + '/' + vcenter_cluster_name + '/' + vm_name) }}" | ||
state: absent | ||
|
||
- name: Delete VM from template | ||
vmware.vmware_rest.vcenter_vm: | ||
vm: "{{ lookup('vmware.vmware_rest.vm_moid', '/' + vcenter_datacenter + '/' + vcenter_cluster_name + '/' + vm_from_template_name) }}" | ||
state: absent | ||
|
||
- name: Delete nfs library | ||
vmware.vmware_rest.content_locallibrary: | ||
library_id: "{{ nfs_lib.id }}" | ||
state: absent | ||
when: nfs_lib is defined | ||
|
||
- name: Delete resource pool | ||
vmware.vmware_rest.vcenter_resourcepool: | ||
resource_pool: "{{ lookup('vmware.vmware_rest.resource_pool_moid', '/' + vcenter_datacenter + '/' + vcenter_cluster_name + '/' + resource_pool_name) }}" | ||
state: absent |