VMware Cloud Community
Rhidian
Contributor
Contributor
Jump to solution

Add ESXi to vCenter Automatically?

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.

0 Kudos
1 Solution

Accepted Solutions
AntonVZhbankov
Immortal
Immortal
Jump to solution

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 Smiley Happy

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

http://blog.vadmin.ru

EMCCAe, HPE ASE, MCITP: SA+VA, VCP 3/4/5, VMware vExpert XO (14 stars)
VMUG Russia Leader
http://t.me/beerpanda

View solution in original post

0 Kudos
1 Reply
AntonVZhbankov
Immortal
Immortal
Jump to solution

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 Smiley Happy

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

http://blog.vadmin.ru

EMCCAe, HPE ASE, MCITP: SA+VA, VCP 3/4/5, VMware vExpert XO (14 stars)
VMUG Russia Leader
http://t.me/beerpanda
0 Kudos