Automated Graceful shutdown in case of power outage
specs : vSphere 6.7 HP R5000 UPS
I am looking for a way to shutdown in a certain sequence not just mass shutdown
example vm1, vm2, vm3 and last your DC, then host, UPD etc
I have read a lot of the option, posted online .. wondering if anyone here in the community
might have a better option. Step by Step
one of the option Scripts I have found
freenasid=`vim-cmd vmsvc/getallvms | sed '1d' | awk '/Eds-FS.vmx/{print$1}'`
vmids=`vim-cmd vmsvc/getallvms | sed '1d' | awk '{print$1}'`
for vmid in $vmids
do
if [ $vmid != $freenasid ]
then
powerstate=`vim-cmd vmsvc/power.getstate $vmid | sed '1d'`
if [ "$powerstate" = "Powered on" ]
then
onvmids="$onvmids $vmid"
fi
fi
done
for vmid in $onvmids
do
vim-cmd vmsvc/power.shutdown $vmid
done
exit 0
I have heard it works, but does not solve the problem - I am looking for an answer to
the script is free for all, as the developer gave it out free to all and myself.
if someone has some experience in this that would be great
thanks in advance.