3

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
}

2 Answers 2

1

Did you go into the Properties (upper right corner) of Virtual Machine Startup and Shutdown and checked the Allow virtual machines to start and stop automatically with the system check box?

3
  • It works a little differently with an HA setup and a cluster, those settings you referred to above are machine specific. I believe most of what he needs will be in the HA configuration and rules. Say a machine vmotions, if you didn't also set it to startup there, it won't start up. Sep 7, 2011 at 19:55
  • My understanding is that all the settings under the virtual machine startup / shutdown screen are overwritten when using the HA option; I can't really test this suggestion. Are you sure it will do what is desired? Sep 7, 2011 at 20:01
  • Based upon what SpacemanSpiff pointed out, you should look through the HA settings to determine whether it has similar and/or overriding options.
    – user48838
    Sep 7, 2011 at 20:07
1

Due to the complexity of this issue I'm going to build out an entire virtual cluster consisting of two ESXi nodes and a vSphere Server. I don't think there is a ready answer to this question without testing. Thanks @SpacemanSpiff and @user48838.

2
  • Have you any updates on this? I was asking similar question but did not solved it.
    – John
    Jan 20, 2012 at 11:07
  • A shutdown script as implemented or a client from your ups vendor are the only ways to go I have found. I included the relevant bit of script in my question. Jan 20, 2012 at 13:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .