Unsolved
This post is more than 5 years old
4 Posts
0
4474
November 5th, 2010 06:00
How to shut down VM's when using free version of VMWare
The free version of ESXi limits the function of vCentre – it removes vCentre’s ability to shut down VMs. Most UPS softwares (all that I know of) rely on the vCentre or similar to manage the VM shutdown process. If the customer pays for a full license the full functionality is available.
A workaround is to use the “run command before shutdown” function to call a script which you or the user can write which will shut down a VM.
The customer should load the Dell UPS software onto a Linux or Windows VM and then execute a script upon power failure to shut down the VMs. An example script is below (copy this into a text file and save with a .sh extension). I make no guarantees this will work for different VMWare revisions but this is just an example of how to approach the situation.
#!/bin/sh -x
# set path and date
DATE=`date +%m.%d.%G.%H%M`
PATH=$PATH:/bin:/usr/bin:/usr/sbin
date
echo "Attempting graceful shutdown of Virtual Machines on the host"
# start for loop to grab VMIDs then send power.shutdown requests using vim 3 seconds apart
for i in `vim-cmd vmsvc/getallvms | sed '1d' | awk '{print $1}'`
do
vim-cmd vmsvc/power.shutdown $i
sleep 2
done
echo "Successfully sent shutdown sequence to Virtual Machines on the host"
# finally give the virtual machines time to shutdown (using sleep) before issue a poweroff
sleep 40 # besure to give enough time to make sure ALL VMs are powered off.
poweroff
A workaround is to use the “run command before shutdown” function to call a script which you or the user can write which will shut down a VM.
The customer should load the Dell UPS software onto a Linux or Windows VM and then execute a script upon power failure to shut down the VMs. An example script is below (copy this into a text file and save with a .sh extension). I make no guarantees this will work for different VMWare revisions but this is just an example of how to approach the situation.
#!/bin/sh -x
# set path and date
DATE=`date +%m.%d.%G.%H%M`
PATH=$PATH:/bin:/usr/bin:/usr/sbin
date
echo "Attempting graceful shutdown of Virtual Machines on the host"
# start for loop to grab VMIDs then send power.shutdown requests using vim 3 seconds apart
for i in `vim-cmd vmsvc/getallvms | sed '1d' | awk '{print $1}'`
do
vim-cmd vmsvc/power.shutdown $i
sleep 2
done
echo "Successfully sent shutdown sequence to Virtual Machines on the host"
# finally give the virtual machines time to shutdown (using sleep) before issue a poweroff
sleep 40 # besure to give enough time to make sure ALL VMs are powered off.
poweroff
No Events found!


