I am curious how Aria Automation picks the host and storage. I am currently using vRA for all of our windows server builds. We have used it for over 2 years now.
For other projects I am looking to write a powershell script to do similar to vRA. I have not writen the storage script but it will be similar to belows host selection script.
For host I figured I would use Powershell to get all the hosts within a cluster and then select the top 10 hosts w/ free memory. Then from those 10 find the host that has the least amount of committed CPU.
Do you think this is pretty much what vRA is doing in the background? If yes please tell me you agree. If no then please tell me what you think is happening.
My best host script....
$compute = "yourVmwareHostClusterNameHere"
$hosts = Get-VMHost -Location $compute
##get top 10 hosts with Memory free
$freeMemory = $hosts | Select-Object Name, CpuTotalMhz, CpuUsageMhz,
@{N='freeMemory';E={[math]::Round($_.MemoryTotalGB - $_.MemoryUsageGB)}}
$top10freeMemoryHosts = $freeMemory | Sort-Object -Property "freeMemory" -Descending | select -First 10
##from these top hosts with free memory we will now select the host with the least amount of committed CPU to build on.
$freeCPU = $top10freeMemoryHosts | Select-Object Name, freeMemory,
@{N='CpuTotalGHz'; E={[math]::Round($_.CpuTotalMhz/1000, 2)}},
@{N='CpuUsageGHz'; E={[math]::Round($_.CpuUsageMhz/1000, 2)}},
@{N='CpuFreeGHz'; E={[math]::Round(($_.CpuTotalMhz - $_.CpuUsageMhz)/1000, 2)}}
$sortFreeCpu = $freeCPU | Select-Object Name, freeMemory,CpuFreeGhz | Sort-Object -Property CpuFreeGhz -Descending
$bestHost = $sortfreeCPU | select -First 1
$usehost = $bestHost.name
-------------------------------------------