mirror of https://github.com/ansible/ansible.git
VMware: Update vmware_guest_powerstate (#57000)
* Updated documentation * Updated testcases * Updated example * Updated logic * Provided option to specify task name, task description, task enable status etc. Fixes: #56987 Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>pull/57268/head
parent
7364e79c0d
commit
c8eda7773e
@ -1,52 +0,0 @@
|
||||
# Test code for the vmware_guest_powerstate module.
|
||||
# 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)
|
||||
|
||||
- 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
|
||||
vmware_guest_powerstate:
|
||||
validate_certs: False
|
||||
hostname: "{{ vcsim }}"
|
||||
username: "{{ vcsim_instance['json']['username'] }}"
|
||||
password: "{{ vcsim_instance['json']['password'] }}"
|
||||
name: "{{ item|basename }}"
|
||||
state: powered-off
|
||||
folder: "{{ item|dirname }}"
|
||||
with_items: "{{ virtual_machines }}"
|
||||
register: poweroff_d1_c1_f0
|
||||
|
||||
- debug: var=poweroff_d1_c1_f0
|
||||
|
||||
# vcsim (v0.18.0) VMs are spawned PoweredOn
|
||||
- name: make sure changes were made
|
||||
assert:
|
||||
that:
|
||||
- "poweroff_d1_c1_f0.results|map(attribute='changed')|unique|list == [True]"
|
@ -1,58 +0,0 @@
|
||||
# Test code for the vmware_guest_powerstate module.
|
||||
# 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)
|
||||
|
||||
- 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
|
||||
# Sending "-folders 1" to vcsim nests the datacenter under
|
||||
# the folder so that the path prefix is no longer /vm
|
||||
#
|
||||
# /F0/DC0/vm/F0/DC0_H0_VM0
|
||||
|
||||
- name: set state to poweredoff on all VMs
|
||||
vmware_guest_powerstate:
|
||||
validate_certs: False
|
||||
hostname: "{{ vcsim }}"
|
||||
username: "{{ vcsim_instance['json']['username'] }}"
|
||||
password: "{{ vcsim_instance['json']['password'] }}"
|
||||
name: "{{ item|basename }}"
|
||||
state: powered-off
|
||||
folder: "{{ item|dirname }}"
|
||||
with_items: "{{ vmlist['json'] }}"
|
||||
register: poweroff_d1_c1_f1
|
||||
|
||||
- debug: var=poweroff_d1_c1_f1
|
||||
|
||||
# vcsim (v0.18.0) VMs are spawned PoweredOn
|
||||
- name: make sure changes were made
|
||||
assert:
|
||||
that:
|
||||
- "poweroff_d1_c1_f1.results|map(attribute='changed')|unique|list == [True]"
|
Loading…
Reference in New Issue