VMware Cloud Community
andreaspa
Hot Shot
Hot Shot

Get-Cluster with percentage based reservation in vSphere 5

I'm building a script that gets information about the HA level, but it seems that the new percentage setting is messing up the Get-Cluster output.

PowerCLI E:\> Get-Cluster | fl



HATotalSlots              :

HAUsedSlots               :

HAAvailableSlots          :
HASlotCpuMHz              :
HASlotMemoryMb            :
HASlotNumVCpus            :
ParentId                  : Folder-group-h4
ParentFolder              : host
HAEnabled                 : True
HAAdmissionControlEnabled : True
HAFailoverLevel           : 0
HARestartPriority         : Medium
HAIsolationResponse       : PowerOff
VMSwapfilePolicy          : WithVM
DrsEnabled                : True
DrsMode                   : FullyAutomated
DrsAutomationLevel        : FullyAutomated
Name                      : cluster01.vmware.local
CustomFields              : {[VEEAM_Business_Unit, ], [VEEAM_Department, ], [VE
                            EAM_Purpose, ]}
ExtensionData             : VMware.Vim.ClusterComputeResource
Id                        : ClusterComputeResource-domain-c7
Uid                       : /VIServer=@vcenter1.vmware.local:443/Cluster=Cluste
                            rComputeResource-domain-c7/

Is there any way to get the slot size and the percentage levels by using Get-Cluster, or do I need to find another way to do this?

0 Kudos
8 Replies
LucD
Leadership
Leadership

Are these properties also missing when you do

Get-Cluster | Select *


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

0 Kudos
RvdNieuwendijk
Leadership
Leadership

I don't know an easy way to get the cluster HA slot size. But you can get the HA percentages with:

Get-Cluster | Select-Object -Property Name,
@{N="CpuFailoverResourcesPercentage";E={$_.ExtensionData.Configuration.DasConfig.AdmissionControlPolicy.CpuFailoverResourcesPercent}},
@{N="MemoryFailoverResourcesPercentage";E={$_.ExtensionData.Configuration.DasConfig.AdmissionControlPolicy.MemoryFailoverResourcesPercent}}

Regards, Robert

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
0 Kudos
andreaspa
Hot Shot
Hot Shot

I actually thinkg I figured it out.

PowerCLI E:\> $tmp = Get-Cluster

PowerCLI E:\> $tmp.ExtensionData.Configuration.DasConfig.AdmissionControlPolicy

CpuFailoverResource MemoryFailoverResou DynamicType         DynamicProperty
           sPercent         rcesPercent
------------------- ------------------- -----------         ---------------
                 30                  30

It doesn't give me the slot info I want to see, but I can extract the memory settings..

LucD;

PowerCLI E:\> Get-Cluster | Select *


HATotalSlots              :
HAUsedSlots               :
HAAvailableSlots          :
HASlotCpuMHz              :
HASlotMemoryMb            :
HASlotNumVCpus            :
ParentId                  : Folder-group-h4
ParentFolder              : host
HAEnabled                 : True
HAAdmissionControlEnabled : True
HAFailoverLevel           : 0
HARestartPriority         : Medium
HAIsolationResponse       : PowerOff
VMSwapfilePolicy          : WithVM
DrsEnabled                : True
DrsMode                   : FullyAutomated
DrsAutomationLevel        : FullyAutomated
Name                      : cluster01.vmware.local
CustomFields              : {[VEEAM_Business_Unit, ], [VEEAM_Department, ], [VE
                            EAM_Purpose, ]}
ExtensionData             : VMware.Vim.ClusterComputeResource
Id                        : ClusterComputeResource-domain-c7
Uid                       : /VIServer=@vcenter1.vmware.local:443/Cluster=Cluste
                            rComputeResource-domain-c7/

0 Kudos
andreaspa
Hot Shot
Hot Shot

This quick and dirty script should list the levels regardless of the reservations being in percent or hosts:


$cluster = Get-Cluster

write-host -Foregroundcolor Cyan "HA Failover settings"
# check if cluster uses percentage or not..
If($cluster.HAAdmissionControlEnabled -eq "True" -and $cluster.HAFailOverLevel -eq "0") {
  Write-Host "CPU:" $cluster.ExtensionData.Configuration.DasConfig.AdmissionControlPolicy.CpuFailoverResourcesPercent"%"
  Write-Host "MEM:" $cluster.ExtensionData.Configuration.DasConfig.AdmissionControlPolicy.MemoryFailoverResourcesPercent"%"
} else {
  Write-Host "Host reservations:" $cluster.HAFailOverLevel
}

Enjoy, if anyone wondered about it Smiley Happy

Too bad we can't get the slot sizes any more.. 😕

0 Kudos
RvdNieuwendijk
Leadership
Leadership

Your script will only work if you have only one cluster. Smiley Wink

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
0 Kudos
LucD
Leadership
Leadership

Are these the sizes you are looking for ?

$Cluster.ExtensionData.RetrieveDasAdvancedRuntimeInfo() |     
Select -ExpandProperty SlotInfo 


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

0 Kudos
andreaspa
Hot Shot
Hot Shot

True that Smiley Wink

Here's the improved one:

$clusters = Get-Cluster

write-host -Foregroundcolor Cyan "HA Failover settings"
# check if cluster uses percentage or not..
foreach($cluster in $clusters) {
  Write-Host "Cluster: " $cluster.Name
  If($cluster.HAAdmissionControlEnabled -eq "True" -and $cluster.HAFailOverLevel -eq "0") {
    Write-Host " - CPU:" $cluster.ExtensionData.Configuration.DasConfig.AdmissionControlPolicy.CpuFailoverResourcesPercent"%"
    Write-Host " - MEM:" $cluster.ExtensionData.Configuration.DasConfig.AdmissionControlPolicy.MemoryFailoverResourcesPercent"%"
  } else {
    Write-Host " - Host reservations:" $cluster.HAFailOverLevel
  }
}

This is however just a part of my script, it currently is about 250 lines and counting. Thanks for the input!


0 Kudos
andreaspa
Hot Shot
Hot Shot

LucD wrote:

Are these the sizes you are looking for ?

$Cluster.ExtensionData.RetrieveDasAdvancedRuntimeInfo() |     
Select -ExpandProperty SlotInfo 

I'm afraid that doesn't help:

Select-Object : Property "SlotInfo" cannot be found.
At line:1 char:70
+     $Cluster.ExtensionData.RetrieveDasAdvancedRuntimeInfo() |  Select <<<<  -ExpandProperty SlotInfo
    + CategoryInfo          : InvalidArgument: (VMware.Vim.ClusterDasAdvancedRuntimeInfo:PSObject) [Select-Object], PSArgumentException
    + FullyQualifiedErrorId : ExpandPropertyNotFound,Microsoft.PowerShell.Commands.SelectObjectCommand

I tried getting more info, and this is all I found on that call:

PowerCLI E:\> $Cluster.ExtensionData.RetrieveDasAdvancedRuntimeInfo() | Select *
| fl


DasHostInfo            :
HeartbeatDatastoreInfo : {VMware.Vim.DasHeartbeatDatastoreInfo, VMware.Vim.DasH
                         eartbeatDatastoreInfo}
DynamicType            :
DynamicProperty        :

Seems they have hidden it well!

If I change the admission control policy to 1 host failure tolerated instead of the 30% CPU/MEM reservation I had before, I can see the info:

PowerCLI E:\> $Cluster.ExtensionData.RetrieveDasAdvancedRuntimeInfo() | Select *
| fl


SlotInfo               : VMware.Vim.ClusterDasFailoverLevelAdvancedRuntimeInfoS
                         lotInfo
TotalSlots             : 488
UsedSlots              : 228
UnreservedSlots        : 211
TotalVms               : 228
TotalHosts             : 10
TotalGoodHosts         : 10
HostSlots              : {VMware.Vim.ClusterDasFailoverLevelAdvancedRuntimeInfo
                         HostSlots, VMware.Vim.ClusterDasFailoverLevelAdvancedR
                         untimeInfoHostSlots, VMware.Vim.ClusterDasFailoverLeve
                         lAdvancedRuntimeInfoHostSlots, VMware.Vim.ClusterDasFa
                         iloverLevelAdvancedRuntimeInfoHostSlots...}
DasHostInfo            :
HeartbeatDatastoreInfo : {VMware.Vim.DasHeartbeatDatastoreInfo, VMware.Vim.DasH
                         eartbeatDatastoreInfo}
DynamicType            :
DynamicProperty        :

So it seems that using percentage limits the information you can get from PowerCLI, perhaps intentionally or perhaps a bug..

0 Kudos