mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
78 lines
2 KiB
YAML
78 lines
2 KiB
YAML
# Test code for the vmware_guest_move module
|
|
# 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)
|
|
|
|
- name: store the vcenter container ip
|
|
set_fact:
|
|
vcsim: "{{ lookup('env', 'vcenter_host') }}"
|
|
- debug: var=vcsim
|
|
|
|
- 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
|
|
uri:
|
|
url: http://{{ vcsim }}:5000/spawn?folder=2&dc=2
|
|
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 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
|
|
- name: Move VM (Changed)
|
|
vmware_guest_move:
|
|
validate_certs: false
|
|
hostname: "{{ vcsim }}"
|
|
username: "{{ vcsim_instance['json']['username'] }}"
|
|
password: "{{ vcsim_instance['json']['password'] }}"
|
|
datacenter: "{{ (vm1|basename).split('_')[0] }}"
|
|
name: "{{ vm1|basename }}"
|
|
dest_folder: F1/DC1/vm/F1
|
|
register: vm_facts_0001
|
|
|
|
|
|
# Testcase 0002: Move vm and get OK status (Already Moved)
|
|
- name: Move VM (OK)
|
|
vmware_guest_move:
|
|
validate_certs: false
|
|
hostname: "{{ vcsim }}"
|
|
username: "{{ vcsim_instance['json']['username'] }}"
|
|
password: "{{ vcsim_instance['json']['password'] }}"
|
|
datacenter: "{{ (vm1|basename).split('_')[0] }}"
|
|
name: "{{ vm1|basename }}"
|
|
dest_folder: F1/DC1/vm/F1
|
|
register: vm_facts_0002
|
|
|
|
- debug:
|
|
msg: "{{ vm_facts_0001 }}"
|
|
|
|
- debug:
|
|
msg: "{{ vm_facts_0002 }}"
|
|
|
|
- name: get all VMs
|
|
uri:
|
|
url: http://{{ vcsim }}:5000/govc_find?filter=VM
|
|
register: vms_diff
|
|
|
|
- name: Difference
|
|
debug:
|
|
var: vms_diff.json | difference(vms.json)
|