I wrote the post explaining what Admission control is
So, if we have Slot Policy in Admission control active, how do we determine the maximum number of VMs we can run? We can calculate it manually or we can calculate it via script. This script is an example of how it can be done.
# Connect to vCenter Server
Connect-VIServer -Server "vCenterServerName" -User "username" -Password "password"
# Specify the cluster name
$clusterName = "YourClusterName"
# Get the cluster object
$cluster = Get-Cluster -Name $clusterName
# Retrieve HA settings and admission control details
$haConfig = $cluster.ExtensionData.Configuration.DasConfig
$admissionControlPolicy = $haConfig.AdmissionControlPolicy
# Check if Admission Control is enabled and using Slot Policy
if ($haConfig.Enabled -and $admissionControlPolicy -and $admissionControlPolicy.GetType().Name -eq "ClusterFailoverLevelAdmissionControlPolicy") {
Write-Host "Admission Control is using Slot Policy."
# Retrieve slot size details
$slotInfo = $cluster.ExtensionData.Summary.HAAdmissionControlSlotInfo
$cpuSlotSize = $slotInfo.CpuSlotSizeMHz
$memorySlotSize = $slotInfo.MemorySlotSizeMB
Write-Host "Slot CPU Size (MHz): $cpuSlotSize"
Write-Host "Slot Memory Size (MB): $memorySlotSize"
# Retrieve total slot capacity and used slots
$totalSlots = $slotInfo.NumSlots
$usedSlots = $slotInfo.NumUsedSlots
$availableSlots = $totalSlots - $usedSlots
Write-Host "Total Slots in Cluster: $totalSlots"
Write-Host "Used Slots: $usedSlots"
Write-Host "Available Slots: $availableSlots"
# Calculate the number of additional VMs that can be run
Write-Host "You can run $availableSlots additional VMs based on the current slot policy."
} else {
Write-Host "Admission Control is not using Slot Policy or is not enabled for this cluster."
}
# Disconnect from vCenter Server
Disconnect-VIServer -Server "vCenterServerName" -Confirm:$false
How It Works:
Connect to vCenter: The script connects to the vCenter Server and retrieves the cluster’s HA configuration and Admission Control Slot Policy details.
Slot Sizes: The script fetches the CPU and memory slot sizes, which define the resource requirements for a single “slot.”
Slot Availability: The script calculates the total number of slots in the cluster, the number of slots already in use, and the remaining available slots.
VM Calculation: Based on the available slots, the script outputs how many additional VMs can be run in the cluster.
Notes:
Replace vCenterServerName
, username
, password
, and YourClusterName
with your actual vCenter server details and cluster name.