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