VMware Cloud Community
TimMcGee
Contributor
Contributor

complete power outage of all hosts and vms

Hello,

Our company has to have a complete Data Center power outage in a couple of weeks. Power will be down for 2 hours.

We have 5 clusters, 14 hosts and 450 virtual machines.

We want to be able to power down all virtual machines in a specific order and then power them on in a specific order.

My main question:

Can someone tell me where I can set the host or cluster settings so that when I power on the ESXi host that it will leave the virtual machines off?

We want to use a script to power on the virtual machines in a specific order.

Also, if anyone has experience with this situation and can offer me advice I would really appreciate it. Thank you!

Steps:

power off virtual machines with script in a specific order

power off ESXi 5.5 update 1 hosts

power on ESXi 5.5 update 1 hosts

power on virtual machines with script in specific order.

8 Replies
npadmani
Virtuoso
Virtuoso

Can someone tell me where I can set the host or cluster settings so that when I power on the ESXi host that it will leave the virtual machines off?

By default, after shutdown of ESXi hosts, when you power them on, they don't power ON any VMs. ESXi host do have settings to do VM startup-shutdown along with host, make sure those are not holding any VMs to start with the host.

Narendra Padmani VCIX6-DCV | VCIX7-CMA | VCI | TOGAF 9 Certified
drowland
Contributor
Contributor

Before I shutdown anything, I would disable HA on the cluster.  That way HA won't try to bring anything up.  But other than that, ESXi shouldn't try to bring anything online just because the host is powered back on.

Now, that being said, you can setup VM's to power on after a power-outage.  We use this at our remote offices which seem to have power outages quite a bit.

How To Set vSphere VMs To Power Up Automatically -- Virtualization Review

0 Kudos
linotelera
Hot Shot
Hot Shot

Hi

VM sturtup/down options is a features you could enable/diasble only if HA is disabled

pastedImage_0.png

Powercli could be a nice automation tool; it needs an extra implementation for the wake-up host procedure (you should refer to server vendor for this)

Answering to your question:

power off virtual machines with script in a specific order -> via powercli cycle to a csv file (for order)

$a = Get-Content "vms.csv"

foreach ($i in $a){

    $vm = Get-VM -Name $i

    Shutdown-VMGuest -VM $vm -Confirm: $false

   

}

power off ESXi 5.5 update 1 hosts -> via powercli (or cycle to a host list)

Stop-VMHost <ip> -Confirm

power on ESXi 5.5 update 1 hosts -> check with server vendor

power on virtual machines with script in specific order.

$a = Get-Content "vms.csv"

foreach ($i in $a){

    $vm = Get-VM -Name $i

    Start-VM $vm

}

That's all

TimMcGee
Contributor
Contributor

Thank you all for the excellent information.

I do have HA enabled, so it sounds like I should disable HA just prior to our Power outage.

Sounds like my steps should be

1.) disable HA

2) Use script to power down all VMs in specific order with power down of our vcenter server last.

3.) Power off all 14 ESXi hosts

** wait 2 hours during power outage work

4.) Power on all 14 ESXi hosts

5.) ssh to the ESXi host that contains the vcenter server and power on the virtual vcenter server

6.) User powercli to connect to vcenter server and run script to power on all vms in specific order

7.) enable HA

Couple of questions:

1.) I am new to powercli . . . does anyone have a link to the various commands I can use?

2.) Also when I ssh to a host to power on the vcenter server, what command is best to use?

Thank you for any additional help!

0 Kudos
TimMcGee
Contributor
Contributor

So, I found the below commands to use from SSH session that will work for me.

But how do I know what I can use when I am using SSH vs PowerCli vs powershell?

What's the best way for a person to learn how to manage vms, check storage, etc this way?

Thank you!

  • List inventory id of a specific virtual machine

vim-cmd vmsvc/getallvms |grep virtualmachinename


Example command: vim-cmd vmsvc/getallvms |grep testmachine

Result of command---> Below it shows the id, name of machine, storage it is on and the vmx file name.

174    testmachine                  [mystorage] testmachine/testmachine.vmx

--------------------------------------------------------------------------------------

Check the power state of the virtual machine with the command:

vim-cmd vmsvc/power.getstate <vmid>

Example command:vim-cmd vmsvc/power.getstate 174

Result of command---> commanRetrieved runtime info

Powered on

--------------------------------------------------------------------------------------

Power-off the virtual machine with the command:


vim-cmd vmsvc/power.off <174>

Example command:vim-cmd vmsvc/power.off 174

Result of command---> Powering off VM:


--------------------------------------------------------------------------------------

Power-on the virtual machine with the command:


vim-cmd vmsvc/power.on <174>

Example command:vim-cmd vmsvc/power.on 174

Result of command---> Powering on VM:

0 Kudos
drowland
Contributor
Contributor

I guess because I'm not much of a scripter, I do most things like this manually.

To power on your vCenter, you can point your vSphere client (not the Web Client) to the ESXi host containing the vCenter VM and power it on from there.

Then I typically want to manually bring up my VM's (in batches).  First, I bring up my Domain Controllers and make sure they are stable.  Then move on to the SQL servers.  Then on to the app servers.  I just don't like doing too many at once.  I don't want to impact my storage.  Typically my storage team is onboard during these types of outages.  They are asking us to slow down powering machines back on once they start seeing the filers bogging down.

linotelera
Hot Shot
Hot Shot

With powercli you could manage all these steps (except host poweron) without the use of ssh and from your workstation...

Just think is the alternative of various ssh operations in all the host.

IMHO is not necessary disable HA... while VMs will powered off ha is never called.

For further information about powercli, please refer to official doc: vSphere PowerCLI Documentation

grasshopper
Virtuoso
Virtuoso

Hi TimMcGee,

Just to clarify since there are some conflicting comments about HA.  IMHO, there is no need to disable HA for this maintenance.  However, you may consider unchecking the box for the HA setting known as "Enable Host Monitoring".

Your most important health check will be ensuring proper time sync on the ESXi hosts before powering on VMs.  This is critical after power maintenance.

Before the maintenance, you should confirm that you have access directly to the host's vSphere Client (i.e. as root) so you can power on VMs manually at the beginning (i.e. domain controllers, vCenter, VCDB, etc.).