I recently assisted with a major hardware life cycle. We Migrated from Dell 1950’s to IBM BladeCenter H with H21XM blades. While the processors were comparable the RAM upgrade was tremendous. Going from 8/16GB to 32GB. This increase enabled much greater consolidation ratios, and with such we found ourselves with an abundance of hardware. After shutting down several hosts, and collapsing a few clusters we still weren’t driving our infrastructure. Shortly thereafter we realized that the resource limitations we had previously set. Were no longer necessary, and in some cases where decreasing performance (memory ballooning). A few minutes with the VI Toolkit for Windows, and we were screaming again!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# we'll use the same object to remove the limit $ResourceAllocationInfo = New-Object VMware.Vim.ResourceAllocationInfo $ResourceAllocationInfo.Limit = -1 # Get the Managed object for each VM Foreach ($VM in get-vm | get-view) { # Create a fresh VirtualMachineConfigSpec $VirtualMachineConfigSpec = New-object VMware.Vim.VirtualMachineConfigSpec $i = 0 # If the CPU Allocation is not unlimited add CPU to our spec. IF ($VM.ResourceConfig.CpuAllocation.Limit -ne -1) { $VirtualMachineConfigSpec.cpuAllocation = $ResourceAllocationIn $i++ } # If the Memory Allocation is not unlimited add Memory to our spec. IF ($VM.ResourceConfig.MemoryAllocation.Limit -ne -1) { $VirtualMachineConfigSpec.memoryAllocation = $ResourceAllocationInfo $i++ } # If $I is gt 0 then we have a VM to fix... Trigger the reconfig task. IF ($I -gt 0) { write-verbose "Removing limits on $($VM.Name)" [void]$VM.ReconfigVM_Task($VirtualMachineConfigSpec) } } |
Now all that is left is for Andrew to translate this to perl/rCLI.
~Glenn
Thanks for this script. It was useful to me in a customer environment where they had been victims of the 3.5 bug that created 512MB limits on templates. They had about 100 VM’s that all had 512MB limits. They were wondering about why vSphere hadn’t improved performance…. thanks to two minutes with your script, it has. 🙂
Cheers!
I may well write a note on my blog about this one.
Glad it helped!
Another helpful script Glenn – everytime I look for script help your site pops up and does the trick. I needed a way round a known bug with Get-VMResouceConfiguration and your Get-View version works a treat.
Hi,
line 12 should be:
$VirtualMachineConfigSpec.cpuAllocation = $ResourceAllocationInfo
Regards,
David
Good catch thanks!