Use virt module to abort if vms are running

Added check to call shutdown a second time, but at the same time
utilize the collected fact to help ensure that virtual machines
have been stopped

If the ansible module indicates that it had to send a shutdown
command after sixty seconds, then the upgrade is aborted and a
message is reported directing the user to shut down their virtual
machines and retry.

Change-Id: I27f32765cc08197e91a2fd740d18289ee0fd342e
This commit is contained in:
Julia Kreger 2014-12-10 16:27:32 -05:00 committed by stephane
parent 35fd0a5fa7
commit dbce4d3afc
1 changed files with 14 additions and 0 deletions

View File

@ -40,3 +40,17 @@
when: use_nova_powercontrol is defined
- name: Pausing for 60 seconds to give VMs time to stop.
pause: seconds=60
- name: Collect list of VMs
sudo: yes
virt: command=list_vms
register: virtual_machines
when: use_nova_powercontrol is not defined
- name: Issue graceful shutdowns
sudo: yes
virt: state=shutdown name={{item}}
when: use_nova_powercontrol is not defined
with_items: virtual_machines.list_vms
register: test_from_second_shutdown_call
- name: "Fail if virtual machines were still running"
fail: msg="If the ansible playbook has failed and exited at this point, virtual machines were still running on the compute node after sixty seconds passed from the shutdown commands having been initiated. Please retry and/or manually ensure that virtual machines on the nodes to be updated have been shut down."
when: use_nova_powercontrol is not defined and test_from_second_shutdown_call.changed == true