vSphere 5 Top 10 – HA
The second post originating from our presentation at the Dutch VMUG Event 2011 is about HA. vSphere High Availability appeared in the 2nd place of the vSphere 5 features Top 10. For the HA feature we showed how you could find out the FDM master and slaves in your cluster, and how to find the heartbeat datastore.
The FDM roles
The following script will show,for each cluster node, which FDM role it holds.
function Get-DasHostState{
param(
[PSObject]$Cluster
)
if($Cluster.GetType().Name -eq "string"){
$Cluster = Get-Cluster -Name $Cluster
}
Get-View -ViewType HostSystem -Property Name,Runtime.DasHostState | %{
New-Object PSObject -Property @{
VMHost = $_.Name
DasHostState = $_.RunTime.DasHostState.State
StateReporter = (Get-View -Id $_.RunTime.DasHostState.StateReporter -Property Name).Name
}
}
}
To call the function you can pass a clustername or the output of a Get-Cluster cmdlet. Something like this.
Get-DasHostState -Cluster Cluster1
or this
$clus = Get-Cluster -Name Cluster1 Get-DasHostState -Cluster $clus
The output looks like this
Note that there are more DasHostState values, besides master and connectedToMaster, possible. The complete list can be found in the ClusterDasFdmAvailabilityState enumeration.
And you can of course provide this functionality as a New-VIProperty.
New-VIProperty -Name "DasHostState" -ObjectType Cluster -Value {
param($cluster)
Get-View $cluster.ExtensionData.Host -Property Name,Runtime.DasHostState | %{
New-Object PSObject -Property @{
VMHost = $_.Name
DasHostState = $_.RunTime.DasHostState.State
StateReporter = (Get-View -Id $_.RunTime.DasHostState.StateReporter).Name
}
}
} -Force | Out-Null
Now you can find the FDM states with a call like this
Get-Cluster -Name London | Select -ExpandProperty DasHostState
The output will look exactly the same as the output that comes out of the Get-DasHostState function.
The heartbeat datastore
Another HA novelty in vSphere 5 is that it will now use, besides a network-based heartbeat, a datastore heartbeat, to check the presence of the nodes. To find out which of the shared datastores is used as the heartbeat datastore, you can use the following function.
function Get-DasHostState{
param(
[PSObject]$Cluster
)
if($Cluster.GetType().Name -eq "string"){
$Cluster = Get-Cluster -Name $Cluster
}
$cluster.ExtensionData.RetrieveDasAdvancedRuntimeInfo() | %{
$_.HeartbeatDatastoreInfo | %{
New-Object PSObject -Property @{
Datastore = (Get-View -Id $_.Datastore).Name
VMHosts = [string]::Join(',',($_.Hosts | %{(Get-View -Id $_).Name}))
}
}
}
}
The function can be called again with the name of a cluster or with the object returned by the Get-Cluster cmdlet.
Get-DasHostState -Cluster Cluster1
The output looks something like this.
And of course, the same functionality as a New-VIProperty.
New-VIProperty -Name HeartbeatDatastore -ObjectType Cluster -Value {
param($cluster)
$cluster.ExtensionData.RetrieveDasAdvancedRuntimeInfo() | %{
[String]::Join(',',($_.HeartbeatDatastoreInfo |
%{(Get-View -Id $_.Datastore).Name}))
}
} -Force | Out-Null
You can now use the HeartbeatDatastore property to get the datastore that is used for the heartbeat.
Get-Cluster -Name Cluster1 | Select Name, HeartbeatDatastore
Which will result in
Enjoy !





Lucd,
Thanks so much, this is useful for me.
Thanks, glad it’s useful for you.
Luc,
Thanks very much! You write so much useful stuff!
Kind regards,
Rick
Gr8′
How can we find out same information thro esxi cmd console,In previous version we cold execute ./Cli and know the pri or sec…but here in new stuff the master n the slaves.
Uttam.kr@gmail.com
Cheers