VMware Cloud Community
burdweiser
Enthusiast
Enthusiast

Pull host roles from vCenter 4.1

So in vCenter 4.1 there is a "cluster operational status" listed under the cluster tab. If you have any issues with HA, the hosts are listed and it shows the role of that host (primary or secondary). Prior to 4.1, I had to go into the CLI of a host to cat the logs and see the roles of the hosts. Now it looks like this information may be stored in the DB for vCenter. Since this information can now be read by vCenter, is there a way to create a script to read the roles of the host even if there is not an issue with HA?

- Burdweiser

Reply
0 Kudos
1 Reply
LucD
Leadership
Leadership

When you are using PowerCLI 4.1 you can do something like this

$clusterName = <clustername>
 
Get-Cluster $clusterName | %{ 
        $info = $_.ExtensionData.RetrieveDasAdvancedRuntimeInfo() 
        $_ | Get-VMHost | %{ 
                $row = "" | Select Name,Role 
                $row.Name = $_.Name 
                $row.Role = &{if($info.DasHostInfo.PrimaryHosts -contains ($_.Name.Split('.')[0])){"primary"}else{"secondary"}}
                $report += $row 
        } 
} 
$report

____________

Blog: LucD notes

Twitter: lucd22


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos