From 4f84b839bc4fda03a6412e7328895a41d08ac1b6 Mon Sep 17 00:00:00 2001 From: Tino Vazquez Date: Tue, 3 Apr 2012 13:35:04 +0200 Subject: [PATCH] Add shutdown wait for VMware (cherry picked from commit d0be26fac3eb9cd5dcb708efaa4a7c8154ff5078) --- src/vmm_mad/remotes/vmware/shutdown | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/vmm_mad/remotes/vmware/shutdown b/src/vmm_mad/remotes/vmware/shutdown index b154da7dd9..315acff535 100755 --- a/src/vmm_mad/remotes/vmware/shutdown +++ b/src/vmm_mad/remotes/vmware/shutdown @@ -29,9 +29,26 @@ $: << File.dirname(__FILE__) require 'vmware_driver' +#------------------------------------------------------------------------------ +# Wait the VM to shutdown TIMEOUT (xPOLL_INTERVAL) seconds. +# Set to ~10min +#------------------------------------------------------------------------------ +POLL_INTERVAL=2 +TIMEOUT=300 + deploy_id = ARGV[0] host = ARGV[1] vmware_drv = VMwareDriver.new(host) vmware_drv.shutdown(deploy_id) + +count=0 +while (vmware_drv.poll(deploy_id).match(/STATE=(.*)/)[1] != "d") do + sleep POLL_INTERVAL + if count > TIMEOUT then + OpenNebula.log_debug("Timeout reached and VM #{deploy_id} is still alive.") + exit -1 + end + count+=POLL_INTERVAL +end