Hi,
Is it possible to add an ESXi host to an vCenter implementation automatically and change the VMs reservations memory allocation etc?
What I’m looking to achive is to have a base implemenatation that supports X users and by adding hosts expand the user base.
You can do it with PowerCLI
C:\PS>Add-VMHost 10.23.113.24 -Location Datacenter -User root -Password pass
To set CPU/memory reservations and limits you can modify this script. Currently I use it to disable limits
get-vm | %{Get-View $_.ID} | %{ if(($_.Config.CpuAllocation.Limit -ne -1) -or ($_.Config.MemoryAllocation.Limit -ne -1)){ Write "VM name: " $_.Name write " CPU limit: " $_.Config.CpuAllocation.Limit write " Memory limit: " $_.Config.MemoryAllocation.Limit $spec = new-object VMware.Vim.VirtualMachineConfigSpec; $spec.memoryAllocation = New-Object VMware.Vim.ResourceAllocationInfo; $spec.memoryAllocation.Shares = New-Object VMware.Vim.SharesInfo; $spec.memoryAllocation.Shares.Level = "normal"; $spec.memoryAllocation.Limit = -1; $spec.CPUAllocation = New-Object VMware.Vim.ResourceAllocationInfo; $spec.CpuAllocation.Shares = New-Object VMware.Vim.SharesInfo; $spec.CpuAllocation.Shares.Level = "normal"; $spec.CpuAllocation.Limit = -1; Get-View($_.ReconfigVM_Task($spec)) } }
---
MCITP: SA+VA, VCP 3/4, VMware vExpert
You can do it with PowerCLI
C:\PS>Add-VMHost 10.23.113.24 -Location Datacenter -User root -Password pass
To set CPU/memory reservations and limits you can modify this script. Currently I use it to disable limits
get-vm | %{Get-View $_.ID} | %{ if(($_.Config.CpuAllocation.Limit -ne -1) -or ($_.Config.MemoryAllocation.Limit -ne -1)){ Write "VM name: " $_.Name write " CPU limit: " $_.Config.CpuAllocation.Limit write " Memory limit: " $_.Config.MemoryAllocation.Limit $spec = new-object VMware.Vim.VirtualMachineConfigSpec; $spec.memoryAllocation = New-Object VMware.Vim.ResourceAllocationInfo; $spec.memoryAllocation.Shares = New-Object VMware.Vim.SharesInfo; $spec.memoryAllocation.Shares.Level = "normal"; $spec.memoryAllocation.Limit = -1; $spec.CPUAllocation = New-Object VMware.Vim.ResourceAllocationInfo; $spec.CpuAllocation.Shares = New-Object VMware.Vim.SharesInfo; $spec.CpuAllocation.Shares.Level = "normal"; $spec.CpuAllocation.Limit = -1; Get-View($_.ReconfigVM_Task($spec)) } }
---
MCITP: SA+VA, VCP 3/4, VMware vExpert