Hello, I was wondering if anyone has been faced with the task of shutting down an entire deployment of vSphere in an automated way before? Basically I have an instance of vCenter with a 2 node ESXi cluster. DRS and HA are enabled on this cluster. So it is designed to run 24/7 in the event of a host failure as well as balance resources. My issue is that I only have about 40 min of battery power in the instance of a prolonged power outage. I would like to be able to script the automatic shutdown of all VMs and both hosts. I've seen plenty of posts about scripting the process of entering maintenance mode and evacuating VMs, but this is a little different. I need to shut down all running VMs gracefully, then shut down each host. Preferably in a way that doesn't use PowerCLI as vCenter won't be available either. PowerCLI also requires there be a system up and running to run a PowerCLI session. In this case, there won't be.
Our UPS/storage deployment actually has a mechanism for reaching out to devices via SSH and running commands in the event of a low battery situation. I was thinking there might be a special combination of commands that I could run directly from a host SSH session?
For example here is the command I have used from SSH to put a host into maintenance mode:
esxcli system maintenanceMode set -e true -t 0
Here is a shut down command:
esxcli system shutdown poweroff -d 10 -r "Shell initiated system shutdown"
I know you can use the "vim-cmd vmsvc/power.on <vmid>" command to power on VMs. But you need to know the ID.
Seems like I have a few of the pieces, but I am not quite there yet.
Regards,
Adam Tyler