mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-27 23:21:22 -07:00
Add the cloud provider script for the vcenter simulator container (#25964)
This commit is contained in:
parent
e391206acc
commit
996dcb989c
3 changed files with 211 additions and 0 deletions
3
test/integration/targets/vmware_guest_find/aliases
Normal file
3
test/integration/targets/vmware_guest_find/aliases
Normal file
|
@ -0,0 +1,3 @@
|
|||
posix/ci/cloud/vcenter
|
||||
cloud/vcenter
|
||||
skip/python3
|
56
test/integration/targets/vmware_guest_find/tasks/main.yml
Normal file
56
test/integration/targets/vmware_guest_find/tasks/main.yml
Normal file
|
@ -0,0 +1,56 @@
|
|||
- name: make sure pyvmomi is installed
|
||||
pip:
|
||||
name: pyvmomi
|
||||
state: latest
|
||||
|
||||
- name: store the vcenter container ip
|
||||
set_fact:
|
||||
vcsim: "{{ lookup('env', 'vcenter_host') }}"
|
||||
- debug: var=vcsim
|
||||
|
||||
- name: kill vcsim
|
||||
uri:
|
||||
url: "{{ 'http://' + vcsim + ':5000/killall' }}"
|
||||
- name: start vcsim
|
||||
uri:
|
||||
url: "{{ 'http://' + vcsim + ':5000/spawn?cluster=2' }}"
|
||||
register: vcsim_instance
|
||||
|
||||
- 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
|
||||
vmware_guest_find:
|
||||
validate_certs: False
|
||||
hostname: "{{ vcsim }}"
|
||||
username: "{{ vcsim_instance['json']['username'] }}"
|
||||
password: "{{ vcsim_instance['json']['password'] }}"
|
||||
name: "{{ item|basename }}"
|
||||
datacenter: "{{ (item|basename).split('_')[0] }}"
|
||||
with_items: "{{ vmlist['json'] }}"
|
||||
register: folders
|
||||
|
||||
- debug: var=item
|
||||
with_items: "{{ folders.results }}"
|
||||
|
||||
# We only care that each VM was found, not that the folder path
|
||||
# is completely accurate. Eventually the test should be extended
|
||||
# to validate the full path for each VM.
|
||||
- assert:
|
||||
that:
|
||||
- "{{ 'folders' in item }}"
|
||||
- "{{ item['folders']|length == 1 }}"
|
||||
with_items: "{{ folders.results }}"
|
Loading…
Add table
Add a link
Reference in a new issue