vmware: refactoring of vmware test roles -- part4

Refactoring of the following roles to make use of the new
`prepare_vmware_tests` role.

- `vmware_guest`
- `vmware_guest_boot_facts`
- `vmware_guest_custom_attribute_defs`
- `vmware_guest_customization_facts`
- `vmware_guest_disk_facts`
- `vmware_guest_facts`
- `vmware_guest_find`
- `vmware_guest_move`
- `vmware_guest_powerstate`
- `vmware_guest_snapshot`
- `vmware_guest_snapshot_facts`
- `vmware_guest_tools_wait`

This patch depends on: https://github.com/ansible/ansible/pull/55719

Original PR: https://github.com/ansible/ansible/pull/54882
pull/55992/head
Gonéri Le Bouder 6 years ago
parent 281cfcddb1
commit e4cca4e40a

@ -1,2 +1,3 @@
shippable/vcenter/group1 shippable/vcenter/group1
cloud/vcenter cloud/vcenter
needs/target/prepare_vmware_tests

@ -2,40 +2,12 @@
# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com> # Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
- name: Wait for Flask controller to come up online
wait_for:
host: "{{ vcsim }}"
port: 5000
state: started
- name: kill vcsim
uri:
url: http://{{ vcsim }}:5000/killall
- name: start vcsim with no folders
uri:
url: http://{{ vcsim }}:5000/spawn?datacenter=1&cluster=1&folder=0
register: vcsim_instance
- name: Wait for Flask controller to come up online
wait_for:
host: "{{ vcsim }}"
port: 443
state: started
- name: get a list of VMS from vcsim
uri:
url: http://{{ vcsim }}:5000/govc_find?filter=VM
register: vmlist
- debug: var=vcsim_instance
- debug: var=vmlist
- name: create new VMs with boot_firmware as 'bios' - name: create new VMs with boot_firmware as 'bios'
vmware_guest: vmware_guest:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
name: "{{ 'newvm_' + item|basename }}" name: "{{ 'newvm_' + item|basename }}"
guest_id: centos64Guest guest_id: centos64Guest
datacenter: "{{ (item|basename).split('_')[0] }}" datacenter: "{{ (item|basename).split('_')[0] }}"
@ -63,9 +35,9 @@
#- name: create new VMs again with boot_firmware as 'bios' #- name: create new VMs again with boot_firmware as 'bios'
# vmware_guest: # vmware_guest:
# validate_certs: False # validate_certs: False
# hostname: "{{ vcsim }}" # hostname: "{{ vcenter_hostname }}"
# username: "{{ vcsim_instance['json']['username'] }}" # username: "{{ vcenter_username }}"
# password: "{{ vcsim_instance['json']['password'] }}" # password: "{{ vcenter_password }}"
# name: "{{ 'newvm_' + item|basename }}" # name: "{{ 'newvm_' + item|basename }}"
# guest_id: centos64Guest # guest_id: centos64Guest
# datacenter: "{{ (item|basename).split('_')[0] }}" # datacenter: "{{ (item|basename).split('_')[0] }}"
@ -92,9 +64,9 @@
- name: create new VMs with boot_firmware as 'efi' - name: create new VMs with boot_firmware as 'efi'
vmware_guest: vmware_guest:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
name: "{{ 'newvm_efi_' + item|basename }}" name: "{{ 'newvm_efi_' + item|basename }}"
guest_id: centos64Guest guest_id: centos64Guest
datacenter: "{{ (item|basename).split('_')[0] }}" datacenter: "{{ (item|basename).split('_')[0] }}"
@ -122,9 +94,9 @@
#- name: create new VMs again with boot_firmware as 'efi' #- name: create new VMs again with boot_firmware as 'efi'
# vmware_guest: # vmware_guest:
# validate_certs: False # validate_certs: False
# hostname: "{{ vcsim }}" # hostname: "{{ vcenter_hostname }}"
# username: "{{ vcsim_instance['json']['username'] }}" # username: "{{ vcenter_username }}"
# password: "{{ vcsim_instance['json']['password'] }}" # password: "{{ vcenter_password }}"
# name: "{{ 'newvm_efi_' + item|basename }}" # name: "{{ 'newvm_efi_' + item|basename }}"
# guest_id: centos64Guest # guest_id: centos64Guest
# datacenter: "{{ (item|basename).split('_')[0] }}" # datacenter: "{{ (item|basename).split('_')[0] }}"

@ -1,41 +1,13 @@
- name: Wait for Flask controller to come up online
wait_for:
host: "{{ vcsim }}"
port: 5000
state: started
- name: kill vcsim
uri:
url: "{{ 'http://' + vcsim + ':5000/killall' }}"
- name: start vcsim with no folders
uri:
url: "{{ 'http://' + vcsim + ':5000/spawn?datacenter=1&cluster=1&folder=0' }}"
register: vcsim_instance
- name: Wait for Flask controller to come up online
wait_for:
host: "{{ vcsim }}"
port: 443
state: started
- name: get a list of Clusters from vcsim
uri:
url: "{{ 'http://' + vcsim + ':5000/govc_find?filter=CCR' }}"
register: clusterlist
- debug: var=vcsim_instance
- debug: var=clusterlist
- name: Create VM with CDROM - name: Create VM with CDROM
vmware_guest: vmware_guest:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
folder: "/{{ (clusterlist['json'][0]|basename).split('_')[0] }}/vm" folder: "vm"
name: CDROM-Test name: CDROM-Test
datacenter: "{{ (clusterlist['json'][0]|basename).split('_')[0] }}" datacenter: "{{ dc1 }}"
cluster: "{{ clusterlist['json'][0]|basename }}" cluster: "{{ ccr1 }}"
resource_pool: Resources resource_pool: Resources
guest_id: centos64Guest guest_id: centos64Guest
hardware: hardware:
@ -62,12 +34,12 @@
- name: Update CDROM to iso for the new VM - name: Update CDROM to iso for the new VM
vmware_guest: vmware_guest:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
folder: "/{{ (clusterlist['json'][0]|basename).split('_')[0] }}/vm" folder: "vm"
name: CDROM-Test name: CDROM-Test
datacenter: "{{ (clusterlist['json'][0]|basename).split('_')[0] }}" datacenter: "{{ dc1 }}"
cdrom: cdrom:
type: iso type: iso
iso_path: "[LocalDS_0] base_new.iso" iso_path: "[LocalDS_0] base_new.iso"
@ -85,12 +57,12 @@
- name: Update CDROM to client for the new VM - name: Update CDROM to client for the new VM
vmware_guest: vmware_guest:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
folder: "/{{ (clusterlist['json'][0]|basename).split('_')[0] }}/vm" folder: vm
name: CDROM-Test name: CDROM-Test
datacenter: "{{ (clusterlist['json'][0]|basename).split('_')[0] }}" datacenter: "{{ dc1 }}"
cdrom: cdrom:
type: client type: client
state: present state: present
@ -107,12 +79,12 @@
- name: Update CDROM to none for the new VM - name: Update CDROM to none for the new VM
vmware_guest: vmware_guest:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
folder: "/{{ (clusterlist['json'][0]|basename).split('_')[0] }}/vm" folder: vm
name: CDROM-Test name: CDROM-Test
datacenter: "{{ (clusterlist['json'][0]|basename).split('_')[0] }}" datacenter: "{{ dc1 }}"
cdrom: cdrom:
type: none type: none
state: present state: present
@ -129,13 +101,13 @@
- name: Create VM with multiple disks and a CDROM - GitHub issue 38679 - name: Create VM with multiple disks and a CDROM - GitHub issue 38679
vmware_guest: vmware_guest:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
folder: "/{{ (clusterlist['json'][0]|basename).split('_')[0] }}/vm" folder: vm
name: CDROM-Test-38679 name: CDROM-Test-38679
datacenter: "{{ (clusterlist['json'][0]|basename).split('_')[0] }}" datacenter: "{{ dc1 }}"
cluster: "{{ clusterlist['json'][0].split('/')[-1] }}" cluster: "{{ ccr1 }}"
resource_pool: Resources resource_pool: Resources
guest_id: centos64Guest guest_id: centos64Guest
hardware: hardware:
@ -170,13 +142,13 @@
#- name: Again create VM with multiple disks and a CDROM - GitHub issue 38679 #- name: Again create VM with multiple disks and a CDROM - GitHub issue 38679
# vmware_guest: # vmware_guest:
# validate_certs: False # validate_certs: False
# hostname: "{{ vcsim }}" # hostname: "{{ vcenter_hostname }}"
# username: "{{ vcsim_instance['json']['username'] }}" # username: "{{ vcenter_username }}"
# password: "{{ vcsim_instance['json']['password'] }}" # password: "{{ vcenter_password }}"
# folder: "/{{ (clusterlist['json'][0]|basename).split('_')[0] }}/vm" # folder: "/{{ (clusters['json'][0]|basename).split('_')[0] }}/vm"
# name: CDROM-Test-38679 # name: CDROM-Test-38679
# datacenter: "{{ (clusterlist['json'][0]|basename).split('_')[0] }}" # datacenter: "{{ (clusters['json'][0]|basename).split('_')[0] }}"
# cluster: "{{ clusterlist['json'][0] }}" # cluster: "{{ clusters['json'][0] }}"
# resource_pool: Resources # resource_pool: Resources
# guest_id: centos64Guest # guest_id: centos64Guest
# hardware: # hardware:

@ -2,46 +2,14 @@
# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com> # Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
- name: Wait for Flask controller to come up online
wait_for:
host: "{{ vcsim }}"
port: 5000
state: started
- name: kill vcsim
uri:
url: http://{{ vcsim }}:5000/killall
- name: start vcsim with no folders
uri:
url: http://{{ vcsim }}:5000/spawn?datacenter=1&cluster=1&folder=0
register: vcsim_instance
- name: Wait for Flask controller to come up online
wait_for:
host: "{{ vcsim }}"
port: 443
state: started
- name: get a list of VMS from vcsim
uri:
url: http://{{ vcsim }}:5000/govc_find?filter=VM
register: vmlist
- debug: var=vcsim_instance
- debug: var=vmlist
- name: get a guest
set_fact:
guest1: "{{ vmlist.json[0] }}"
- name: Perform all operation in check mode - name: Perform all operation in check mode
vmware_guest: vmware_guest:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
name: "{{ guest1|basename }}" name: "{{ infra.vm_list[0] }}"
datacenter: "{{ (guest1|basename).split('_')[0] }}" datacenter: "{{ dc1 }}"
state: "{{ item }}" state: "{{ item }}"
with_items: with_items:
- absent - absent
@ -55,22 +23,23 @@
register: check_mode_state register: check_mode_state
check_mode: yes check_mode: yes
- debug: var=check_mode_state - debug:
var: check_mode_state
- name: assert that changes were made - name: assert that changes were made
assert: assert:
that: that:
- "check_mode_state.results|map(attribute='changed')|unique|list == [true]" - "check_mode_state.results|map(attribute='changed')|unique|list == [true]"
- "check_mode_state.results|map(attribute='vm_name')|unique|list == [ guest1 | basename ]" - "check_mode_state.results|map(attribute='vm_name')|unique|list == [ infra.vm_list[0] ]"
- name: Perform all operation on non-existent VM in check mode - name: Perform all operation on non-existent VM in check mode
vmware_guest: vmware_guest:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
name: non_existent_vm name: non_existent_vm
datacenter: "{{ (guest1|basename).split('_')[0] }}" datacenter: "{{ dc1 }}"
state: "{{ item }}" state: "{{ item }}"
with_items: with_items:
- present - present
@ -81,7 +50,8 @@
register: check_mode_state register: check_mode_state
check_mode: yes check_mode: yes
- debug: var=check_mode_state - debug:
var: check_mode_state
- name: assert that changes were made - name: assert that changes were made
assert: assert:

@ -2,56 +2,100 @@
# Copyright: (c) 2017, James Tanner <tanner.jc@gmail.com> # Copyright: (c) 2017, James Tanner <tanner.jc@gmail.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
- name: Wait for Flask controller to come up online - name: create new linked clone without specifying snapshot_src
wait_for:
host: "{{ vcsim }}"
port: 5000
state: started
- name: kill vcsim
uri:
url: http://{{ vcsim }}:5000/killall
- name: start vcsim with no folders
uri:
url: http://{{ vcsim }}:5000/spawn?datacenter=1&cluster=1&folder=0
register: vcsim_instance
- name: Wait for Flask controller to come up online
wait_for:
host: "{{ vcsim }}"
port: 443
state: started
- name: get a list of VMS from vcsim
uri:
url: http://{{ vcsim }}:5000/govc_find?filter=VM
register: vmlist
- debug: var=vcsim_instance
- debug: var=vmlist
- name: set state to poweroff on all VMs
vmware_guest: vmware_guest:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
name: "{{ 'newvm_' + item|basename }}" name: new_vm_1
template: "{{ item|basename }}" template: "{{ infra.vm_list[0] }}"
datacenter: "{{ (item|basename).split('_')[0] }}" guest_id: centos64Guest
disk: datacenter: "{{ dc1 }}"
- size: 1gb folder: D1/C1/F0
type: thin linked_clone: True
autoselect_datastore: True register: linked_clone_d1_c1_f0
state: poweredoff ignore_errors: True
folder: "{{ item|dirname }}"
convert: thin - debug:
with_items: "{{ vmlist['json'] }}" var: linked_clone_d1_c1_f0
register: clone_d1_c1_f0
- name: assert that changes were not made
- debug: var=clone_d1_c1_f0
- name: assert that changes were made
assert: assert:
that: that:
- "clone_d1_c1_f0.results|map(attribute='changed')|unique|list == [true]" - not (linked_clone_d1_c1_f0 is changed)
- name: create new linked clone without specifying linked_clone
vmware_guest:
validate_certs: False
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
name: new_vm_2
template: "{{ infra.vm_list[0] }}"
guest_id: centos64Guest
datacenter: "{{ dc1 }}"
folder: D1/C1/F0
snapshot_src: "snap_shot1"
register: linked_clone_d1_c1_f0
ignore_errors: True
- debug:
var: linked_clone_d1_c1_f0
- name: assert that changes were not made
assert:
that:
- not (linked_clone_d1_c1_f0 is changed)
# TODO: VCSIM: snapshot is not supported in current vcsim
#
#- name: create new linked clone with linked_clone and snapshot_src
# vmware_guest:
# validate_certs: False
# hostname: "{{ vcenter_hostname }}"
# username: "{{ vcenter_username }}"
# password: "{{ vcenter_password }}"
# name: "{{ 'new_vm_' + item|basename }}"
# template: "{{ item|basename }}"
# guest_id: centos64Guest
# datacenter: "{{ (item|basename).split('_')[0] }}"
# folder: "{{ item|dirname }}"
# snapshot_src: "snap_shot1"
# linked_clone: True
# with_items: "{{ vmlist['json'] }}"
# register: linked_clone_d1_c1_f0
# ignore_errors: True
#- debug: var=linked_clone_d1_c1_f0
#- name: assert that changes were made
# assert:
# that:
# - "linked_clone_d1_c1_f0.results|map(attribute='changed')|unique|list == [true]"
# TODO: VCSIM: snapshot is not supported in current vcsim
#
#- name: create new linked clone with linked_clone and snapshot_src again
# vmware_guest:
# validate_certs: False
# hostname: "{{ vcenter_hostname }}"
# username: "{{ vcenter_username }}"
# password: "{{ vcenter_password }}"
# name: "{{ 'new_vm_' + item|basename }}"
# template: "{{ item|basename }}"
# guest_id: centos64Guest
# datacenter: "{{ (item|basename).split('_')[0] }}"
# folder: "{{ item|dirname }}"
# snapshot_src: "snap_shot1"
# linked_clone: True
# with_items: "{{ vmlist['json'] }}"
# register: linked_clone_d1_c1_f0
# ignore_errors: True
#- debug: var=linked_clone_d1_c1_f0
#- name: assert that changes were not made
# assert:
# that:
# - "linked_clone_d1_c1_f0.results|map(attribute='changed')|unique|list == [false]"

@ -2,41 +2,12 @@
# Copyright: (c) 2018, Christophe FERREIRA <christophe.ferreira@cnaf.fr> # Copyright: (c) 2018, Christophe FERREIRA <christophe.ferreira@cnaf.fr>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
- name: Wait for Flask controller to come up online
wait_for:
host: "{{ vcsim }}"
port: 5000
state: started
- name: kill vcsim
uri:
url: http://{{ vcsim }}:5000/killall
- name: start vcsim with no folders
uri:
url: http://{{ vcsim }}:5000/spawn?datacenter=1&cluster=1&folder=0
register: vcsim_instance
- name: Wait for Flask controller to come up online
wait_for:
host: "{{ vcsim }}"
port: 443
state: started
- name: get a list of VMS from vcsim
uri:
url: http://{{ vcsim }}:5000/govc_find?filter=VM
register: vmlist
- debug: var=vcsim_instance
- debug: var=vmlist
- name: clone vm from template and convert to thin - name: clone vm from template and convert to thin
vmware_guest: vmware_guest:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
name: "{{ 'thin_' + item|basename }}" name: "{{ 'thin_' + item|basename }}"
template: "{{ item|basename }}" template: "{{ item|basename }}"
datacenter: "{{ (item|basename).split('_')[0] }}" datacenter: "{{ (item|basename).split('_')[0] }}"
@ -56,9 +27,9 @@
- name: clone vm from template and convert to thick - name: clone vm from template and convert to thick
vmware_guest: vmware_guest:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
name: "{{ 'thick_' + item|basename }}" name: "{{ 'thick_' + item|basename }}"
template: "{{ item|basename }}" template: "{{ item|basename }}"
datacenter: "{{ (item|basename).split('_')[0] }}" datacenter: "{{ (item|basename).split('_')[0] }}"
@ -78,9 +49,9 @@
- name: clone vm from template and convert to eagerzeroedthick - name: clone vm from template and convert to eagerzeroedthick
vmware_guest: vmware_guest:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
name: "{{ 'eagerzeroedthick_' + item|basename }}" name: "{{ 'eagerzeroedthick_' + item|basename }}"
template: "{{ item|basename }}" template: "{{ item|basename }}"
datacenter: "{{ (item|basename).split('_')[0] }}" datacenter: "{{ (item|basename).split('_')[0] }}"

@ -2,44 +2,16 @@
# Copyright: (c) 2017, James Tanner <tanner.jc@gmail.com> # Copyright: (c) 2017, James Tanner <tanner.jc@gmail.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
- name: Wait for Flask controller to come up online
wait_for:
host: "{{ vcsim }}"
port: 5000
state: started
- name: kill vcsim
uri:
url: http://{{ vcsim }}:5000/killall
- name: start vcsim with no folders
uri:
url: http://{{ vcsim }}:5000/spawn?datacenter=1&cluster=1&folder=0
register: vcsim_instance
- name: Wait for Flask controller to come up online
wait_for:
host: "{{ vcsim }}"
port: 443
state: started
- name: get a list of VMS from vcsim
uri:
url: http://{{ vcsim }}:5000/govc_find?filter=VM
register: vmlist
- debug: var=vcsim_instance
- debug: var=vmlist
- name: create new VMs - name: create new VMs
vmware_guest: vmware_guest:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
name: "{{ 'newvm_' + item|basename }}" name: newvm_1
#template: "{{ item|basename }}" #template: "{{ item|basename }}"
guest_id: centos64Guest guest_id: centos64Guest
datacenter: "{{ (item|basename).split('_')[0] }}" datacenter: "{{ dc1 }}"
hardware: hardware:
num_cpus: 4 num_cpus: 4
num_cpu_cores_per_socket: 2 num_cpu_cores_per_socket: 2
@ -62,8 +34,7 @@
type: thin type: thin
autoselect_datastore: True autoselect_datastore: True
state: poweredoff state: poweredoff
folder: "{{ item|dirname }}" folder: F0
with_items: "{{ vmlist['json'] }}"
register: clone_d1_c1_f0 register: clone_d1_c1_f0
- debug: var=clone_d1_c1_f0 - debug: var=clone_d1_c1_f0
@ -71,18 +42,18 @@
- name: assert that changes were made - name: assert that changes were made
assert: assert:
that: that:
- "clone_d1_c1_f0.results|map(attribute='changed')|unique|list == [true]" - clone_d1_c1_f0 is changed
- name: create new VMs again - name: create the VM again
vmware_guest: vmware_guest:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
name: "{{ 'newvm_' + item|basename }}" name: newvm_1
#template: "{{ item|basename }}" #template: "{{ item|basename }}"
guest_id: centos64Guest guest_id: centos64Guest
datacenter: "{{ (item|basename).split('_')[0] }}" datacenter: "{{ dc1 }}"
hardware: hardware:
num_cpus: 4 num_cpus: 4
num_cpu_cores_per_socket: 2 num_cpu_cores_per_socket: 2
@ -92,8 +63,7 @@
type: thin type: thin
autoselect_datastore: True autoselect_datastore: True
state: poweredoff state: poweredoff
folder: "{{ item|dirname }}" folder: F0
with_items: "{{ vmlist['json'] }}"
register: clone_d1_c1_f0_recreate register: clone_d1_c1_f0_recreate
- debug: var=clone_d1_c1_f0_recreate - debug: var=clone_d1_c1_f0_recreate
@ -101,30 +71,23 @@
- name: assert that no changes were made after re-creating - name: assert that no changes were made after re-creating
assert: assert:
that: that:
- "clone_d1_c1_f0_recreate.results|map(attribute='changed')|unique|list == [false]" - not (clone_d1_c1_f0_recreate is changed)
- name: assert that no changes were made after re-creating VM and task returns facts
assert:
that:
- "'newvm_' + item | basename in clone_d1_c1_f0.results|map(attribute='instance.hw_name')|list"
with_items: "{{ vmlist['json'] }}"
- name: modify the new VMs - name: modify the new VMs
vmware_guest: vmware_guest:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
name: "{{ 'newvm_' + item|basename }}" name: newvm_1
#template: "{{ item|basename }}" #template: "{{ item|basename }}"
guest_id: centos64Guest guest_id: centos64Guest
datacenter: "{{ (item|basename).split('_')[0] }}" datacenter: "{{ dc1 }}"
hardware: hardware:
num_cpus: 2 num_cpus: 2
memory_mb: 1024 memory_mb: 1024
state: present state: present
folder: "{{ item|dirname }}" folder: F0
with_items: "{{ vmlist['json'] }}"
register: clone_d1_c1_f0_modify register: clone_d1_c1_f0_modify
- debug: var=clone_d1_c1_f0_modify - debug: var=clone_d1_c1_f0_modify
@ -132,24 +95,23 @@
- name: assert that changes were made with modification - name: assert that changes were made with modification
assert: assert:
that: that:
- "clone_d1_c1_f0_modify.results|map(attribute='changed')|unique|list == [true]" - clone_d1_c1_f0_modify is changed
- name: re-modify the new VMs - name: re-modify the new VMs
vmware_guest: vmware_guest:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
name: "{{ 'newvm_' + item|basename }}" name: newvm_1
#template: "{{ item|basename }}" #template: "{{ item|basename }}"
guest_id: centos64Guest guest_id: centos64Guest
datacenter: "{{ (item|basename).split('_')[0] }}" datacenter: "{{ dc1 }}"
hardware: hardware:
num_cpus: 2 num_cpus: 2
memory_mb: 1024 memory_mb: 1024
state: present state: present
folder: "{{ item|dirname }}" folder: F0
with_items: "{{ vmlist['json'] }}"
register: clone_d1_c1_f0_remodify register: clone_d1_c1_f0_remodify
- debug: var=clone_d1_c1_f0_remodify - debug: var=clone_d1_c1_f0_remodify
@ -157,21 +119,20 @@
- name: assert that no changes were made when re-modified - name: assert that no changes were made when re-modified
assert: assert:
that: that:
- "clone_d1_c1_f0_remodify.results|map(attribute='changed')|unique|list == [false]" - not (clone_d1_c1_f0_remodify is changed)
- name: delete the new VMs - name: delete the new VMs
vmware_guest: vmware_guest:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
name: "{{ 'newvm_' + item|basename }}" name: newvm_1
#template: "{{ item|basename }}" #template: "{{ item|basename }}"
#guest_id: centos64Guest #guest_id: centos64Guest
datacenter: "{{ (item|basename).split('_')[0] }}" datacenter: "{{ dc1 }}"
state: absent state: absent
folder: "{{ item|dirname }}" folder: F0
with_items: "{{ vmlist['json'] }}"
register: clone_d1_c1_f0_delete register: clone_d1_c1_f0_delete
- debug: var=clone_d1_c1_f0_delete - debug: var=clone_d1_c1_f0_delete
@ -179,21 +140,20 @@
- name: assert that changes were made with deletion - name: assert that changes were made with deletion
assert: assert:
that: that:
- "clone_d1_c1_f0_delete.results|map(attribute='changed')|unique|list == [true]" - clone_d1_c1_f0_delete is changed
- name: re-delete the new VMs - name: re-delete the new VMs
vmware_guest: vmware_guest:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
name: "{{ 'newvm_' + item|basename }}" name: newvm_1
#template: "{{ item|basename }}" #template: "{{ item|basename }}"
#guest_id: centos64Guest #guest_id: centos64Guest
datacenter: "{{ (item|basename).split('_')[0] }}" datacenter: "{{ dc1 }}"
state: absent state: absent
folder: "{{ item|dirname }}" folder: F0
with_items: "{{ vmlist['json'] }}"
register: clone_d1_c1_f0_redelete register: clone_d1_c1_f0_redelete
- debug: var=clone_d1_c1_f0_redelete - debug: var=clone_d1_c1_f0_redelete
@ -201,4 +161,4 @@
- name: assert that no changes were made with redeletion - name: assert that no changes were made with redeletion
assert: assert:
that: that:
- "clone_d1_c1_f0_redelete.results|map(attribute='changed')|unique|list == [false]" - not (clone_d1_c1_f0_redelete is changed)

@ -2,35 +2,6 @@
# Copyright: (c) 2018 Abhijeet Kasurde <akasurde@redhat.com> # Copyright: (c) 2018 Abhijeet Kasurde <akasurde@redhat.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
- name: Wait for Flask controller to come up online
wait_for:
host: "{{ vcsim }}"
port: 5000
state: started
- name: kill vcsim
uri:
url: http://{{ vcsim }}:5000/killall
- name: start vcsim with no folders
uri:
url: http://{{ vcsim }}:5000/spawn?datacenter=1&cluster=1&folder=0
register: vcsim_instance
- name: Wait for Flask controller to come up online
wait_for:
host: "{{ vcsim }}"
port: 443
state: started
- name: get a list of VMS from vcsim
uri:
url: http://{{ vcsim }}:5000/govc_find?filter=VM
register: vmlist
- debug: var=vcsim_instance
- debug: var=vmlist
- name: create new VMs without connection parameters - name: create new VMs without connection parameters
vmware_guest: vmware_guest:
name: "{{ 'newvm_' + item|basename }}" name: "{{ 'newvm_' + item|basename }}"
@ -73,7 +44,7 @@
register: clone_d1_c1_f0_env register: clone_d1_c1_f0_env
ignore_errors: True ignore_errors: True
environment: environment:
VMWARE_HOST: "{{ vcsim }}" VMWARE_HOST: "{{ vcenter_hostname }}"
- debug: var=clone_d1_c1_f0_env - debug: var=clone_d1_c1_f0_env
- name: assert that changes were made - name: assert that changes were made
@ -99,8 +70,8 @@
register: clone_d1_c1_f0_env register: clone_d1_c1_f0_env
ignore_errors: True ignore_errors: True
environment: environment:
VMWARE_HOST: "{{ vcsim }}" VMWARE_HOST: "{{ vcenter_hostname }}"
VMWARE_USER: "{{ vcsim_instance['json']['username'] }}" VMWARE_USER: "{{ vcenter_username }}"
- debug: var=clone_d1_c1_f0_env - debug: var=clone_d1_c1_f0_env
- name: assert that changes were not made - name: assert that changes were not made
@ -125,9 +96,9 @@
with_items: "{{ vmlist['json'] }}" with_items: "{{ vmlist['json'] }}"
register: clone_d1_c1_f0_env register: clone_d1_c1_f0_env
environment: environment:
VMWARE_HOST: "{{ vcsim }}" VMWARE_HOST: "{{ vcenter_hostname }}"
VMWARE_USER: "{{ vcsim_instance['json']['username'] }}" VMWARE_USER: "{{ vcenter_username }}"
VMWARE_PASSWORD: "{{ vcsim_instance['json']['password'] }}" VMWARE_PASSWORD: "{{ vcenter_password }}"
VMWARE_VALIDATE_CERTS: False VMWARE_VALIDATE_CERTS: False
- debug: var=clone_d1_c1_f0_env - debug: var=clone_d1_c1_f0_env

@ -2,48 +2,15 @@
# Copyright: (c) 2017, Abhijeet Kasurde <akasurde@redhat.com> # Copyright: (c) 2017, Abhijeet Kasurde <akasurde@redhat.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
#- name: Wait for Flask controller to come up online
# wait_for: #- set_fact: vm1="{{ vmlist['json'][0] }}"
# host: "{{ vcsim }}"
# port: 5000
# state: started
#
#- name: kill vcsim
# uri:
# url: http://{{ vcsim }}:5000/killall
#- name: start vcsim with no folders
# uri:
# url: http://{{ vcsim }}:5000/spawn?datacenter=1&cluster=1&folder=0
# register: vcsim_instance
#
#- name: Wait for Flask controller to come up online
# wait_for:
# host: "{{ vcsim }}"
# port: 443
# state: started
#
#- debug: var=vcsim_instance
#
#- name: get a list of Datacenter from vcsim
# uri:
# url: http://{{ vcsim }}:5000/govc_find?filter=DC
# register: datacenters
#
#- set_fact: dc1="{{ datacenters['json'][0] }}"
#
#- name: get a list of virtual machines from vcsim
# uri:
# url: http://{{ vcsim }}:5000/govc_find?filter=VM
# register: vms
#
#- set_fact: vm1="{{ vms['json'][0] }}"
# #
#- name: create new virtual machine with invalid guest id #- name: create new virtual machine with invalid guest id
# vmware_guest: # vmware_guest:
# validate_certs: False # validate_certs: False
# hostname: "{{ vcsim }}" # hostname: "{{ vcenter_hostname }}"
# username: "{{ vcsim_instance['json']['username'] }}" # username: "{{ vcenter_username }}"
# password: "{{ vcsim_instance['json']['password'] }}" # password: "{{ vcenter_password }}"
# name: "{{ 'invalid_vm_' + vm1 | basename }}" # name: "{{ 'invalid_vm_' + vm1 | basename }}"
# guest_id: "invalid_guest_id" # guest_id: "invalid_guest_id"
# datacenter: "{{ (vm1|basename).split('_')[0] }}" # datacenter: "{{ (vm1|basename).split('_')[0] }}"

@ -2,43 +2,15 @@
# Copyright: (c) 2017, Abhijeet Kasurde <akasurde@redhat.com> # Copyright: (c) 2017, Abhijeet Kasurde <akasurde@redhat.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
- name: Wait for Flask controller to come up online
wait_for:
host: "{{ vcsim }}"
port: 5000
state: started
- name: kill vcsim
uri:
url: http://{{ vcsim }}:5000/killall
- name: start vcsim with no folders
uri:
url: http://{{ vcsim }}:5000/spawn?datacenter=1&cluster=1&folder=0
register: vcsim_instance
- name: Wait for Flask controller to come up online
wait_for:
host: "{{ vcsim }}"
port: 443
state: started
- name: get a list of VMS from vcsim
uri:
url: http://{{ vcsim }}:5000/govc_find?filter=VM
register: vmlist
- debug: var=vcsim_instance
- debug: var=vmlist
- name: create new VMs - name: create new VMs
vmware_guest: vmware_guest:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
name: "{{ 'newvmnw_' + item|basename }}" name: newvmnw_4
guest_id: centos64Guest guest_id: centos64Guest
datacenter: "{{ (item|basename).split('_')[0] }}" datacenter: "{{ dc1 }}"
hardware: hardware:
num_cpus: 4 num_cpus: 4
memory_mb: 512 memory_mb: 512
@ -55,8 +27,7 @@
start_connected: True start_connected: True
allow_guest_control: True allow_guest_control: True
state: poweredoff state: poweredoff
folder: "{{ item|dirname }}" folder: F0
with_items: "{{ vmlist['json'] }}"
register: clone_d1_c1_f0 register: clone_d1_c1_f0
- debug: var=clone_d1_c1_f0 - debug: var=clone_d1_c1_f0
@ -64,4 +35,4 @@
- name: assert that changes were made - name: assert that changes were made
assert: assert:
that: that:
- "clone_d1_c1_f0.results|map(attribute='changed')|unique|list == [true]" - clone_d1_c1_f0 is changed

@ -1,60 +1,14 @@
- name: Wait for Flask controller to come up online
wait_for:
host: "{{ vcsim }}"
port: 5000
state: started
- name: kill vcsim
uri:
url: http://{{ vcsim }}:5000/killall
- name: start vcsim with no folders
uri:
url: http://{{ vcsim }}:5000/spawn?datacenter=1&cluster=2&pool=2&folder=0
register: vcsim_instance
- name: Wait for Flask controller to come up online
wait_for:
host: "{{ vcsim }}"
port: 443
state: started
- name: get a list of VMS from vcsim
uri:
url: http://{{ vcsim }}:5000/govc_find?filter=VM
register: vmlist
- name: get a list of clusters from vcsim
uri:
url: http://{{ vcsim }}:5000/govc_find?filter=CCR
register: clusts
- name: get a list of resource pools from vcsim
uri:
url: http://{{ vcsim }}:5000/govc_find?filter=RP
register: res_pools
- name: get a list of hosts from vcsim
uri:
url: http://{{ vcsim }}:5000/govc_find?filter=H
register: hosts
- debug: var=vcsim_instance
- debug: var=vmlist
- debug: var=res_pools
- debug: var=clusts
- debug: var=hosts
# Create one with the defaults # Create one with the defaults
- name: create new VM with default resource pool - name: create new VM with default resource pool
vmware_guest: vmware_guest:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
name: "{{ 'newvm_' + item|basename }}" name: newvm_2
#template: "{{ item|basename }}" #template: "{{ item|basename }}"
guest_id: centos64Guest guest_id: centos64Guest
datacenter: "{{ (item|basename).split('_')[0] }}" datacenter: "{{ dc1 }}"
hardware: hardware:
num_cpus: 1 num_cpus: 1
memory_mb: 512 memory_mb: 512
@ -63,8 +17,7 @@
type: thin type: thin
autoselect_datastore: True autoselect_datastore: True
state: poweredoff state: poweredoff
folder: "{{ item|dirname }}" folder: F0
with_items: "{{ vmlist['json'][0] }}"
register: clone_rp_d1_c1_f0 register: clone_rp_d1_c1_f0
- debug: var=clone_rp_d1_c1_f0 - debug: var=clone_rp_d1_c1_f0
@ -72,21 +25,20 @@
- name: assert that changes were made - name: assert that changes were made
assert: assert:
that: that:
- "clone_rp_d1_c1_f0.results|map(attribute='changed')|unique|list == [true]" - clone_rp_d1_c1_f0 is changed
- name: delete the new VMs - name: delete the new VMs
vmware_guest: vmware_guest:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
name: "{{ 'newvm_' + item|basename }}" name: newvm_2
#template: "{{ item|basename }}" #template: "{{ item|basename }}"
#guest_id: centos64Guest #guest_id: centos64Guest
datacenter: "{{ (item|basename).split('_')[0] }}" datacenter: "{{ dc1 }}"
state: absent state: absent
folder: "{{ item|dirname }}" folder: F0
with_items: "{{ vmlist['json'][0] }}"
register: clone_rp_d1_c1_f0_delete register: clone_rp_d1_c1_f0_delete
- debug: var=clone_rp_d1_c1_f0_delete - debug: var=clone_rp_d1_c1_f0_delete
@ -94,20 +46,20 @@
- name: assert that changes were made with deletion - name: assert that changes were made with deletion
assert: assert:
that: that:
- "clone_rp_d1_c1_f0_delete.results|map(attribute='changed')|unique|list == [true]" - clone_rp_d1_c1_f0_delete is changed
# now create with just a cluster # now create with just a cluster
- name: create new VM with default resource pool in cluster - name: create new VM with default resource pool in cluster
vmware_guest: vmware_guest:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
name: "{{ 'newvm_' + item|basename }}" name: newvm_2
#template: "{{ item|basename }}" #template: "{{ item|basename }}"
guest_id: centos64Guest guest_id: centos64Guest
datacenter: "{{ (item|basename).split('_')[0] }}" datacenter: "{{ dc1 }}"
cluster: "{{ clusts['json'][0]|basename }}" cluster: "{{ ccr1 }}"
hardware: hardware:
num_cpus: 1 num_cpus: 1
memory_mb: 512 memory_mb: 512
@ -116,8 +68,7 @@
type: thin type: thin
autoselect_datastore: True autoselect_datastore: True
state: poweredoff state: poweredoff
folder: "{{ item|dirname }}" folder: F0
with_items: "{{ vmlist['json'][0] }}"
register: clone_rpc_d1_c1_f0 register: clone_rpc_d1_c1_f0
- debug: var=clone_rpc_d1_c1_f0 - debug: var=clone_rpc_d1_c1_f0
@ -125,22 +76,21 @@
- name: assert that changes were made - name: assert that changes were made
assert: assert:
that: that:
- "clone_rpc_d1_c1_f0.results|map(attribute='changed')|unique|list == [true]" - clone_rpc_d1_c1_f0 is changed
- name: delete the new VMs - name: delete the new VMs
vmware_guest: vmware_guest:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
name: "{{ 'newvm_' + item|basename }}" name: newvm_2
#template: "{{ item|basename }}" #template: "{{ item|basename }}"
#guest_id: centos64Guest #guest_id: centos64Guest
datacenter: "{{ (item|basename).split('_')[0] }}" datacenter: "{{ dc1 }}"
cluster: "{{ clusts['json'][0]|basename }}" cluster: "{{ ccr1 }}"
state: absent state: absent
folder: "{{ item|dirname }}" folder: F0
with_items: "{{ vmlist['json'][0] }}"
register: clone_rpc_d1_c1_f0_delete register: clone_rpc_d1_c1_f0_delete
- debug: var=clone_rpc_d1_c1_f0_delete - debug: var=clone_rpc_d1_c1_f0_delete
@ -148,21 +98,21 @@
- name: assert that changes were made with deletion - name: assert that changes were made with deletion
assert: assert:
that: that:
- "clone_rpc_d1_c1_f0_delete.results|map(attribute='changed')|unique|list == [true]" - clone_rpc_d1_c1_f0_delete is changed
# now create with a specific resource pool # now create with a specific resource pool
- name: create new VM with specific resource pool in cluster - name: create new VM with specific resource pool in cluster
vmware_guest: vmware_guest:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
name: "{{ 'newvm_' + item|basename }}" name: newvm_2
#template: "{{ item|basename }}" #template: "{{ item|basename }}"
guest_id: centos64Guest guest_id: centos64Guest
datacenter: "{{ (item|basename).split('_')[0] }}" datacenter: "{{ dc1 }}"
cluster: "{{ clusts['json'][0]|basename }}" cluster: "{{ ccr1 }}"
resource_pool: "{{ res_pools['json'][2]|basename }}" resource_pool: DC0_C0_RP1
hardware: hardware:
num_cpus: 1 num_cpus: 1
memory_mb: 512 memory_mb: 512
@ -171,8 +121,7 @@
type: thin type: thin
autoselect_datastore: True autoselect_datastore: True
state: poweredoff state: poweredoff
folder: "{{ item|dirname }}" folder: F0
with_items: "{{ vmlist['json'][0] }}"
register: clone_rpcp_d1_c1_f0 register: clone_rpcp_d1_c1_f0
- debug: var=clone_rpcp_d1_c1_f0 - debug: var=clone_rpcp_d1_c1_f0
@ -180,22 +129,21 @@
- name: assert that changes were made - name: assert that changes were made
assert: assert:
that: that:
- "clone_rpcp_d1_c1_f0.results|map(attribute='changed')|unique|list == [true]" - clone_rpcp_d1_c1_f0 is changed
- name: delete the new VMs - name: delete the new VMs
vmware_guest: vmware_guest:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
name: "{{ 'newvm_' + item|basename }}" name: newvm_2
#template: "{{ item|basename }}" #template: "{{ item|basename }}"
#guest_id: centos64Guest #guest_id: centos64Guest
datacenter: "{{ (item|basename).split('_')[0] }}" datacenter: "{{ dc1 }}"
cluster: "{{ clusts['json'][0]|basename }}" cluster: "{{ ccr1 }}"
state: absent state: absent
folder: "{{ item|dirname }}" folder: F0
with_items: "{{ vmlist['json'][0] }}"
register: clone_rpcp_d1_c1_f0_delete register: clone_rpcp_d1_c1_f0_delete
- debug: var=clone_rpcp_d1_c1_f0_delete - debug: var=clone_rpcp_d1_c1_f0_delete
@ -203,20 +151,20 @@
- name: assert that changes were made with deletion - name: assert that changes were made with deletion
assert: assert:
that: that:
- "clone_rpcp_d1_c1_f0_delete.results|map(attribute='changed')|unique|list == [true]" - clone_rpcp_d1_c1_f0_delete is changed
# now create with a specific host # now create with a specific host
- name: create new VM with specific host - name: create new VM with specific host
vmware_guest: vmware_guest:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
name: "{{ 'newvm_' + item|basename }}" name: newvm_2
#template: "{{ item|basename }}" #template: "{{ item|basename }}"
guest_id: centos64Guest guest_id: centos64Guest
datacenter: "{{ (item|basename).split('_')[0] }}" datacenter: "{{ dc1 }}"
esxi_hostname: "{{ hosts['json'][0]|basename }}" esxi_hostname: '{{ hostvars[esxi1].ansible_host }}'
hardware: hardware:
num_cpus: 1 num_cpus: 1
memory_mb: 512 memory_mb: 512
@ -225,8 +173,7 @@
type: thin type: thin
autoselect_datastore: True autoselect_datastore: True
state: poweredoff state: poweredoff
folder: "{{ item|dirname }}" folder: F0
with_items: "{{ vmlist['json'][0] }}"
register: clone_rph_d1_c1_f0 register: clone_rph_d1_c1_f0
- debug: var=clone_rph_d1_c1_f0 - debug: var=clone_rph_d1_c1_f0
@ -234,21 +181,20 @@
- name: assert that changes were made - name: assert that changes were made
assert: assert:
that: that:
- "clone_rph_d1_c1_f0.results|map(attribute='changed')|unique|list == [true]" - clone_rph_d1_c1_f0 is changed
- name: delete the new VMs - name: delete the new VMs
vmware_guest: vmware_guest:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
name: "{{ 'newvm_' + item|basename }}" name: newvm_2
#template: "{{ item|basename }}" #template: "{{ item|basename }}"
#guest_id: centos64Guest #guest_id: centos64Guest
datacenter: "{{ (item|basename).split('_')[0] }}" datacenter: "{{ dc1 }}"
state: absent state: absent
folder: "{{ item|dirname }}" folder: F0
with_items: "{{ vmlist['json'][0] }}"
register: clone_rph_d1_c1_f0_delete register: clone_rph_d1_c1_f0_delete
- debug: var=clone_rph_d1_c1_f0_delete - debug: var=clone_rph_d1_c1_f0_delete
@ -256,4 +202,4 @@
- name: assert that changes were made with deletion - name: assert that changes were made with deletion
assert: assert:
that: that:
- "clone_rph_d1_c1_f0_delete.results|map(attribute='changed')|unique|list == [true]" - clone_rph_d1_c1_f0_delete is changed

@ -2,75 +2,14 @@
# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com> # Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
- name: Wait for Flask controller to come up online
wait_for:
host: "{{ vcsim }}"
port: 5000
state: started
- name: kill vcsim
uri:
url: http://{{ vcsim }}:5000/killall
- name: start vcsim with no folders
uri:
url: http://{{ vcsim }}:5000/spawn?datacenter=1&cluster=1&folder=0
register: vcsim_instance
- name: Wait for Flask controller to come up online
wait_for:
host: "{{ vcsim }}"
port: 443
state: started
- name: get a list of VMS from vcsim
uri:
url: http://{{ vcsim }}:5000/govc_find?filter=VM
register: vmlist
- debug: var=vcsim_instance
- debug: var=vmlist
- name: get a guest
set_fact:
guest1: "{{ vmlist.json[0] | basename }}"
- vmware_vm_facts:
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance['json']['username'] }}"
password: "{{ vcsim_instance['json']['password'] }}"
validate_certs: no
register: vm_details
- name: store the vcenter container ip
set_fact:
vm_powerstate: "{{ item.power_state }}"
with_items:
- "{{ vm_details.virtual_machines| json_query(query) }}"
vars:
query: "[?guest_name == '{{ guest1 }}' ]"
- debug: var=vm_powerstate
- vmware_guest:
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance['json']['username'] }}"
password: "{{ vcsim_instance['json']['password'] }}"
validate_certs: no
name: "{{ guest1 }}"
state: poweredon
when: "vm_powerstate != 'poweredOn'"
register: vmware_guest_poweron_state
- debug: var=vmware_guest_poweron_state
- name: Delete VM - name: Delete VM
vmware_guest: vmware_guest:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
name: "{{ guest1 }}" name: nothinghere
datacenter: "{{ guest1.split('_')[0] }}" datacenter: "{{ dc1 }}"
state: absent state: absent
register: delete_vm register: delete_vm
ignore_errors: yes ignore_errors: yes
@ -81,4 +20,3 @@
assert: assert:
that: that:
- "not delete_vm.changed" - "not delete_vm.changed"
- "delete_vm.msg"

@ -2,43 +2,15 @@
# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com> # Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
- name: Wait for Flask controller to come up online
wait_for:
host: "{{ vcsim }}"
port: 5000
state: started
- name: kill vcsim
uri:
url: http://{{ vcsim }}:5000/killall
- name: start vcsim with no folders
uri:
url: http://{{ vcsim }}:5000/spawn?datacenter=1&cluster=1&folder=0
register: vcsim_instance
- name: Wait for Flask controller to come up online
wait_for:
host: "{{ vcsim }}"
port: 443
state: started
- name: get a list of VMS from vcsim
uri:
url: http://{{ vcsim }}:5000/govc_find?filter=VM
register: vmlist
- debug: var=vcsim_instance
- debug: var=vmlist
- name: create new VMs with invalid disk mode - name: create new VMs with invalid disk mode
vmware_guest: vmware_guest:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
name: "{{ 'newvm_' + item|basename }}" name: disk_mode_d1_c1_f0
guest_id: centos64Guest guest_id: centos64Guest
datacenter: "{{ (item|basename).split('_')[0] }}" datacenter: "{{ dc1 }}"
hardware: hardware:
num_cpus: 1 num_cpus: 1
memory_mb: 512 memory_mb: 512
@ -48,8 +20,7 @@
autoselect_datastore: True autoselect_datastore: True
disk_mode: 'invalid_disk_mode' disk_mode: 'invalid_disk_mode'
state: poweredoff state: poweredoff
folder: "{{ item|dirname }}" folder: "{{ f0 }}"
with_items: "{{ vmlist['json'] }}"
register: disk_mode_d1_c1_f0 register: disk_mode_d1_c1_f0
ignore_errors: True ignore_errors: True
@ -58,17 +29,17 @@
- name: assert that changes were not made - name: assert that changes were not made
assert: assert:
that: that:
- "disk_mode_d1_c1_f0.results|map(attribute='changed')|unique|list == [false]" - not(disk_mode_d1_c1_f0 is changed)
- name: create new VMs with valid disk mode - name: create new VMs with valid disk mode
vmware_guest: vmware_guest:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
name: "{{ 'newvm_' + item|basename }}" name: disk_mode_d1_c1_f0
guest_id: centos64Guest guest_id: centos64Guest
datacenter: "{{ (item|basename).split('_')[0] }}" datacenter: "{{ dc1 }}"
hardware: hardware:
num_cpus: 1 num_cpus: 1
memory_mb: 512 memory_mb: 512
@ -78,8 +49,7 @@
autoselect_datastore: True autoselect_datastore: True
disk_mode: 'independent_persistent' disk_mode: 'independent_persistent'
state: poweredoff state: poweredoff
folder: "{{ item|dirname }}" folder: "{{ f0 }}"
with_items: "{{ vmlist['json'] }}"
register: disk_mode_d1_c1_f0_2 register: disk_mode_d1_c1_f0_2
- debug: var=disk_mode_d1_c1_f0_2 - debug: var=disk_mode_d1_c1_f0_2
@ -87,34 +57,33 @@
- name: assert that changes were made - name: assert that changes were made
assert: assert:
that: that:
- "disk_mode_d1_c1_f0_2.results|map(attribute='changed')|unique|list == [true]" - disk_mode_d1_c1_f0_2 is changed
# TODO: vcsim does not support reconfiguration of disk mode, fails with types.InvalidDeviceSpec
#- name: create new VMs with valid disk mode again
# vmware_guest:
# validate_certs: False
# hostname: "{{ vcsim }}"
# username: "{{ vcsim_instance['json']['username'] }}"
# password: "{{ vcsim_instance['json']['password'] }}"
# name: "{{ 'newvm_' + item|basename }}"
# guest_id: centos64Guest
# datacenter: "{{ (item|basename).split('_')[0] }}"
# hardware:
# num_cpus: 1
# memory_mb: 512
# disk:
# - size: 1gb
# type: eagerzeroedthick
# autoselect_datastore: True
# disk_mode: 'independent_persistent'
# state: poweredoff
# folder: "{{ item|dirname }}"
# with_items: "{{ vmlist['json'] }}"
# register: disk_mode_d1_c1_f0_2
#- debug: var=disk_mode_d1_c1_f0_2
#- name: assert that changes were not made #TODO: vcsim does not support reconfiguration of disk mode, fails with types.InvalidDeviceSpec
# assert: - when: vcsim is not defined
# that: block:
# - "disk_mode_d1_c1_f0_2.results|map(attribute='changed')|unique|list == [false]" - name: create new VMs with valid disk mode again
vmware_guest:
validate_certs: False
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
name: disk_mode_d1_c1_f0
guest_id: centos64Guest
datacenter: "{{ (item|basename).split('_')[0] }}"
hardware:
num_cpus: 1
memory_mb: 512
disk:
- size: 1gb
type: eagerzeroedthick
autoselect_datastore: True
disk_mode: 'independent_persistent'
state: poweredoff
folder: "{{ f0 }}"
register: disk_mode_d1_c1_f0_2
- debug: var=disk_mode_d1_c1_f0_2
- name: assert that changes were not made
assert:
that:
- not (disk_mode_d1_c1_f0_2 is changed)

@ -2,43 +2,15 @@
# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com> # Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
- name: Wait for Flask controller to come up online
wait_for:
host: "{{ vcsim }}"
port: 5000
state: started
- name: kill vcsim
uri:
url: http://{{ vcsim }}:5000/killall
- name: start vcsim with no folders
uri:
url: http://{{ vcsim }}:5000/spawn?datacenter=1&cluster=1&folder=0
register: vcsim_instance
- name: Wait for Flask controller to come up online
wait_for:
host: "{{ vcsim }}"
port: 443
state: started
- name: get a list of VMS from vcsim
uri:
url: http://{{ vcsim }}:5000/govc_find?filter=VM
register: vmlist
- debug: var=vcsim_instance
- debug: var=vmlist
- name: create new VMs with invalid disk size - name: create new VMs with invalid disk size
vmware_guest: vmware_guest:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
name: "{{ 'newvm_' + item|basename }}" name: newvm_6
guest_id: centos64Guest guest_id: centos64Guest
datacenter: "{{ (item|basename).split('_')[0] }}" datacenter: "{{ dc1 }}"
hardware: hardware:
num_cpus: 1 num_cpus: 1
memory_mb: 512 memory_mb: 512
@ -47,8 +19,7 @@
type: eagerzeroedthick type: eagerzeroedthick
autoselect_datastore: True autoselect_datastore: True
state: poweredoff state: poweredoff
folder: "{{ item|dirname }}" folder: "{{ f0 }}"
with_items: "{{ vmlist['json'] }}"
register: disk_size_d1_c1_f0 register: disk_size_d1_c1_f0
ignore_errors: True ignore_errors: True
@ -57,4 +28,4 @@
- name: assert that changes were made - name: assert that changes were made
assert: assert:
that: that:
- "disk_size_d1_c1_f0.results|map(attribute='changed')|unique|list == [false]" - not (disk_size_d1_c1_f0 is changed)

@ -2,43 +2,15 @@
# Copyright: (c) 2017, Abhijeet Kasurde <akasurde@redhat.com> # Copyright: (c) 2017, Abhijeet Kasurde <akasurde@redhat.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
- name: Wait for Flask controller to come up online
wait_for:
host: "{{ vcsim }}"
port: 5000
state: started
- name: kill vcsim
uri:
url: http://{{ vcsim }}:5000/killall
- name: start vcsim with no folders
uri:
url: http://{{ vcsim }}:5000/spawn?datacenter=1&cluster=1&folder=0
register: vcsim_instance
- name: Wait for Flask controller to come up online
wait_for:
host: "{{ vcsim }}"
port: 443
state: started
- name: get a list of VMS from vcsim
uri:
url: http://{{ vcsim }}:5000/govc_find?filter=VM
register: vmlist
- debug: var=vcsim_instance
- debug: var=vmlist
- name: create new VMs - name: create new VMs
vmware_guest: vmware_guest:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
name: "{{ 'newvm_' + item|basename }}" name: newvm_3
guest_id: centos64Guest guest_id: centos64Guest
datacenter: "{{ (item|basename).split('_')[0] }}" datacenter: "{{ dc1 }}"
hardware: hardware:
num_cpus: 1 num_cpus: 1
memory_mb: 512 memory_mb: 512
@ -50,8 +22,7 @@
type: thin type: thin
autoselect_datastore: True autoselect_datastore: True
state: poweredoff state: poweredoff
folder: "{{ item|dirname }}" folder: F0
with_items: "{{ vmlist['json'] }}"
register: disk_type_d1_c1_f0 register: disk_type_d1_c1_f0
- debug: var=disk_type_d1_c1_f0 - debug: var=disk_type_d1_c1_f0
@ -59,4 +30,4 @@
- name: assert that changes were made - name: assert that changes were made
assert: assert:
that: that:
- "disk_type_d1_c1_f0.results|map(attribute='changed')|unique|list == [true]" - disk_type_d1_c1_f0 is changed

@ -2,37 +2,15 @@
# Copyright: (c) 2017, Abhijeet Kasurde <akasurde@redhat.com> # Copyright: (c) 2017, Abhijeet Kasurde <akasurde@redhat.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
- name: Wait for Flask controller to come up online
wait_for:
host: "{{ vcsim }}"
port: 5000
state: started
- name: kill vcsim
uri:
url: http://{{ vcsim }}:5000/killall
- name: start vcsim with no folders
uri:
url: http://{{ vcsim }}:5000/spawn?datacenter=1&cluster=1&folder=0
register: vcsim_instance
- name: Wait for Flask controller to come up online
wait_for:
host: "{{ vcsim }}"
port: 443
state: started
- debug: var=vcsim_instance
- name: create new VMs with manual MAC address - name: create new VMs with manual MAC address
vmware_guest: vmware_guest:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
name: "{{ item | basename }}" name: DC0_H0_VM12
guest_id: centos64Guest guest_id: centos64Guest
datacenter: "{{ (item|basename).split('_')[0] }}" datacenter: "{{ dc1 }}"
hardware: hardware:
num_cpus: 1 num_cpus: 1
memory_mb: 512 memory_mb: 512
@ -47,9 +25,7 @@
gateway: 192.168.10.254 gateway: 192.168.10.254
mac: aa:bb:cc:dd:aa:42 mac: aa:bb:cc:dd:aa:42
state: poweredoff state: poweredoff
folder: "{{ item | dirname }}" folder: vm
with_items:
- "/DC0/vm/DC0_H0_VM12"
register: clone_d1_c1_f0 register: clone_d1_c1_f0
- debug: var=clone_d1_c1_f0 - debug: var=clone_d1_c1_f0
@ -57,5 +33,5 @@
- name: assert that changes were made - name: assert that changes were made
assert: assert:
that: that:
- "clone_d1_c1_f0.results[0]['instance']['hw_eth0']['addresstype'] == 'manual'" - "clone_d1_c1_f0['instance']['hw_eth0']['addresstype'] == 'manual'"
- "clone_d1_c1_f0.results[0]['instance']['hw_eth0']['macaddress'] == 'aa:bb:cc:dd:aa:42'" - "clone_d1_c1_f0['instance']['hw_eth0']['macaddress'] == 'aa:bb:cc:dd:aa:42'"

@ -2,6 +2,14 @@
# Copyright: (c) 2017, James Tanner <tanner.jc@gmail.com> # Copyright: (c) 2017, James Tanner <tanner.jc@gmail.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
- import_role:
name: prepare_vmware_tests
vars:
setup_attach_host: true
setup_datastore: true
setup_virtualmachines: true
- include: poweroff_d1_c1_f0.yml - include: poweroff_d1_c1_f0.yml
- include: poweroff_d1_c1_f1.yml - include: poweroff_d1_c1_f1.yml
- include: check_mode.yml - include: check_mode.yml
@ -15,6 +23,14 @@
- include: create_nw_d1_c1_f0.yml - include: create_nw_d1_c1_f0.yml
- include: delete_vm.yml - include: delete_vm.yml
- include: non_existent_vm_ops.yml - include: non_existent_vm_ops.yml
- import_role:
name: prepare_vmware_tests
vars:
setup_attach_host: true
setup_datastore: true
setup_virtualmachines: true
- include: network_negative_test.yml - include: network_negative_test.yml
# VCSIM does not return list of portgroups for dvswitch so commenting following TC # VCSIM does not return list of portgroups for dvswitch so commenting following TC
#- include: network_with_portgroup.yml #- include: network_with_portgroup.yml

@ -2,49 +2,17 @@
# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com> # Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
- name: Wait for Flask controller to come up online - debug: var=f0
wait_for:
host: "{{ vcsim }}"
port: 5000
state: started
- name: kill vcsim
uri:
url: http://{{ vcsim }}:5000/killall
- name: start vcsim with no folders
uri:
url: http://{{ vcsim }}:5000/spawn?datacenter=1&cluster=1&folder=0
register: vcsim_instance
- name: Wait for Flask controller to come up online
wait_for:
host: "{{ vcsim }}"
port: 443
state: started
- name: get a list of VMS from vcsim
uri:
url: http://{{ vcsim }}:5000/govc_find?filter=VM
register: vmlist
- debug: var=vcsim_instance
- debug: var=vmlist
- set_fact:
vm1: "{{ vmlist['json'][0] }}"
- debug: var=vm1
- name: create new VMs with non-existent network - name: create new VMs with non-existent network
vmware_guest: vmware_guest:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
name: new_vm name: new_vm
guest_id: centos64Guest guest_id: centos64Guest
datacenter: "{{ (vm1 | basename).split('_')[0] }}" datacenter: "{{ dc1 }}"
disk: disk:
- size: 3mb - size: 3mb
type: thin type: thin
@ -55,7 +23,7 @@
num_cpus: 3 num_cpus: 3
memory_mb: 512 memory_mb: 512
state: poweredoff state: poweredoff
folder: "{{ vm1 | dirname }}" folder: "{{ f0 }}"
register: non_existent_network register: non_existent_network
ignore_errors: yes ignore_errors: yes
@ -64,18 +32,18 @@
- name: assert that no changes were not made - name: assert that no changes were not made
assert: assert:
that: that:
- "not non_existent_network.changed" - not (non_existent_network is changed)
- "\"Network 'Non existent VM' does not exist\" in non_existent_network.msg" - "'does not exist' in non_existent_network.msg"
- name: create new VMs with network and with only IP - name: create new VMs with network and with only IP
vmware_guest: vmware_guest:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
name: new_vm name: new_vm
guest_id: centos64Guest guest_id: centos64Guest
datacenter: "{{ (vm1 | basename).split('_')[0] }}" datacenter: "{{ dc1 }}"
disk: disk:
- size: 3mb - size: 3mb
type: thin type: thin
@ -88,7 +56,7 @@
num_cpus: 3 num_cpus: 3
memory_mb: 512 memory_mb: 512
state: poweredoff state: poweredoff
folder: "{{ vm1 | dirname }}" folder: "{{ f0 }}"
register: no_netmask register: no_netmask
ignore_errors: yes ignore_errors: yes
@ -103,12 +71,12 @@
- name: create new VMs with network and with only netmask - name: create new VMs with network and with only netmask
vmware_guest: vmware_guest:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
name: new_vm name: new_vm
guest_id: centos64Guest guest_id: centos64Guest
datacenter: "{{ (vm1 | basename).split('_')[0] }}" datacenter: "{{ dc1 }}"
disk: disk:
- size: 3mb - size: 3mb
type: thin type: thin
@ -121,7 +89,7 @@
num_cpus: 3 num_cpus: 3
memory_mb: 512 memory_mb: 512
state: poweredoff state: poweredoff
folder: "{{ vm1 | dirname }}" folder: "{{ f0 }}"
register: no_ip register: no_ip
ignore_errors: yes ignore_errors: yes
@ -136,12 +104,12 @@
- name: create new VMs with network and without network name - name: create new VMs with network and without network name
vmware_guest: vmware_guest:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
name: new_vm name: new_vm
guest_id: centos64Guest guest_id: centos64Guest
datacenter: "{{ (vm1 | basename).split('_')[0] }}" datacenter: "{{ dc1 }}"
disk: disk:
- size: 3mb - size: 3mb
type: thin type: thin
@ -154,7 +122,7 @@
num_cpus: 3 num_cpus: 3
memory_mb: 512 memory_mb: 512
state: poweredoff state: poweredoff
folder: "{{ vm1 | dirname }}" folder: "{{ f0 }}"
register: no_network_name register: no_network_name
ignore_errors: yes ignore_errors: yes
@ -169,12 +137,12 @@
- name: create new VMs with network and without network name - name: create new VMs with network and without network name
vmware_guest: vmware_guest:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
name: new_vm name: new_vm
guest_id: centos64Guest guest_id: centos64Guest
datacenter: "{{ (vm1 | basename).split('_')[0] }}" datacenter: "{{ dc1 }}"
disk: disk:
- size: 3mb - size: 3mb
type: thin type: thin
@ -187,7 +155,7 @@
num_cpus: 3 num_cpus: 3
memory_mb: 512 memory_mb: 512
state: poweredoff state: poweredoff
folder: "{{ vm1 | dirname }}" folder: "{{ f0 }}"
register: no_network register: no_network
ignore_errors: yes ignore_errors: yes
@ -202,12 +170,12 @@
- name: create new VMs with invalid device type - name: create new VMs with invalid device type
vmware_guest: vmware_guest:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
name: new_vm name: new_vm
guest_id: centos64Guest guest_id: centos64Guest
datacenter: "{{ (vm1 | basename).split('_')[0] }}" datacenter: "{{ dc1 }}"
disk: disk:
- size: 3mb - size: 3mb
type: thin type: thin
@ -221,7 +189,7 @@
num_cpus: 3 num_cpus: 3
memory_mb: 512 memory_mb: 512
state: poweredoff state: poweredoff
folder: "{{ vm1 | dirname }}" folder: "{{ f0 }}"
register: invalid_device_type register: invalid_device_type
ignore_errors: yes ignore_errors: yes
@ -236,12 +204,12 @@
- name: create new VMs with invalid device MAC address - name: create new VMs with invalid device MAC address
vmware_guest: vmware_guest:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
name: new_vm name: new_vm
guest_id: centos64Guest guest_id: centos64Guest
datacenter: "{{ (vm1 | basename).split('_')[0] }}" datacenter: "{{ dc1 }}"
disk: disk:
- size: 3mb - size: 3mb
type: thin type: thin
@ -256,7 +224,7 @@
num_cpus: 3 num_cpus: 3
memory_mb: 512 memory_mb: 512
state: poweredoff state: poweredoff
folder: "{{ vm1 | dirname }}" folder: "{{ f0 }}"
register: invalid_mac register: invalid_mac
ignore_errors: yes ignore_errors: yes
@ -271,12 +239,12 @@
- name: create new VMs with invalid network type - name: create new VMs with invalid network type
vmware_guest: vmware_guest:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
name: new_vm name: new_vm
guest_id: centos64Guest guest_id: centos64Guest
datacenter: "{{ (vm1 | basename).split('_')[0] }}" datacenter: "{{ dc1 }}"
disk: disk:
- size: 3mb - size: 3mb
type: thin type: thin
@ -292,7 +260,7 @@
num_cpus: 3 num_cpus: 3
memory_mb: 512 memory_mb: 512
state: poweredoff state: poweredoff
folder: "{{ vm1 | dirname }}" folder: "{{ f0 }}"
register: invalid_network_type register: invalid_network_type
ignore_errors: yes ignore_errors: yes
@ -307,12 +275,12 @@
- name: create new VMs with IP, netmask and network type as "DHCP" - name: create new VMs with IP, netmask and network type as "DHCP"
vmware_guest: vmware_guest:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
name: new_vm name: new_vm
guest_id: centos64Guest guest_id: centos64Guest
datacenter: "{{ (vm1 | basename).split('_')[0] }}" datacenter: "{{ dc1 }}"
disk: disk:
- size: 3mb - size: 3mb
type: thin type: thin
@ -328,7 +296,7 @@
num_cpus: 3 num_cpus: 3
memory_mb: 512 memory_mb: 512
state: poweredoff state: poweredoff
folder: "{{ vm1 | dirname }}" folder: "{{ f0 }}"
register: invalid_dhcp_network_type register: invalid_dhcp_network_type
ignore_errors: yes ignore_errors: yes
@ -343,12 +311,12 @@
- name: create new VMs with no network type which set network type as "DHCP" - name: create new VMs with no network type which set network type as "DHCP"
vmware_guest: vmware_guest:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
name: new_vm_no_nw_type name: new_vm_no_nw_type
guest_id: centos64Guest guest_id: centos64Guest
datacenter: "{{ (vm1 | basename).split('_')[0] }}" datacenter: "{{ dc1 }}"
disk: disk:
- size: 3mb - size: 3mb
type: thin type: thin
@ -359,7 +327,7 @@
num_cpus: 3 num_cpus: 3
memory_mb: 512 memory_mb: 512
state: poweredoff state: poweredoff
folder: "{{ vm1 | dirname }}" folder: "{{ f0 }}"
register: no_network_type register: no_network_type
ignore_errors: yes ignore_errors: yes

@ -3,53 +3,19 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# Testcase to check #38605 # Testcase to check #38605
- name: Wait for Flask controller to come up online
wait_for:
host: "{{ vcsim }}"
port: 5000
state: started
- name: kill vcsim
uri:
url: http://{{ vcsim }}:5000/killall
- name: start vcsim with no folders
uri:
url: http://{{ vcsim }}:5000/spawn?datacenter=1&cluster=1&folder=0
register: vcsim_instance
- name: Wait for Flask controller to come up online
wait_for:
host: "{{ vcsim }}"
port: 443
state: started
- name: get a list of VMS from vcsim
uri:
url: http://{{ vcsim }}:5000/govc_find?filter=VM
register: vmlist
- debug: var=vcsim_instance
- debug: var=vmlist
- set_fact:
vm1: "{{ vmlist['json'][0] }}"
- debug: var=vm1
- set_fact: - set_fact:
vm_name: "VM_{{ 10000 | random }}" vm_name: "VM_{{ 10000 | random }}"
- name: Deploy VM {{ vm1 | basename }} - name: Deploy VM first VM
vmware_guest: vmware_guest:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
validate_certs: False validate_certs: False
datacenter: "{{ (vm1|basename).split('_')[0] }}" datacenter: "{{ dc1 }}"
state: poweredon state: poweredon
folder: "{{ vm1 | dirname }}" folder: "{{ f0 }}"
name: "{{ vm_name }}" name: network_with_device
disk: disk:
- size: 10mb - size: 10mb
autoselect_datastore: yes autoselect_datastore: yes
@ -70,14 +36,14 @@
- name: Deploy VM {{ vm1 | basename }} again - name: Deploy VM {{ vm1 | basename }} again
vmware_guest: vmware_guest:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
validate_certs: False validate_certs: False
datacenter: "{{ (vm1|basename).split('_')[0] }}" datacenter: "{{ dc1 }}"
state: poweredon state: poweredon
folder: "{{ vm1 | dirname }}" folder: "{{ f0 }}"
name: "{{ vm_name }}" name: network_with_device
disk: disk:
- size: 10mb - size: 10mb
autoselect_datastore: yes autoselect_datastore: yes
@ -94,4 +60,4 @@
- assert: - assert:
that: that:
- "not vm_result_again.changed" - not (vm_result_again is changed)

@ -2,49 +2,12 @@
# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com> # Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
- name: Wait for Flask controller to come up online
wait_for:
host: "{{ vcsim }}"
port: 5000
state: started
- name: kill vcsim
uri:
url: http://{{ vcsim }}:5000/killall
- name: start vcsim with no folders
uri:
url: http://{{ vcsim }}:5000/spawn?datacenter=1&cluster=1&folder=0
register: vcsim_instance
- name: Wait for Flask controller to come up online
wait_for:
host: "{{ vcsim }}"
port: 443
state: started
- name: get a list of VMS from vcsim
uri:
url: http://{{ vcsim }}:5000/govc_find?filter=VM
register: vmlist
- debug: var=vcsim_instance
- debug: var=vmlist
- set_fact:
vm1: "{{ vmlist['json'][0] }}"
- debug: var=vm1
- set_fact:
vm_name: "VM_{{ 10000 | random }}"
# Clone from existing VM with DVPG # Clone from existing VM with DVPG
- name: Deploy VM from template {{ vm1 | basename }} - name: Deploy VM from template {{ vm1 | basename }}
vmware_guest: vmware_guest:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
validate_certs: no validate_certs: no
datacenter: "{{ (vm1|basename).split('_')[0] }}" datacenter: "{{ (vm1|basename).split('_')[0] }}"
state: poweredon state: poweredon
@ -76,9 +39,9 @@
- name: Deploy new VM with DVPG - name: Deploy new VM with DVPG
vmware_guest: vmware_guest:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
validate_certs: no validate_certs: no
datacenter: "{{ (vm1|basename).split('_')[0] }}" datacenter: "{{ (vm1|basename).split('_')[0] }}"
state: poweredon state: poweredon
@ -103,9 +66,9 @@
- name: Deploy same {{ vm_name }} VM again - name: Deploy same {{ vm_name }} VM again
vmware_guest: vmware_guest:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
validate_certs: no validate_certs: no
datacenter: "{{ (vm1|basename).split('_')[0] }}" datacenter: "{{ (vm1|basename).split('_')[0] }}"
state: poweredon state: poweredon

@ -2,47 +2,12 @@
# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>, Tim Steinbach <tim@nequissimus.com> # Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>, Tim Steinbach <tim@nequissimus.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
- name: Wait for Flask controller to come up online
wait_for:
host: "{{ vcsim }}"
port: 5000
state: started
- name: kill vcsim
uri:
url: http://{{ vcsim }}:5000/killall
- name: start vcsim with no folders
uri:
url: http://{{ vcsim }}:5000/spawn?datacenter=1&cluster=1&folder=0
register: vcsim_instance
- name: Wait for Flask controller to come up online
wait_for:
host: "{{ vcsim }}"
port: 443
state: started
- name: get a list of VMS from vcsim
uri:
url: http://{{ vcsim }}:5000/govc_find?filter=VM
register: vmlist
- debug: var=vcsim_instance
- debug: var=vmlist
- set_fact:
vm1: "{{ vmlist['json'][0] }}"
- debug: var=vm1
- name: Create dvswitch - name: Create dvswitch
vmware_dvswitch: vmware_dvswitch:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
datacenter_name: "{{ (vm1 | basename).split('_')[0] }}" datacenter_name: "{{ (vm1 | basename).split('_')[0] }}"
switch_name: dvSwitch switch_name: dvSwitch
uplink_quantity: 2 uplink_quantity: 2
@ -55,9 +20,9 @@
- name: Add portgroup - name: Add portgroup
vmware_dvs_portgroup: vmware_dvs_portgroup:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
portgroup_name: "portgroup_network" portgroup_name: "portgroup_network"
switch_name: "{{ dvswitch.switch_name }}" switch_name: "{{ dvswitch.switch_name }}"
vlan_id: "1" vlan_id: "1"
@ -69,9 +34,9 @@
- name: create new VMs with portgroup - name: create new VMs with portgroup
vmware_guest: vmware_guest:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
name: new_vm_pg name: new_vm_pg
guest_id: centos64Guest guest_id: centos64Guest
datacenter: "{{ (vm1 | basename).split('_')[0] }}" datacenter: "{{ (vm1 | basename).split('_')[0] }}"

@ -2,56 +2,22 @@
# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com> # Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
- name: Wait for Flask controller to come up online
wait_for:
host: "{{ vcsim }}"
port: 5000
state: started
- name: kill vcsim
uri:
url: http://{{ vcsim }}:5000/killall
- name: start vcsim with no folders
uri:
url: http://{{ vcsim }}:5000/spawn?datacenter=1&cluster=1&folder=0
register: vcsim_instance
- name: Wait for Flask controller to come up online
wait_for:
host: "{{ vcsim }}"
port: 443
state: started
- name: get a list of VMS from vcsim
uri:
url: http://{{ vcsim }}:5000/govc_find?filter=VM
register: vmlist
- debug: var=vcsim_instance
- debug: var=vmlist
- name: get a guest
set_fact:
guest1: "{{ vmlist.json[0] }}"
- name: Perform operation on non-existent VM - name: Perform operation on non-existent VM
vmware_guest: vmware_guest:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
name: "non_existent_vm" name: "non_existent_vm"
datacenter: "{{ (guest1|basename).split('_')[0] }}" datacenter: "{{ dc1 }}"
folder: "{{ guest1 | dirname }}" folder: "{{ f0 }}"
state: poweredoff state: poweredoff
register: non_existent_vm_ops register: non_existent_vm_ops
ignore_errors: yes ignore_errors: yes
- debug: var=non_existent_vm_ops - debug: var=non_existent_vm_ops
- name: assert that changes were not made - name: assert that changes were not made
assert: assert:
that: that:
- not non_existent_vm_ops.changed - not (non_existent_vm_ops is changed)
- non_existent_vm_ops.msg is defined - "'msg' in non_existent_vm_ops"
- "'Unable to find the datastore with given parameters' in non_existent_vm_ops.msg" - "'Unable to find the datastore with given parameters.' in non_existent_vm_ops.msg"

@ -2,51 +2,23 @@
# Copyright: (c) 2017, James Tanner <tanner.jc@gmail.com> # Copyright: (c) 2017, James Tanner <tanner.jc@gmail.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
- name: Wait for Flask controller to come up online
wait_for:
host: "{{ vcsim }}"
port: 5000
state: started
- name: kill vcsim
uri:
url: http://{{ vcsim }}:5000/killall
- name: start vcsim with no folders
uri:
url: http://{{ vcsim }}:5000/spawn?datacenter=1&cluster=1&folder=0
register: vcsim_instance
- name: Wait for Flask controller to come up online
wait_for:
host: "{{ vcsim }}"
port: 443
state: started
- name: get a list of VMS from vcsim
uri:
url: http://{{ vcsim }}:5000/govc_find?filter=VM
register: vmlist
- debug: var=vcsim_instance
- debug: var=vmlist
- name: set state to poweroff on all VMs - name: set state to poweroff on all VMs
vmware_guest: vmware_guest:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
name: "{{ item|basename }}" name: "{{ item }}"
datacenter: "{{ (item|basename).split('_')[0] }}"
state: poweredoff state: poweredoff
folder: "{{ item|dirname }}" with_items: "{{ infra.vm_list }}"
with_items: "{{ vmlist['json'] }}"
register: poweroff_d1_c1_f0 register: poweroff_d1_c1_f0
- debug: var=poweroff_d1_c1_f0 - debug:
var: poweroff_d1_c1_f0
# vcsim (v0.18.0) VMs are spawned PoweredOn # vcsim (v0.18.0) VMs are spawned PoweredOn
- name: make sure changes were made - name: make sure changes were made
assert: assert:
that: that:
- "poweroff_d1_c1_f0.results|map(attribute='changed')|unique|list == [True]" - "poweroff_d1_c1_f0.results[0].changed == true"
- "poweroff_d1_c1_f0.results[1].changed == true"

@ -2,34 +2,6 @@
# Copyright: (c) 2017, James Tanner <tanner.jc@gmail.com> # Copyright: (c) 2017, James Tanner <tanner.jc@gmail.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
- name: Wait for Flask controller to come up online
wait_for:
host: "{{ vcsim }}"
port: 5000
state: started
- name: kill vcsim
uri:
url: http://{{ vcsim }}:5000/killall
- name: start vcsim with folders
uri:
url: http://{{ vcsim }}:5000/spawn?datacenter=1&cluster=1&folder=1
register: vcsim_instance
- name: Wait for Flask controller to come up online
wait_for:
host: "{{ vcsim }}"
port: 443
state: started
- name: get a list of VMS from vcsim
uri:
url: http://{{ vcsim }}:5000/govc_find?filter=VM
register: vmlist
- debug: var=vcsim_instance
- debug: var=vmlist
# https://github.com/ansible/ansible/issues/25011 # https://github.com/ansible/ansible/issues/25011
# Sending "-folders 1" to vcsim nests the datacenter under # Sending "-folders 1" to vcsim nests the datacenter under
# the folder so that the path prefix is no longer /vm # the folder so that the path prefix is no longer /vm
@ -39,14 +11,13 @@
- name: set state to poweredoff on all VMs - name: set state to poweredoff on all VMs
vmware_guest: vmware_guest:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
name: "{{ item|basename }}" name: "{{ item }}"
datacenter: "{{ (item|basename).split('_')[0] }}"
state: poweredoff state: poweredoff
folder: "{{ item|dirname }}" folder: "DC1/C1/F1"
with_items: "{{ vmlist['json'] }}" with_items: "{{ infra.vm_list }}"
register: poweroff_d1_c1_f1 register: poweroff_d1_c1_f1
- debug: var=poweroff_d1_c1_f1 - debug: var=poweroff_d1_c1_f1
@ -55,4 +26,5 @@
- name: make sure changes were made - name: make sure changes were made
assert: assert:
that: that:
- "poweroff_d1_c1_f1.results|map(attribute='changed')|unique|list == [True]" - '"instance" in poweroff_d1_c1_f1.results[0]'
- '"instance" in poweroff_d1_c1_f1.results[1]'

@ -1,37 +1,9 @@
- name: Wait for Flask controller to come up online
wait_for:
host: "{{ vcsim }}"
port: 5000
state: started
- name: kill vcsim
uri:
url: "http://{{ vcsim }}:5000/killall"
- name: start vcsim with no folders
uri:
url: "http://{{ vcsim }}:5000/spawn?datacenter=1&cluster=1&folder=0"
register: vcsim_instance
- name: Wait for Flask controller to come up online
wait_for:
host: "{{ vcsim }}"
port: 443
state: started
- name: get a list of VMs from vcsim
uri:
url: "http://{{ vcsim }}:5000/govc_find?filter=VM"
register: vmlist
- debug: var=vcsim_instance
- debug: var=vmlist
- name: ensure that VMs are not flagged as templates - name: ensure that VMs are not flagged as templates
vmware_guest: vmware_guest:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
datacenter: "{{ (item|basename).split('_')[0] }}" datacenter: "{{ (item|basename).split('_')[0] }}"
folder: "{{ item|dirname }}" folder: "{{ item|dirname }}"
name: "{{ item|basename }}" name: "{{ item|basename }}"
@ -50,9 +22,9 @@
- name: convert all VMs to templates - name: convert all VMs to templates
vmware_guest: vmware_guest:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
datacenter: "{{ (item|basename).split('_')[0] }}" datacenter: "{{ (item|basename).split('_')[0] }}"
folder: "{{ item|dirname }}" folder: "{{ item|dirname }}"
name: "{{ item|basename }}" name: "{{ item|basename }}"
@ -71,9 +43,9 @@
- name: make double sure that all VMs are templates - name: make double sure that all VMs are templates
vmware_guest: vmware_guest:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
datacenter: "{{ (item|basename).split('_')[0] }}" datacenter: "{{ (item|basename).split('_')[0] }}"
folder: "{{ item|dirname }}" folder: "{{ item|dirname }}"
name: "{{ item|basename }}" name: "{{ item|basename }}"
@ -92,9 +64,9 @@
- name: convert all templates back to VMs - name: convert all templates back to VMs
vmware_guest: vmware_guest:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
datacenter: "{{ (item|basename).split('_')[0] }}" datacenter: "{{ (item|basename).split('_')[0] }}"
folder: "{{ item|dirname }}" folder: "{{ item|dirname }}"
name: "{{ item|basename }}" name: "{{ item|basename }}"

@ -1,41 +1,13 @@
- name: Wait for Flask controller to come up online
wait_for:
host: "{{ vcsim }}"
port: 5000
state: started
- name: kill vcsim
uri:
url: "{{ 'http://' + vcsim + ':5000/killall' }}"
- name: start vcsim with no folders
uri:
url: "{{ 'http://' + vcsim + ':5000/spawn?datacenter=1&cluster=1&folder=0' }}"
register: vcsim_instance
- name: Wait for Flask controller to come up online
wait_for:
host: "{{ vcsim }}"
port: 443
state: started
- name: get a list of Clusters from vcsim
uri:
url: "{{ 'http://' + vcsim + ':5000/govc_find?filter=CCR' }}"
register: clusterlist
- debug: var=vcsim_instance
- debug: var=clusterlist
- name: Create test VM - name: Create test VM
vmware_guest: vmware_guest:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
folder: "/{{ (clusterlist['json'][0]|basename).split('_')[0] }}/vm" folder: "vm"
name: vApp-Test name: vApp-Test
datacenter: "{{ (clusterlist['json'][0]|basename).split('_')[0] }}" datacenter: "{{ dc1 }}"
cluster: "{{ clusterlist['json'][0]|basename }}" cluster: "{{ ccr1 }}"
resource_pool: Resources resource_pool: Resources
guest_id: centos64Guest guest_id: centos64Guest
hardware: hardware:
@ -53,12 +25,12 @@
- name: Define vApp properties for the new VM - name: Define vApp properties for the new VM
vmware_guest: vmware_guest:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
folder: "/{{ (clusterlist['json'][0]|basename).split('_')[0] }}/vm" folder: "vm"
name: vApp-Test name: vApp-Test
datacenter: "{{ (clusterlist['json'][0]|basename).split('_')[0] }}" datacenter: "{{ dc1 }}"
vapp_properties: vapp_properties:
- id: prop_id1 - id: prop_id1
category: category category: category
@ -84,12 +56,12 @@
- name: Edit one vApp property and removing another - name: Edit one vApp property and removing another
vmware_guest: vmware_guest:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
folder: "/{{ (clusterlist['json'][0]|basename).split('_')[0] }}/vm" folder: "vm"
name: vApp-Test name: vApp-Test
datacenter: "{{ (clusterlist['json'][0]|basename).split('_')[0] }}" datacenter: "{{ dc1 }}"
vapp_properties: vapp_properties:
- id: prop_id1 - id: prop_id1
operation: remove operation: remove

@ -1,41 +1,13 @@
- name: Wait for Flask controller to come up online
wait_for:
host: "{{ vcsim }}"
port: 5000
state: started
- name: kill vcsim
uri:
url: "{{ 'http://' + vcsim + ':5000/killall' }}"
- name: start vcsim with no folders
uri:
url: "{{ 'http://' + vcsim + ':5000/spawn?datacenter=1&cluster=1&folder=0' }}"
register: vcsim_instance
- name: Wait for Flask controller to come up online
wait_for:
host: "{{ vcsim }}"
port: 443
state: started
- name: get a list of Clusters from vcsim
uri:
url: "{{ 'http://' + vcsim + ':5000/govc_find?filter=CCR' }}"
register: clusterlist
- debug: var=vcsim_instance
- debug: var=clusterlist
- name: Create Windows 10 VM with VBS enabled - name: Create Windows 10 VM with VBS enabled
vmware_guest: vmware_guest:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
folder: "/{{ (clusterlist['json'][0]|basename).split('_')[0] }}/vm" folder: "/{{ (clusters['json'][0]|basename).split('_')[0] }}/vm"
name: vbs-Test name: vbs-Test
datacenter: "{{ (clusterlist['json'][0]|basename).split('_')[0] }}" datacenter: "{{ (clusters['json'][0]|basename).split('_')[0] }}"
cluster: "{{ clusterlist['json'][0] }}" cluster: "{{ clusters['json'][0] }}"
resource_pool: Resources resource_pool: Resources
guest_id: windows9_64Guest guest_id: windows9_64Guest
hardware: hardware:
@ -64,13 +36,13 @@
- name: Create Windows Server 2016 VM without VBS enabled - name: Create Windows Server 2016 VM without VBS enabled
vmware_guest: vmware_guest:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
folder: "/{{ (clusterlist['json'][0]|basename).split('_')[0] }}/vm" folder: "/{{ (clusters['json'][0]|basename).split('_')[0] }}/vm"
name: vbs-Test2 name: vbs-Test2
datacenter: "{{ (clusterlist['json'][0]|basename).split('_')[0] }}" datacenter: "{{ (clusters['json'][0]|basename).split('_')[0] }}"
cluster: "{{ clusterlist['json'][0] }}" cluster: "{{ clusters['json'][0] }}"
resource_pool: Resources resource_pool: Resources
guest_id: windows9Server64Guest guest_id: windows9Server64Guest
hardware: hardware:
@ -98,12 +70,12 @@
- name: Enable VBS for Windows Server 2016 VM - name: Enable VBS for Windows Server 2016 VM
vmware_guest: vmware_guest:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
folder: "/{{ (clusterlist['json'][0]|basename).split('_')[0] }}/vm" folder: "/{{ (clusters['json'][0]|basename).split('_')[0] }}/vm"
name: vbs-Test2 name: vbs-Test2
datacenter: "{{ (clusterlist['json'][0]|basename).split('_')[0] }}" datacenter: "{{ (clusters['json'][0]|basename).split('_')[0] }}"
disk: disk:
- size_mb: 256 - size_mb: 256
type: thin type: thin

@ -1,2 +1,3 @@
cloud/vcenter cloud/vcenter
unsupported shippable/vcenter/group1
needs/target/prepare_vmware_tests

@ -2,75 +2,50 @@
# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com> # Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
- name: Wait for Flask controller to come up online - when: vcsim is not defined
wait_for: block:
host: "{{ vcsim }}" - import_role:
port: 5000 name: prepare_vmware_tests
state: started vars:
setup_attach_host: true
- name: kill vcsim setup_datastore: true
uri: setup_virtualmachines: true
url: http://{{ vcsim }}:5000/killall
- name: start vcsim with no folders - name: Gather facts about VM boot order
uri: vmware_guest_boot_facts:
url: http://{{ vcsim }}:5000/spawn?datacenter=1&cluster=1&folder=0 validate_certs: no
register: vcsim_instance hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
- name: Wait for Flask controller to come up online password: '{{ vcenter_password }}'
wait_for: name: "{{ infra.vm_list[0] }}"
host: "{{ vcsim }}" register: vm1_facts
port: 443 - debug: var=vm1_facts
state: started - name: assert that values are set
assert:
- name: get a list of VMS from vcsim that:
uri: - vm1_facts.vm_boot_facts.current_boot_delay is defined
url: http://{{ vcsim }}:5000/govc_find?filter=VM - vm1_facts.vm_boot_facts.current_boot_firmware is defined
register: vmlist - vm1_facts.vm_boot_facts.current_boot_order is defined
- vm1_facts.vm_boot_facts.current_boot_retry_delay is defined
- debug: var=vcsim_instance - vm1_facts.vm_boot_facts.current_boot_retry_enabled is defined
- debug: var=vmlist - vm1_facts.vm_boot_facts.current_enter_bios_setup is defined
- name: Gather facts about VM boot order - name: Gather facts about VM boot order in check mode
vmware_guest_boot_facts: vmware_guest_boot_facts:
validate_certs: no validate_certs: no
hostname: "{{ vcsim }}" hostname: '{{ vcenter_hostname }}'
username: "{{ vcsim_instance['json']['username'] }}" username: '{{ vcenter_username }}'
password: "{{ vcsim_instance['json']['password'] }}" password: '{{ vcenter_password }}'
name: "{{ item|basename }}" name: "{{ infra.vm_list[0] }}"
with_items: "{{ vmlist['json'] }}" check_mode: yes
register: boot_d1_c1_f0 register: vm1_facts
- debug: var=vm1_facts
- debug: var=boot_d1_c1_f0 - name: assert that values are set
assert:
- name: assert that changes were made that:
assert: - vm1_facts.vm_boot_facts.current_boot_delay is defined
that: - vm1_facts.vm_boot_facts.current_boot_firmware is defined
- boot_d1_c1_f0.results.vm_boot_facts.current_boot_delay is defined - vm1_facts.vm_boot_facts.current_boot_order is defined
- boot_d1_c1_f0.results.vm_boot_facts.current_boot_firmware is defined - vm1_facts.vm_boot_facts.current_boot_retry_delay is defined
- boot_d1_c1_f0.results.vm_boot_facts.current_boot_order is defined - vm1_facts.vm_boot_facts.current_boot_retry_enabled is defined
- boot_d1_c1_f0.results.vm_boot_facts.current_boot_retry_delay is defined - vm1_facts.vm_boot_facts.current_enter_bios_setup is defined
- boot_d1_c1_f0.results.vm_boot_facts.current_boot_retry_enabled is defined
- boot_d1_c1_f0.results.vm_boot_facts.current_enter_bios_setup is defined
- name: Gather facts about VM boot order in check mode
vmware_guest_boot_facts:
validate_certs: no
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance['json']['username'] }}"
password: "{{ vcsim_instance['json']['password'] }}"
name: "{{ item|basename }}"
with_items: "{{ vmlist['json'] }}"
check_mode: yes
register: boot_d1_c1_f0
- debug: var=boot_d1_c1_f0
- name: assert that changes were made
assert:
that:
- boot_d1_c1_f0.results.vm_boot_facts.current_boot_delay is defined
- boot_d1_c1_f0.results.vm_boot_facts.current_boot_firmware is defined
- boot_d1_c1_f0.results.vm_boot_facts.current_boot_order is defined
- boot_d1_c1_f0.results.vm_boot_facts.current_boot_retry_delay is defined
- boot_d1_c1_f0.results.vm_boot_facts.current_boot_retry_enabled is defined
- boot_d1_c1_f0.results.vm_boot_facts.current_enter_bios_setup is defined

@ -1,2 +1,3 @@
cloud/vcenter cloud/vcenter
unsupported shippable/vcenter/group1
needs/target/prepare_vmware_tests

@ -2,48 +2,27 @@
# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com> # Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
- name: Wait for Flask controller to come up online - import_role:
wait_for: name: prepare_vmware_tests
host: "{{ vcsim }}" vars:
port: 5000 setup_attach_host: true
state: started setup_datastore: true
setup_virtualmachines: true
- name: kill vcsim - name: remove attribute definition
uri:
url: http://{{ vcsim }}:5000/killall
- name: start vcsim
uri:
url: http://{{ vcsim }}:5000/spawn?datacenter=1&cluster=1&folder=0
register: vcsim_instance
- name: Wait for vcsim server to come up online
wait_for:
host: "{{ vcsim }}"
port: 443
state: started
- name: list custom attributes
vmware_guest_custom_attribute_defs: vmware_guest_custom_attribute_defs:
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance['json']['username'] }}"
password: "{{ vcsim_instance['json']['password'] }}"
validate_certs: False validate_certs: False
state: list hostname: "{{ vcenter_hostname }}"
register: list_attrib_def username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
- debug: var=list_attrib_def state: absent
attribute_key: sample_5
- assert:
that:
- "not list_attrib_def.changed"
- name: add custom attribute definition - name: add custom attribute definition
vmware_guest_custom_attribute_defs: vmware_guest_custom_attribute_defs:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
state: present state: present
attribute_key: sample_5 attribute_key: sample_5
register: add_attrib_def register: add_attrib_def
@ -52,30 +31,15 @@
- assert: - assert:
that: that:
- "add_attrib_def.changed" - add_attrib_def is changed
- "'sample_5' in add_attrib_def.instance" - "'sample_5' in add_attrib_def.custom_attribute_defs"
- name: list custom attributes
vmware_guest_custom_attribute_defs:
validate_certs: False
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance['json']['username'] }}"
password: "{{ vcsim_instance['json']['password'] }}"
state: list
register: list_attrib_def
- debug: var=list_attrib_def
- assert:
that:
- "not list_attrib_def.changed"
- name: add attribute definition again - name: add attribute definition again
vmware_guest_custom_attribute_defs: vmware_guest_custom_attribute_defs:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
state: present state: present
attribute_key: sample_5 attribute_key: sample_5
register: add_attrib_def register: add_attrib_def
@ -84,29 +48,14 @@
- assert: - assert:
that: that:
- "not add_attrib_def.changed" - not (add_attrib_def is changed)
- name: list attribute definition
vmware_guest_custom_attribute_defs:
validate_certs: False
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance['json']['username'] }}"
password: "{{ vcsim_instance['json']['password'] }}"
state: list
register: list_attrib_def
- debug: var=list_attrib_def
- assert:
that:
- "not list_attrib_def.changed"
- name: remove attribute definition - name: remove attribute definition
vmware_guest_custom_attribute_defs: vmware_guest_custom_attribute_defs:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
state: absent state: absent
attribute_key: sample_5 attribute_key: sample_5
register: remove_attrib_def register: remove_attrib_def
@ -116,14 +65,14 @@
- assert: - assert:
that: that:
- "remove_attrib_def.changed" - "remove_attrib_def.changed"
- "'sample_5' not in remove_attrib_def.instance" - "'sample_5' not in remove_attrib_def.custom_attribute_defs"
- name: remove attribute definition - name: remove attribute definition
vmware_guest_custom_attribute_defs: vmware_guest_custom_attribute_defs:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
state: absent state: absent
attribute_key: sample_5 attribute_key: sample_5
register: remove_attrib_def register: remove_attrib_def
@ -133,19 +82,4 @@
- assert: - assert:
that: that:
- "not remove_attrib_def.changed" - "not remove_attrib_def.changed"
- "'sample_5' not in remove_attrib_def.instance" - "'sample_5' not in remove_attrib_def.custom_attribute_defs"
- name: list attribute definition
vmware_guest_custom_attribute_defs:
validate_certs: False
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance['json']['username'] }}"
password: "{{ vcsim_instance['json']['password'] }}"
state: list
register: list_attrib_def
- debug: var=list_attrib_def
- assert:
that:
- "not list_attrib_def.changed"

@ -1,2 +1,3 @@
cloud/vcenter cloud/vcenter
unsupported shippable/vcenter/group1
needs/target/prepare_vmware_tests

@ -4,51 +4,21 @@
# TODO: Current pinned version of vcsim does not support custom fields # TODO: Current pinned version of vcsim does not support custom fields
# commenting testcase below # commenting testcase below
- import_role:
- name: Wait for Flask controller to come up online name: prepare_vmware_tests
wait_for: vars:
host: "{{ vcsim }}" setup_attach_host: true
port: 5000 setup_datastore: true
state: started setup_virtualmachines: true
- name: kill vcsim
uri:
url: http://{{ vcsim }}:5000/killall
- name: start vcsim
uri:
url: http://{{ vcsim }}:5000/spawn?datacenter=1&cluster=1&folder=0
register: vcsim_instance
- name: Wait for vcsim server to come up online
wait_for:
host: "{{ vcsim }}"
port: 443
state: started
- name: get a list of Datacenter from vcsim
uri:
url: http://{{ vcsim }}:5000/govc_find?filter=DC
register: datacenters
- set_fact: dc1="{{ datacenters['json'][0] }}"
- name: get a list of virtual machines from vcsim
uri:
url: http://{{ vcsim }}:5000/govc_find?filter=VM
register: vms
- set_fact: vm1="{{ vms['json'][0] }}"
- name: Add custom attribute to the given virtual machine - name: Add custom attribute to the given virtual machine
vmware_guest_custom_attributes: vmware_guest_custom_attributes:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: '{{ vcenter_hostname }}'
username: "{{ vcsim_instance['json']['username'] }}" username: '{{ vcenter_username }}'
password: "{{ vcsim_instance['json']['password'] }}" password: '{{ vcenter_password }}'
datacenter: "{{ dc1 | basename }}" datacenter: "{{ dc1 }}"
name: "{{ vm1 | basename }}" name: "{{ infra.vm_list[0] }}"
folder: "{{ vm1 | dirname }}" folder: "{{ f0 }}"
state: present state: present
attributes: attributes:
- name: 'sample_1' - name: 'sample_1'
@ -59,21 +29,21 @@
value: 'sample_3_value' value: 'sample_3_value'
register: guest_facts_0001 register: guest_facts_0001
- debug: msg="{{ guest_facts_0001 }}" - debug: var=guest_facts_0001
- assert: - assert:
that: that:
- "guest_facts_0001.changed" - guest_facts_0001 is changed
- name: Add custom attribute to the given virtual machine again - name: Add custom attribute to the given virtual machine again
vmware_guest_custom_attributes: vmware_guest_custom_attributes:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: '{{ vcenter_hostname }}'
username: "{{ vcsim_instance['json']['username'] }}" username: '{{ vcenter_username }}'
password: "{{ vcsim_instance['json']['password'] }}" password: '{{ vcenter_password }}'
datacenter: "{{ dc1 | basename }}" datacenter: "{{ dc1 }}"
name: "{{ vm1 | basename }}" name: "{{ infra.vm_list[0] }}"
folder: "{{ vm1 | dirname }}" folder: "{{ f0 }}"
state: present state: present
attributes: attributes:
- name: 'sample_1' - name: 'sample_1'
@ -84,21 +54,21 @@
value: 'sample_3_value' value: 'sample_3_value'
register: guest_facts_0002 register: guest_facts_0002
- debug: msg="{{ guest_facts_0002 }}" - debug: var=guest_facts_0002
- assert: - assert:
that: that:
- "not guest_facts_0002.changed" - not (guest_facts_0002 is changed)
- name: Remove custom attribute to the given virtual machine - name: Remove custom attribute to the given virtual machine
vmware_guest_custom_attributes: vmware_guest_custom_attributes:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: '{{ vcenter_hostname }}'
username: "{{ vcsim_instance['json']['username'] }}" username: '{{ vcenter_username }}'
password: "{{ vcsim_instance['json']['password'] }}" password: '{{ vcenter_password }}'
datacenter: "{{ dc1 | basename }}" datacenter: "{{ dc1 }}"
name: "{{ vm1 | basename }}" name: "{{ infra.vm_list[0] }}"
folder: "{{ vm1 | dirname }}" folder: "{{ f0 }}"
state: absent state: absent
attributes: attributes:
- name: 'sample_1' - name: 'sample_1'
@ -115,24 +85,26 @@
# TODO: vcsim returns duplicate values so removing custom attributes # TODO: vcsim returns duplicate values so removing custom attributes
# results in change. vCenter show correct behavior. Commenting this # results in change. vCenter show correct behavior. Commenting this
# till this is supported by vcsim. # till this is supported by vcsim.
#- name: Remove custom attribute to the given virtual machine again - when: vcsim is not defined
# vmware_guest_custom_attributes: block:
# validate_certs: False - name: Remove custom attribute to the given virtual machine again
# hostname: "{{ vcsim }}" vmware_guest_custom_attributes:
# username: "{{ vcsim_instance['json']['username'] }}" validate_certs: False
# password: "{{ vcsim_instance['json']['password'] }}" hostname: '{{ vcenter_hostname }}'
# datacenter: "{{ dc1 | basename }}" username: '{{ vcenter_username }}'
# name: "{{ vm1 | basename }}" password: '{{ vcenter_password }}'
# folder: "{{ vm1 | dirname }}" datacenter: "{{ dc1 }}"
# state: absent name: "{{ infra.vm_list[0] }}"
# attributes: folder: "{{ f0 }}"
# - name: 'sample_1' state: absent
# - name: 'sample_2' attributes:
# - name: 'sample_3' - name: 'sample_1'
# register: guest_facts_0005 - name: 'sample_2'
- name: 'sample_3'
#- debug: msg="{{ guest_facts_0005 }}" register: guest_facts_0005
#- assert: - debug: var=guest_facts_0005
# that:
# - "not guest_facts_0005.changed" - assert:
that:
- not (guest_facts_0005 is changed)

@ -1,2 +1,3 @@
cloud/vcenter cloud/vcenter
unsupported shippable/vcenter/group1
needs/target/prepare_vmware_tests

@ -4,41 +4,37 @@
# TODO: vcsim does not support customizationspecmanager related functionalities # TODO: vcsim does not support customizationspecmanager related functionalities
- name: Wait for Flask controller to come up online - when: vcsim is not defined
wait_for: block:
host: "{{ vcsim }}" - import_role:
port: 5000 name: prepare_vmware_tests
state: started vars:
setup_attach_host: true
- name: kill vcsim setup_datastore: true
uri: setup_virtualmachines: true
url: http://{{ vcsim }}:5000/killall
- &vm_guest_facts
- name: start vcsim with no folders name: Gather facts about given customization spec
uri: vmware_guest_customization_facts:
url: http://{{ vcsim }}:5000/spawn?datacenter=1&cluster=1&folder=1 validate_certs: False
register: vcsim_instance hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
- name: Wait for Flask controller to come up online password: "{{ vcenter_password }}"
wait_for: register: vm_custom_spec_facts
host: "{{ vcsim }}"
port: 443 - debug:
state: started var: vm_custom_spec_facts
- debug: var=vcsim_instance - assert:
- debug: var=vmlist that:
- "not vm_custom_spec_facts.changed"
- name: Gather facts about given customization spec
vmware_guest_customization_facts: - <<: *vm_guest_facts
validate_certs: False name: Gather facts about given customization spec in check module
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance['json']['username'] }}" - debug:
password: "{{ vcsim_instance['json']['password'] }}" var: vm_custom_spec_facts
spec_name: sample_spec
register: vm_custom_spec_facts - assert:
that:
- debug: var=vm_custom_spec_facts - "not vm_custom_spec_facts.changed"
- assert:
that:
- "not vm_custom_spec_facts.changed"

@ -1,2 +1,3 @@
cloud/vcenter cloud/vcenter
unsupported shippable/vcenter/group1
needs/target/prepare_vmware_tests

@ -2,49 +2,22 @@
# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com> # Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# TODO: vcsim does not support disk information - import_role:
- name: Wait for Flask controller to come up online name: prepare_vmware_tests
wait_for: vars:
host: "{{ vcsim }}" setup_attach_host: true
port: 5000 setup_datastore: true
state: started setup_virtualmachines: true
- name: kill vcsim
uri:
url: http://{{ vcsim }}:5000/killall
- name: start vcsim with no folders
uri:
url: http://{{ vcsim }}:5000/spawn?datacenter=1&cluster=1&folder=0
register: vcsim_instance
- name: Wait for Flask controller to come up online
wait_for:
host: "{{ vcsim }}"
port: 443
state: started
- name: get a list of VMS from vcsim
uri:
url: http://{{ vcsim }}:5000/govc_find?filter=VM
register: vmlist
- debug: var=vcsim_instance
- debug: var=vmlist
- set_fact:
vm1: "{{ vmlist['json'][0] }}"
- debug: var=vm1
- name: Gather facts about virtual machine disks - name: Gather facts about virtual machine disks
vmware_guest_disk_facts: vmware_guest_disk_facts: &get_facts
validate_certs: no validate_certs: no
hostname: "{{ vcsim }}" hostname: '{{ vcenter_hostname }}'
username: "{{ vcsim_instance['json']['username'] }}" username: '{{ vcenter_username }}'
password: "{{ vcsim_instance['json']['password'] }}" password: '{{ vcenter_password }}'
name: "{{ vm1 }}" name: "{{ infra.vm_list[0] }}"
datacenter: "{{ (vm1 | basename).split('_')[0] }}" datacenter: '{{ dc1 }}'
register: disk_facts register: disk_facts
- debug: - debug:
@ -57,12 +30,7 @@
- name: Gather facts about virtual machine disks in check mode - name: Gather facts about virtual machine disks in check mode
vmware_guest_disk_facts: vmware_guest_disk_facts:
validate_certs: no <<: *get_facts
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance['json']['username'] }}"
password: "{{ vcsim_instance['json']['password'] }}"
name: "{{ vm1 }}"
datacenter: "{{ (vm1 | basename).split('_')[0] }}"
register: disk_facts register: disk_facts
check_mode: yes check_mode: yes

@ -1,2 +1,3 @@
shippable/vcenter/group1 shippable/vcenter/group1
cloud/vcenter cloud/vcenter
needs/target/prepare_vmware_tests

@ -2,70 +2,36 @@
# Copyright: (c) 2017, Abhijeet Kasurde <akasurde@redhat.com> # Copyright: (c) 2017, Abhijeet Kasurde <akasurde@redhat.com>
# Copyright: (c) 2018, James E. King III (@jeking3) <jking@apache.org> # Copyright: (c) 2018, James E. King III (@jeking3) <jking@apache.org>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
---
- name: Wait for Flask controller to come up online
wait_for:
host: "{{ vcsim }}"
port: 5000
state: started
- name: kill vcsim - import_role:
uri: name: prepare_vmware_tests
url: http://{{ vcsim }}:5000/killall vars:
setup_attach_host: true
- name: start vcsim setup_datastore: true
uri: setup_virtualmachines: true
url: http://{{ vcsim }}:5000/spawn?datacenter=1&cluster=1&folder=0
register: vcsim_instance
- name: Wait for vcsim server to come up online
wait_for:
host: "{{ vcsim }}"
port: 443
state: started
- name: get a list of Datacenter from vcsim
uri:
url: http://{{ vcsim }}:5000/govc_find?filter=DC
register: datacenters
- set_fact: dc1="{{ datacenters['json'][0] }}"
- name: get a list of hosts from vcsim
uri:
url: http://{{ vcsim }}:5000/govc_find?filter=H
register: hosts
- set_fact: h1="{{ hosts['json'][0] }}"
- name: get a list of virtual machines from vcsim
uri:
url: http://{{ vcsim }}:5000/govc_find?filter=VM
register: vms
- set_fact: vm1="{{ vms['json'][0] }}"
# Testcase 0001: Get details about virtual machines # Testcase 0001: Get details about virtual machines
- name: get list of facts about virtual machines - name: get list of facts about virtual machines
vmware_guest_facts: vmware_guest_facts:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
datacenter: "{{ dc1 | basename }}" datacenter: "{{ dc1 }}"
name: "{{ vm1 | basename }}" name: "{{ infra.vm_list[0] }}"
folder: "{{ vm1 | dirname }}" folder: "{{ f0 }}"
register: guest_facts_0001 register: guest_facts_0001
- debug: var=guest_facts_0001 - debug:
var: guest_facts_0001
- assert: - assert:
that: that:
- "guest_facts_0001['instance']['hw_name'] == vm1 | basename" - "guest_facts_0001['instance']['hw_name'] == infra.vm_list[0]"
- "guest_facts_0001['instance']['hw_product_uuid'] is defined" - "guest_facts_0001['instance']['hw_product_uuid'] is defined"
- "guest_facts_0001['instance']['hw_cores_per_socket'] is defined" - "guest_facts_0001['instance']['hw_cores_per_socket'] is defined"
- "guest_facts_0001['instance']['hw_datastores'] is defined" - "guest_facts_0001['instance']['hw_datastores'] is defined"
- "guest_facts_0001['instance']['hw_esxi_host'] == h1 | basename" - "guest_facts_0001['instance']['hw_esxi_host'] is defined"
- "guest_facts_0001['instance']['hw_files'] is defined" - "guest_facts_0001['instance']['hw_files'] is defined"
- "guest_facts_0001['instance']['hw_guest_ha_state'] is defined" - "guest_facts_0001['instance']['hw_guest_ha_state'] is defined"
- "guest_facts_0001['instance']['hw_is_template'] is defined" - "guest_facts_0001['instance']['hw_is_template'] is defined"
@ -80,28 +46,30 @@
- set_fact: vm1_instance_uuid="{{ guest_facts_0001['instance']['instance_uuid'] }}" - set_fact: vm1_instance_uuid="{{ guest_facts_0001['instance']['instance_uuid'] }}"
- debug: var=vm1_uuid - debug:
var: vm1_uuid
# Testcase 0002: Get details about virtual machines using UUID # Testcase 0002: Get details about virtual machines using UUID
- name: get list of facts about virtual machines using UUID - name: get list of facts about virtual machines using UUID
vmware_guest_facts: vmware_guest_facts:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
datacenter: "{{ dc1 | basename }}" datacenter: "{{ dc1 }}"
uuid: "{{ vm1_uuid }}" uuid: "{{ vm1_uuid }}"
register: guest_facts_0002 register: guest_facts_0002
- debug: var=guest_facts_0002 - debug:
var: guest_facts_0002
- name: "Get specific details about virtual machines using the vsphere output schema" - name: Get specific details about virtual machines using the vsphere output schema
vmware_guest_facts: vmware_guest_facts:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
datacenter: "{{ dc1 | basename }}" datacenter: "{{ dc1 }}"
uuid: "{{ vm1_uuid }}" uuid: "{{ vm1_uuid }}"
schema: vsphere schema: vsphere
properties: properties:
@ -111,11 +79,12 @@
- summary.runtime.connectionState - summary.runtime.connectionState
register: guest_facts_0002b register: guest_facts_0002b
- debug: var=guest_facts_0002b - debug:
var: guest_facts_0002b
- assert: - assert:
that: that:
- "guest_facts_0002['instance']['hw_name'] == vm1 | basename" - "guest_facts_0002['instance']['hw_name'] == infra.vm_list[0]"
- "guest_facts_0002['instance']['hw_product_uuid'] is defined" - "guest_facts_0002['instance']['hw_product_uuid'] is defined"
- "guest_facts_0002['instance']['hw_product_uuid'] == vm1_uuid" - "guest_facts_0002['instance']['hw_product_uuid'] == vm1_uuid"
- "guest_facts_0002['instance']['hw_cores_per_socket'] is defined" - "guest_facts_0002['instance']['hw_cores_per_socket'] is defined"
@ -128,88 +97,83 @@
- name: get empty list of snapshots from virtual machine using UUID - name: get empty list of snapshots from virtual machine using UUID
vmware_guest_facts: vmware_guest_facts:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
datacenter: "{{ dc1 | basename }}" datacenter: "{{ dc1 }}"
uuid: "{{ vm1_uuid }}" uuid: "{{ vm1_uuid }}"
register: guest_facts_0003 register: guest_facts_0003
- debug: var=guest_facts_0003 - debug:
var: guest_facts_0003
- assert: - assert:
that: that:
- "guest_facts_0003['instance']['snapshots']|length == 0" - "guest_facts_0003['instance']['snapshots']|length == 0"
- "guest_facts_0003['instance']['current_snapshot'] is none" - "guest_facts_0003['instance']['current_snapshot'] is none"
# Commenting as this is failing right now - 15 Dec 2017
# Testcase 0004: Get details about virtual machines with two snapshots using UUID # Testcase 0004: Get details about virtual machines with two snapshots using UUID
#- name: Create first snapshot - name: Create first snapshot
# vmware_guest_snapshot: vmware_guest_snapshot: &vm_snap
# validate_certs: False validate_certs: False
# hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
# username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
# password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
# datacenter: "{{ dc1 | basename }}" datacenter: "{{ dc1 }}"
# name: "{{ vm1 | basename }}" name: "{{ infra.vm_list[0] }}"
# folder: "{{ vm1 | dirname }}" folder: "{{ f0 }}"
# state: present state: present
# snapshot_name: snap1 snapshot_name: snap1
#- name: Create second snapshot - name: Create second snapshot
# vmware_guest_snapshot: vmware_guest_snapshot:
# validate_certs: False <<: *vm_snap
# hostname: "{{ vcsim }}" snapshot_name: snap2
# username: "{{ vcsim_instance['json']['username'] }}"
# password: "{{ vcsim_instance['json']['password'] }}" - name: get list of snapshots from virtual machine using UUID
# datacenter: "{{ dc1 | basename }}" vmware_guest_facts:
# name: "{{ vm1 | basename }}" validate_certs: False
# folder: "{{ vm1 | dirname }}" hostname: "{{ vcenter_hostname }}"
# state: present username: "{{ vcenter_username }}"
# snapshot_name: snap2 password: "{{ vcenter_password }}"
datacenter: "{{ dc1 }}"
#- name: get list of snapshots from virtual machine using UUID uuid: "{{ vm1_uuid }}"
# vmware_guest_facts: register: guest_facts_0004
# validate_certs: False
# hostname: "{{ vcsim }}" - debug:
# username: "{{ vcsim_instance['json']['username'] }}" var: guest_facts_0004
# password: "{{ vcsim_instance['json']['password'] }}"
# datacenter: "{{ dc1 | basename }}" - assert:
# uuid: "{{ vm1_uuid }}" that:
# register: guest_facts_0004 - "guest_facts_0004['instance']['snapshots'] is defined"
- "guest_facts_0004['instance']['snapshots'][0]['name'] == 'snap1'"
#- debug: var=guest_facts_0004 - "guest_facts_0004['instance']['snapshots'][1]['name'] == 'snap2'"
- "guest_facts_0004['instance']['current_snapshot']['name'] == 'snap2'"
#- assert: - "guest_facts_0002['instance']['hw_folder'] is defined"
# that:
# - "guest_facts_0004['instance']['snapshots'] is defined"
# - "guest_facts_0004['instance']['snapshots'][0]['name'] == 'snap1'"
# - "guest_facts_0004['instance']['snapshots'][1]['name'] == 'snap2'"
# - "guest_facts_0004['instance']['current_snapshot']['name'] == 'snap2'"
# - "guest_facts_0002['instance']['hw_folder'] == vm1 | dirname"
# Testcase 0005: Get details about virtual machines using UUID # Testcase 0005: Get details about virtual machines using UUID
- name: get list of facts about virtual machines using instance UUID - name: get list of facts about virtual machines using instance UUID
vmware_guest_facts: vmware_guest_facts:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
datacenter: "{{ dc1 | basename }}" datacenter: "{{ dc1 }}"
uuid: "{{ vm1_instance_uuid }}" uuid: "{{ vm1_instance_uuid }}"
use_instance_uuid: True use_instance_uuid: True
register: guest_facts_0005 register: guest_facts_0005
- debug: msg="{{ guest_facts_0005 }}" - debug:
msg: "{{ guest_facts_0005 }}"
- assert: - assert:
that: that:
- "guest_facts_0005['instance']['hw_name'] == vm1 | basename" - "guest_facts_0005['instance']['hw_name'] == infra.vm_list[0]"
- "guest_facts_0005['instance']['hw_product_uuid'] is defined" - "guest_facts_0005['instance']['hw_product_uuid'] is defined"
- "guest_facts_0005['instance']['hw_product_uuid'] == vm1_uuid" - "guest_facts_0005['instance']['hw_product_uuid'] == vm1_uuid"
- "guest_facts_0005['instance']['hw_cores_per_socket'] is defined" - "guest_facts_0005['instance']['hw_cores_per_socket'] is defined"
- "guest_facts_0005['instance']['hw_datastores'] is defined" - "guest_facts_0005['instance']['hw_datastores'] is defined"
- "guest_facts_0005['instance']['hw_esxi_host'] == h1 | basename" - "guest_facts_0005['instance']['hw_esxi_host'] is defined"
- "guest_facts_0005['instance']['hw_files'] is defined" - "guest_facts_0005['instance']['hw_files'] is defined"
- "guest_facts_0005['instance']['hw_guest_ha_state'] is defined" - "guest_facts_0005['instance']['hw_guest_ha_state'] is defined"
- "guest_facts_0005['instance']['hw_is_template'] is defined" - "guest_facts_0005['instance']['hw_is_template'] is defined"

@ -1,2 +1,3 @@
shippable/vcenter/group1 shippable/vcenter/group1
cloud/vcenter cloud/vcenter
needs/target/prepare_vmware_tests

@ -2,52 +2,21 @@
# Copyright: (c) 2017, James Tanner <tanner.jc@gmail.com> # Copyright: (c) 2017, James Tanner <tanner.jc@gmail.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
- name: wait for flask server - import_role:
wait_for: name: prepare_vmware_tests
host: "{{ vcsim }}" vars:
port: 5000 setup_attach_host: true
state: started setup_datastore: true
setup_virtualmachines: true
- name: kill vcsim
uri:
url: http://{{ vcsim }}:5000/killall
- name: start vcsim
uri:
url: http://{{ vcsim }}:5000/spawn?cluster=2
register: vcsim_instance
- name: wait for vcsim server
wait_for:
host: "{{ vcsim }}"
port: 443
state: started
- name: get a list of VMS from vcsim
uri:
url: http://{{ vcsim }}:5000/govc_find?filter=VM
register: vmlist
- debug: var=vcsim_instance
- debug: var=vmlist
# vcsim embeds the datacenter into the path and
# the VM name, so it can be chopped out for later
# use or verification
- name: show the datacenter(s)
debug:
msg: "{{ (item|basename).split('_')[0] }}"
with_items: "{{ vmlist['json'] }}"
- name: find folders for each vm - name: find folders for each vm
vmware_guest_find: vmware_guest_find:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
name: "{{ item|basename }}" name: "{{ item }}"
datacenter: "{{ (item|basename).split('_')[0] }}" datacenter: "{{ dc1 }}"
with_items: "{{ vmlist['json'] }}" with_items: "{{ infra.vm_list }}"
register: folders register: folders
- debug: var=item - debug: var=item
@ -62,28 +31,31 @@
- "{{ item['folders']|length == 1 }}" - "{{ item['folders']|length == 1 }}"
with_items: "{{ folders.results }}" with_items: "{{ folders.results }}"
# Testcase 2: Find VMS using UUID - name: get fact of the first VM
- name: get details about VMS from vcsim vmware_guest_facts:
uri: validate_certs: False
url: http://{{ vcsim }}:5000/govc_vm_info hostname: "{{ vcenter_hostname }}"
register: vms_detail_list username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ dc1 }}"
name: "{{ infra.vm_list[0] }}"
folder: "{{ f0 }}"
register: guest_facts_0001
- debug: var=guest_facts_0001
- name: find folders for each vm using UUID - name: find folders for each vm using UUID
vmware_guest_find: vmware_guest_find:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
uuid: "{{ vms_detail_list['json'][item|basename]['UUID'] }}" uuid: "{{ guest_facts_0001['instance']['hw_product_uuid'] }}"
datacenter: "{{ (item|basename).split('_')[0] }}" register: folder_uuid
with_items: "{{ vmlist['json'] }}"
register: folders_uuid
- debug: var=item - debug: var=folder_uuid
with_items: "{{ folders_uuid.results }}"
- assert: - assert:
that: that:
- "{{ 'folders' in item }}" - "{{ 'folders' in folder_uuid }}"
- "{{ item['folders']|length == 1 }}" - "{{ folder_uuid['folders']|length == 1 }}"
with_items: "{{ folders_uuid.results }}"

@ -1,2 +1,3 @@
shippable/vcenter/group1 shippable/vcenter/group1
cloud/vcenter cloud/vcenter
needs/target/prepare_vmware_tests

@ -1,47 +1,34 @@
# Test code for the vmware_guest_move module # Test code for the vmware_guest_move module
# Copyright: (c) 2018, Jose Angel Munoz <josea.munoz@gmail.com> # Copyright: (c) 2018, Jose Angel Munoz <josea.munoz@gmail.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
- import_role:
- name: Wait for Flask controller to come up online name: prepare_vmware_tests
wait_for: vars:
host: "{{ vcsim }}" setup_attach_host: true
port: 5000 setup_datastore: true
state: started setup_virtualmachines: true
- name: kill vcsim - name: Create a VM folder on given Datacenter
uri: vcenter_folder:
url: http://{{ vcsim }}:5000/killall hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
- name: start vcsim password: '{{ vcenter_password }}'
uri: datacenter: '{{ dc1 }}'
url: http://{{ vcsim }}:5000/spawn?folder=2&dc=2 folder_name: 'f1'
register: vcsim_instance folder_type: vm
state: present
- name: Wait for Flask controller to come up online validate_certs: no
wait_for:
host: "{{ vcsim }}"
port: 443
state: started
- debug: var=vcsim_instance
- name: get a list of virtual machines from vcsim
uri:
url: http://{{ vcsim }}:5000/govc_find?filter=VM
register: vms
- set_fact: vm1="{{ vms['json'][0] }}"
# Testcase 0001: Move vm and get changed status # Testcase 0001: Move vm and get changed status
- name: Move VM (Changed) - name: Move VM (Changed)
vmware_guest_move: vmware_guest_move:
validate_certs: false validate_certs: false
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
datacenter: "{{ (vm1|basename).split('_')[0] }}" datacenter: "{{ dc1 }}"
name: "{{ vm1|basename }}" name: "{{ infra.vm_list[0] }}"
dest_folder: F1/DC1/vm/F1 dest_folder: '/F0/DC0/vm/f1'
register: vm_facts_0001 register: vm_facts_0001
@ -49,12 +36,12 @@
- name: Move VM (OK) - name: Move VM (OK)
vmware_guest_move: vmware_guest_move:
validate_certs: false validate_certs: false
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
datacenter: "{{ (vm1|basename).split('_')[0] }}" datacenter: "{{ dc1 }}"
name: "{{ vm1|basename }}" name: "{{ infra.vm_list[0] }}"
dest_folder: F1/DC1/vm/F1 dest_folder: 'F0/DC0/vm/f1'
register: vm_facts_0002 register: vm_facts_0002
- debug: - debug:
@ -63,11 +50,7 @@
- debug: - debug:
msg: "{{ vm_facts_0002 }}" msg: "{{ vm_facts_0002 }}"
- name: get all VMs - assert:
uri: that:
url: http://{{ vcsim }}:5000/govc_find?filter=VM - vm_facts_0001.changed
register: vms_diff - not vm_facts_0002.changed
- name: Difference
debug:
var: vms_diff.json | difference(vms.json)

@ -1,2 +1,3 @@
shippable/vcenter/group1 shippable/vcenter/group1
cloud/vcenter cloud/vcenter
needs/target/prepare_vmware_tests

@ -2,5 +2,26 @@
# Copyright: (c) 2017, Abhijeet Kasurde <akasurde@redhat.com> # Copyright: (c) 2017, Abhijeet Kasurde <akasurde@redhat.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
- include: poweroff_d1_c1_f0.yml - import_role:
- include: poweroff_d1_c1_f1.yml name: prepare_vmware_tests
vars:
setup_attach_host: true
setup_datastore: true
setup_virtualmachines: true
- name: set state to poweroff the first VM
vmware_guest_powerstate:
validate_certs: False
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
name: "{{ infra.vm_list[0] }}"
state: powered-off
folder: '/dc1/vm/f0'
register: poweroff_d1_c1_f0
- debug: var=poweroff_d1_c1_f0
- name: make sure change was made
assert:
that:
- poweroff_d1_c1_f0.changed

@ -1,2 +1,3 @@
cloud/vcenter cloud/vcenter
unsupported shippable/vcenter/group1
needs/target/prepare_vmware_tests

@ -1,225 +1,178 @@
- name: Wait for Flask controller to come up online - import_role:
wait_for: name: prepare_vmware_tests
host: "{{ vcsim }}" vars:
port: 5000 setup_attach_host: true
state: started setup_datastore: true
setup_virtualmachines: true
- name: kill vcsim
uri: # Test0001: Try to delete the non-existent snapshot
url: "{{ 'http://' + vcsim + ':5000/killall' }}" - name: 0001 - Delete non-existent snapshot
- name: start vcsim with no folders vmware_guest_snapshot:
uri: validate_certs: False
url: "{{ 'http://' + vcsim + ':5000/spawn?datacenter=1&cluster=1&folder=1' }}" hostname: '{{ vcenter_hostname }}'
register: vcsim_instance username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
- name: Wait for Flask controller to come up online datacenter: "{{ dc1 }}"
wait_for: folder: "{{ f0 }}"
host: "{{ vcsim }}" name: "{{ infra.vm_list[0] }}"
port: 443 state: absent
state: started snapshot_name: snap_a
- name: get a list of VMS from vcsim # Test0002: Create two snapshots
uri: - name: 0002 - Create snapshot
url: "{{ 'http://' + vcsim + ':5000/govc_find?filter=VM' }}" vmware_guest_snapshot:
register: vmlist validate_certs: False
hostname: '{{ vcenter_hostname }}'
- set_fact: username: '{{ vcenter_username }}'
vm1: "{{ vmlist['json'][0] }}" password: '{{ vcenter_password }}'
datacenter: "{{ dc1 }}"
- name: get a list of datacenters from vcsim folder: "{{ f0 }}"
uri: name: "{{ infra.vm_list[0] }}"
url: "{{ 'http://' + vcsim + ':5000/govc_find?filter=DC' }}" state: present
register: datacenters snapshot_name: "snap_{{item}}"
description: "snap named {{item}}"
- set_fact: with_items:
dc1: "{{ datacenters['json'][0] }}" - a
- b
- debug: var=vcsim_instance
- debug: var=vmlist - when: vcsim is not defined
- debug: var=vm1 block:
- debug: var=dc1 # Test0003: Reanme a to c
- name: 0003 - Rename snapshot
# Test0001: Try to delete the non-existent snapshot vmware_guest_snapshot:
- name: 0001 - Delete non-existent snapshot validate_certs: False
vmware_guest_snapshot: hostname: '{{ vcenter_hostname }}'
validate_certs: False username: '{{ vcenter_username }}'
hostname: "{{ vcsim }}" password: '{{ vcenter_password }}'
username: "{{ vcsim_instance['json']['username'] }}" datacenter: "{{ dc1 }}"
password: "{{ vcsim_instance['json']['password'] }}" folder: "{{ f0 }}"
datacenter: "{{ dc1 | basename }}" name: "{{ infra.vm_list[0] }}"
folder: "{{ vm1 | dirname }}" state: present
name: "{{ vm1 | basename }}" snapshot_name: snap_a
state: absent new_snapshot_name: snap_c
snapshot_name: snap_a
# Test0004: Create snap_a again
# Test0002: Create two snapshots - name: 0004 - Re-create snapshot a
- name: 0002 - Create snapshot vmware_guest_snapshot:
vmware_guest_snapshot: validate_certs: False
validate_certs: False hostname: '{{ vcenter_hostname }}'
hostname: "{{ vcsim }}" username: '{{ vcenter_username }}'
username: "{{ vcsim_instance['json']['username'] }}" password: '{{ vcenter_password }}'
password: "{{ vcsim_instance['json']['password'] }}" datacenter: "{{ dc1 }}"
datacenter: "{{ dc1 | basename }}" folder: "{{ f0 }}"
folder: "{{ vm1 | dirname }}" name: "{{ infra.vm_list[0] }}"
name: "{{ vm1 | basename }}" state: present
state: present snapshot_name: snap_a
snapshot_name: "snap_{{item}}" description: "snap named a"
description: "snap named {{item}}"
with_items: # Test0005: Change description of snap_c
- a - name: 0005 - Change description of snap_c
- b vmware_guest_snapshot:
validate_certs: False
# Test0003: Reanme a to c hostname: '{{ vcenter_hostname }}'
- name: 0003 - Rename snapshot username: '{{ vcenter_username }}'
vmware_guest_snapshot: password: '{{ vcenter_password }}'
validate_certs: False datacenter: "{{ dc1 }}"
hostname: "{{ vcsim }}" folder: "{{ f0 }}"
username: "{{ vcsim_instance['json']['username'] }}" name: "{{ infra.vm_list[0] }}"
password: "{{ vcsim_instance['json']['password'] }}" state: present
datacenter: "{{ dc1 | basename }}" snapshot_name: snap_c
folder: "{{ vm1 | dirname }}" new_description: "renamed to snap_c from snap_a"
name: "{{ vm1 | basename }}"
state: present - when: vcsim is not defined
snapshot_name: snap_a block:
new_snapshot_name: snap_c # Test0006: Delete snap_b with child remove
- name: 0006 - Delete snap_b with child remove
# Test0004: Create snap_a again vmware_guest_snapshot:
- name: 0004 - Re-create snapshot a validate_certs: False
vmware_guest_snapshot: hostname: '{{ vcenter_hostname }}'
validate_certs: False username: '{{ vcenter_username }}'
hostname: "{{ vcsim }}" password: '{{ vcenter_password }}'
username: "{{ vcsim_instance['json']['username'] }}" datacenter: "{{ dc1 }}"
password: "{{ vcsim_instance['json']['password'] }}" folder: "{{ f0 }}"
datacenter: "{{ dc1 | basename }}" name: "{{ infra.vm_list[0] }}"
folder: "{{ vm1 | dirname }}" state: absent
name: "{{ vm1 | basename }}" snapshot_name: snap_b
state: present remove_children: True
snapshot_name: snap_a
description: "snap named a" # Test0007: Delete all snapshots
- name: 0007 - Delete all snapshots
# Test0005: Change description of snap_c vmware_guest_snapshot:
- name: 0005 - Change description of snap_c validate_certs: False
vmware_guest_snapshot: hostname: '{{ vcenter_hostname }}'
validate_certs: False username: '{{ vcenter_username }}'
hostname: "{{ vcsim }}" password: '{{ vcenter_password }}'
username: "{{ vcsim_instance['json']['username'] }}" datacenter: "{{ dc1 }}"
password: "{{ vcsim_instance['json']['password'] }}" folder: "{{ f0 }}"
datacenter: "{{ dc1 | basename }}" name: "{{ infra.vm_list[0] }}"
folder: "{{ vm1 | dirname }}" state: remove_all
name: "{{ vm1 | basename }}"
state: present # Test0008: Create snap_a again and revert to it
snapshot_name: snap_c - name: 0008 - Re-create snapshot a
new_description: "renamed to snap_c from snap_a" vmware_guest_snapshot:
validate_certs: False
# Test0006: Delete snap_b with child remove hostname: '{{ vcenter_hostname }}'
- name: 0006 - Delete snap_b with child remove username: '{{ vcenter_username }}'
vmware_guest_snapshot: password: '{{ vcenter_password }}'
validate_certs: False datacenter: "{{ dc1 }}"
hostname: "{{ vcsim }}" folder: "{{ f0 }}"
username: "{{ vcsim_instance['json']['username'] }}" name: "{{ infra.vm_list[0] }}"
password: "{{ vcsim_instance['json']['password'] }}" state: present
datacenter: "{{ dc1 | basename }}" snapshot_name: snap_a
folder: "{{ vm1 | dirname }}" description: "snap named a"
name: "{{ vm1 | basename }}"
state: absent - when: vcsim is not defined
snapshot_name: snap_b block:
remove_children: True - name: 0008 - Revert to snap_a
vmware_guest_snapshot:
# Test0007: Delete all snapshots validate_certs: False
- name: 0007 - Delete all snapshots hostname: '{{ vcenter_hostname }}'
vmware_guest_snapshot: username: '{{ vcenter_username }}'
validate_certs: False password: '{{ vcenter_password }}'
hostname: "{{ vcsim }}" datacenter: "{{ dc1 }}"
username: "{{ vcsim_instance['json']['username'] }}" folder: "{{ f0 }}"
password: "{{ vcsim_instance['json']['password'] }}" name: "{{ infra.vm_list[0] }}"
datacenter: "{{ dc1 | basename }}" state: revert
folder: "{{ vm1 | dirname }}" snapshot_name: snap_a
name: "{{ vm1 | basename }}"
state: remove_all # Test0009: Create snap_a and check in result
- name: 0009 - create snapshot a
# Test0008: Create snap_a again and revert to it vmware_guest_snapshot:
- name: 0008 - Re-create snapshot a validate_certs: False
vmware_guest_snapshot: hostname: '{{ vcenter_hostname }}'
validate_certs: False username: '{{ vcenter_username }}'
hostname: "{{ vcsim }}" password: '{{ vcenter_password }}'
username: "{{ vcsim_instance['json']['username'] }}" datacenter: "{{ dc1 }}"
password: "{{ vcsim_instance['json']['password'] }}" folder: "{{ f0 }}"
datacenter: "{{ dc1 | basename }}" name: "{{ infra.vm_list[0] }}"
folder: "{{ vm1 | dirname }}" state: present
name: "{{ vm1 | basename }}" snapshot_name: snap_a
state: present description: "snap named a"
snapshot_name: snap_a register: snapshot_details
description: "snap named a"
- debug: var=snapshot_details
- name: 0008 - Revert to snap_a
vmware_guest_snapshot: - name: Check if snapshot details available or not
validate_certs: False assert:
hostname: "{{ vcsim }}" that:
username: "{{ vcsim_instance['json']['username'] }}" - "snapshot_details['msg'] == 'Snapshot named [snap_a] already exists and is current.'"
password: "{{ vcsim_instance['json']['password'] }}"
datacenter: "{{ dc1 | basename }}" # Test0011: Failure sceanrios - when name and UUID is not specified
folder: "{{ vm1 | dirname }}" - name: 0011 - name and UUID is missing
name: "{{ vm1 | basename }}" vmware_guest_snapshot:
state: revert validate_certs: False
snapshot_name: snap_a hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
# Test0009: Create snap_a and check in result password: '{{ vcenter_password }}'
- name: 0009 - create snapshot a datacenter: "{{ dc1 }}"
vmware_guest_snapshot: state: present
validate_certs: False snapshot_name: snap_a
hostname: "{{ vcsim }}" description: "snap named a"
username: "{{ vcsim_instance['json']['username'] }}" register: snapshot_failure_details
password: "{{ vcsim_instance['json']['password'] }}" ignore_errors: yes
datacenter: "{{ dc1 | basename }}"
folder: "{{ vm1 | dirname }}" - name: Check if error is shown
name: "{{ vm1 | basename }}" assert:
state: present that:
snapshot_name: snap_a - "'one of the following is required: name, uuid' in snapshot_failure_details['msg']"
description: "snap named a" - "snapshot_failure_details.changed == false"
register: snapshot_details
- name: Check if snapshot details available or not
assert:
that:
- "snapshot_details.results['current_snapshot']['name'] == 'snap_a'"
# Test0010: Failure sceanrios
- name: 0010 - Folder is missing
vmware_guest_snapshot:
validate_certs: False
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance['json']['username'] }}"
password: "{{ vcsim_instance['json']['password'] }}"
datacenter: "{{ dc1 | basename }}"
name: "{{ vm1 | basename }}"
state: present
snapshot_name: snap_a
description: "snap named a"
register: snapshot_failure_details
ignore_errors: yes
- name: Check if error is shown
assert:
that:
- "'parameters are required together: name, folder' in snapshot_failure_details['msg']"
- "snapshot_failure_details.changed == false"
# Test0011: Failure sceanrios - when name and UUID is not specified
- name: 0011 - name and UUID is missing
vmware_guest_snapshot:
validate_certs: False
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance['json']['username'] }}"
password: "{{ vcsim_instance['json']['password'] }}"
datacenter: "{{ dc1 | basename }}"
state: present
snapshot_name: snap_a
description: "snap named a"
register: snapshot_failure_details
ignore_errors: yes
- name: Check if error is shown
assert:
that:
- "'one of the following is required: name, uuid' in snapshot_failure_details['msg']"
- "snapshot_failure_details.changed == false"

@ -1,2 +1,3 @@
cloud/vcenter cloud/vcenter
unsupported shippable/vcenter/group1
needs/target/prepare_vmware_tests

@ -3,60 +3,26 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# TODO: vcsim does not support snapshot related functionalities # TODO: vcsim does not support snapshot related functionalities
- import_role:
- name: Wait for Flask controller to come up online name: prepare_vmware_tests
wait_for: vars:
host: "{{ vcsim }}" setup_attach_host: true
port: 5000 setup_datastore: true
state: started setup_virtualmachines: true
- name: kill vcsim - name: Gather snapshot facts about given virtual machine
uri: vmware_guest_snapshot_facts:
url: "{{ 'http://' + vcsim + ':5000/killall' }}" validate_certs: False
- name: start vcsim with no folders hostname: "{{ vcenter_hostname }}"
uri: username: "{{ vcenter_username }}"
url: "{{ 'http://' + vcsim + ':5000/spawn?datacenter=1&cluster=1&folder=1' }}" password: "{{ vcenter_password }}"
register: vcsim_instance datacenter: "{{ dc1 }}"
folder: "{{ f0 }}"
- name: Wait for Flask controller to come up online name: "{{ infra.vm_list[0] }}"
wait_for: register: vm_snapshot_facts
host: "{{ vcsim }}"
port: 443 - debug: var=vm_snapshot_facts
state: started
- assert:
- name: get a list of VMS from vcsim that:
uri: - '"guest_snapshots" in vm_snapshot_facts'
url: "{{ 'http://' + vcsim + ':5000/govc_find?filter=VM' }}"
register: vmlist
- set_fact:
vm1: "{{ vmlist['json'][0] }}"
- name: get a list of datacenters from vcsim
uri:
url: "{{ 'http://' + vcsim + ':5000/govc_find?filter=DC' }}"
register: datacenters
- set_fact:
dc1: "{{ datacenters['json'][0] }}"
- debug: var=vcsim_instance
- debug: var=vmlist
- debug: var=vm1
- debug: var=dc1
- name: Gather snapshot facts about given virtual machine
vmware_guest_snapshot_facts:
validate_certs: False
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance['json']['username'] }}"
password: "{{ vcsim_instance['json']['password'] }}"
datacenter: "{{ dc1 | basename }}"
folder: "{{ vm1 | dirname }}"
register: vm_snapshot_facts
- debug: vm_snapshot_facts
- assert:
that:
- "not vm_snapshot_facts.changed"

@ -1,2 +1,3 @@
shippable/vcenter/group1 shippable/vcenter/group1
cloud/vcenter cloud/vcenter
needs/target/prepare_vmware_tests

@ -2,44 +2,23 @@
# Copyright: (c) 2017 Philippe Dellaert <philippe@dellaert.org> # Copyright: (c) 2017 Philippe Dellaert <philippe@dellaert.org>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
- name: Wait for Flask controller to come up online - import_role:
wait_for: name: prepare_vmware_tests
host: "{{ vcsim }}" vars:
port: 5000 setup_attach_host: true
state: started setup_datastore: true
setup_virtualmachines: true
- name: kill vcsim
uri:
url: http://{{ vcsim }}:5000/killall
- name: start vcsim
uri:
url: http://{{ vcsim }}:5000/spawn?datacenter=1&cluster=1&folder=0
register: vcsim_instance
- name: Wait for vcsim server to come up online
wait_for:
host: "{{ vcsim }}"
port: 443
state: started
- name: get a list of virtual machines from vcsim
uri:
url: http://{{ vcsim }}:5000/govc_find?filter=VM
register: vms
- set_fact: vm1="{{ vms['json'][0] }}"
- name: Power on VM1 - name: Power on VM1
vmware_guest: vmware_guest:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
name: "{{ vm1|basename }}" name: "{{ infra.vm_list[0] }}"
datacenter: "{{ (vm1|basename).split('_')[0] }}" datacenter: "{{ dc1 }}"
state: poweredon state: poweredon
folder: "{{ vm1|dirname }}" folder: "{{ f0 }}"
# FixMe: govcsim does not support VMware tools status reporting # FixMe: govcsim does not support VMware tools status reporting
## Testcase 0001: Wait for VMware tools to become available by name ## Testcase 0001: Wait for VMware tools to become available by name

Loading…
Cancel
Save