I am putting together a script and documentation to manage extended power outages for my facility. I have a script that automatically shuts down my hardware cleanly.
I also have VMware HA configured on my cluster. Ideally when I power back up the cluster all the VMs should start powering up in the sequence outlined in the HA configuration. Which of the HA options do I need to enable for this behavior? This obviously isn't something I can test freely in production and I don't have a test environment for this kind of thing.
I was originally thinking the virtual machine startup / shutdown options listed under the individual servers would do the trick but those settings apparently are disabled when using a vCenter Server.
EDIT: I have the VMware HA Virtual Machine Options set to use the order I would like to use. If my understanding is correct the underlying issue is that the HA functions won't restart a VM that has effectively been manually shut down. I have also included the relevant function of my shutdown script.
Function VMWareServer
# This function will shut down all virtual machines and then a VMware environment.
{ param( [string]$Server, [string]$ID, [string]$Password )
Write-Host Connecting to $Server ..
Connect-VIServer $Server -User $ID -Password $Password
Write-Host Getting virtual machines...
$ESXSRV = Get-VMHost
Foreach ($VM in ($ESXSRV | Get-VM))
{
Write-Host Shut Down $VM
If( $shutdown )
{
$VM | Shutdown-VMGuest -Confirm:$false
}
}
If( $shutdown )
{ # The following lines shut down the remaining VMs and shut down
# the VMware servers.
Write-Host Waiting for shutdown to complete, be patient
sleep 30
$activeVMs = ($ESXSRV | Get-VM | Where { $_.PowerState -eq "poweredOn" }).Count
Write-Host Sleepy VMs: $activeVMs
If( $activeVMs > 0 )
{
Write-Host Giving remaining VMs 90 seconds to shut down...
sleep 90
}
$ESXSRV | Foreach {Get-View $_.ID} | Foreach {$_.ShutdownHost_Task($TRUE)}
}
Disconnect-VIServer -Server * -Force -Confirm:$False
}