PowerCLI: Listing Cluster Primary HA Nodes

Following my recent post on Slot Sizes and pointing to Duncan’s great HA Deepdive article I came across a great script today on Hypervisor.fr, he has been creating some great PowerCLI scripts recently and also sent me some fantastic additions to my Daily Report, all of which will be added in the next version which is due out any day now.

Just to set the background I will steel a little of Duncan’s post but please make sure you read his full article and then re-read it until it is ingrained in your brain, this guy knows his stuff.  Duncan’s post reads…

A VMware HA Cluster consists of nodes, primary and secondary nodes. Primary nodes hold cluster settings and all “node states” which are synchronized between primaries. Node states hold for instance resource usage information. In case that vCenter is not available the primary nodes will have a rough estimate of the resource occupation and can take this into account when a fail-over needs to occur. Secondary nodes send their state info to the primary nodes.

Nodes send a heartbeat to each other, which is the mechanism to detect possible outages. Primary nodes send heartbeats to primary nodes only. Secondary nodes send their heartbeats to primary nodes only. Nodes send out these heartbeats every second by default. However this is a changeable value: das.failuredetectioninterval. (Advanced Settings on your HA-Cluster)

The first 5 hosts that join the VMware HA cluster are automatically selected as primary nodes.  All the others are automatically selected as secondary nodes. When you do a reconfigure for HA the primary nodes and secondary nodes are selected again, this is at random. The vCenter client does not show which host is a primary and which is not.

A question was raised on the PowerCLI communities before the days of vSphere asking if you could get the information with regards to which of the hosts were primary for each cluster, a suggestion was made by The PowerCLI master himself LucD to grab the information via a putty session and then present it back onto PowerCLI to use the data.

Now, with vSphere and the updated SDK it would seam that this information is available, so I have modified the script found on Hypervisor.fr to list each cluster and the primary nodes within these cluster as seen in the example below:


This can be achieved with a simple (well kinda) script which will check that the cluster has HA enabled and that the vCenter server is Version 4 (vSphere) and then present the results for each cluster:

If ((Get-View ServiceInstance).Content.About.Version-ge 4.0.0){
Get-View -ViewType ClusterComputeResource |Where {$_.Configuration.DasConfig.Enabled-eq $true} | Select Name,  @{N=PrimaryHosts;E={[string]::join( & ,(($_.RetrieveDasAdvancedRuntimeInfo()).DasHostInfo.PrimaryHosts))}}
Write Sorry this is only available to a V4 vCenter Host

Or if the perl toolkit is your cuppa tea then check out this version from William Lam (Perl Ninja)

I have also added this to a VESI PowerPack which I am in the middle of creating and will publish soon, as you can see from the below:


5 thoughts on “PowerCLI: Listing Cluster Primary HA Nodes”

  1. My results differ using your script vs. the console command:
    ‘cat /var/log/vmware/aam/aam_config_util_listnodes.log

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.