I already predicted that this was bound to happen sooner or later. It only took William Lam, aka lamw, a couple of days to enhance the work that Joseph Holland did. Joseph wrote a procedure that let’s APC’s software initiate a shutdown of the VM’s and ESXi host when a power failure occurs. Joseph’s solution included a modification of ESXi which means no VMware support.
I hinted William via twitter and he came up with a perl script that uses the API to initiate the shutdown of the VM’s and the ESXi host. This script will be run on the VIMA VM. There’s no need to change the ESXi host anymore!
ghettoShutdown.pl – This script initiates the shutdown of all VM(s) within an ESX/ESXi host excluding the virtual machine that’s monitoring the UPS device and then shutdowns the host. It accepts two commandline parameters: –sleep the duration in seconds to wait after a VM has initiated the shutdown before moving onto the next VM (shutdownVM() is non-blocking function) and –ups_vm the name of the displayName of your VM that is monotiring the UPS device [more details to come later].
upsVIShutdown.pl – This script is a wrapper which will hold the configurations of the order of hosts to shutdown. It may be used inconjunction with other UPS monitoring utility, though with our example, it’ll be placed in the apccontrol script to execute upon a power interuption.
Now head over to the VMware Communities, download the script and testdrive it! Awesome work William!
Tom says
Could someone clarify that this can work on ESX hosts as well as ESXi??
What about restarting the VMs when power comes back on?? Is this done within the shutdown/start part of VI Client??
Which version of the APC software must be on the hosts — 2.2.1 (free) or 2.2.3 (paid)??
I wasn’t sure where to put these questions…but thought I would start here.
Thank you, Tom
William says
Hi Tom,
This should work on ESX, though I only had a chance to test on ESXi so you’ll want to just verify before implementing this in production.
In terms of restarting the VM(s), you can just setup the autostart for the VM(s) that need to be powered back on when the host is back online.
This solution uses open source utility apcupsd which I’ve used in the past and works great, check out their site for the latest rpm/source.
You can always post here or you can post on the main document.
–William
Tom says
If this had come along in December I could have avoided buying APC’s paid software and network management cards, though the NMCs may hopefully prove useful in some other way.
Regardless — William Lam rocks!! I will definitely try to find a way to test this out.
Thank you, Tom