VMware {code} Community
sanketm25
Contributor
Contributor

To Enable Hot add memory/Hot plug CPU

Hi all,

I need to enable hot add memory/cpu to reconfigure the VM when it is running.

I'm able to do it by changing the setting of the VM (Edit Setting ->Option->Advanced->Enable /Disable Memory/Cpu hot add).

But i want to enable the Memory/cpu hot add with the help of WorkFlow/Java Code.Any reference code will be helpfull.

Note: I'm using vSphere webservice SDK to develop my application.

Thanks All,

Sanket

0 Kudos
5 Replies
njain
Expert
Expert

Hi,

You can use "cpuHotAddEnabled" and "memoryHotAddEnabled" properties, set them in VirtualMachineConfigSpec and reconfigure the VM using ReconfigVM_Task method. Please note, these properties are available since 4.0 and the VM needs to be powered off while reconfiguring the VM.

VirtualMachineConfigSpec vmConfigSpec = new VirtualMachineConfigSpec();

vmConfigSpec.setMemoryHotAddEnabled(true);

vmConfigSpec.setCpuHotAddEnabled(true);

ManagedObjectReference task = service.reconfigVMTask(vmMor, vmConfigSpec);

Hope this helps.

Neha

sanketm25
Contributor
Contributor

Hi Neha

Thanks for your reply, But no such methods_ "vmConfigSpec.setMemoryHotAddEnabled(true);"_ are available in the VirtualMachineConfigSpec class.

I'm using "vi-sdk-4.0.0-161137 " webservice SDK. So can you suggest me which version of SDK should i use so that my requirement will be fullfilled.

Thanks ,

Sanket.

0 Kudos
daniellynn
Enthusiast
Enthusiast

Are you using Java or C#? If it's C#, it'll look like this:

VirtualMachineConfigSpec myConfig = new VirtualMachineConfigSpec();

myConfig.memoryHotAddEnabled = true;

myConfig.memoryHotAddEnabledSpecified = true;

The "Specified" property is important. It won't work without that.

sanketm25
Contributor
Contributor

Hi Neha,Daneil,

Thanks a lot for your replies.It helped me to resolve my issue.

Thanks ,

Sanket.

0 Kudos
pvpkiran
Contributor
Contributor

Hi,

  can this be done using vcloud director API's ?

The reason i am asking is, in vchs(vcloud air) we will not have access to vcenter/vsphere but only to Vcloud director.

Thanks

Panikiran

0 Kudos