VMware Cloud Community
djurgens
Contributor
Contributor

Using vSphere Automation Java SDK, unable to set CPU or Memory Limits, Reservation or Shares

I was previously using VIJAVA. I'm trying to use vSphere Automation Java SDK to do everything I did before. So we clone our VMs from templates then configure them according to specifications. I have coded the CPU and Memory UpdateSpecs to specify the details but I can't seem to figure out how to set CPU Reservation, Limit, and Share and also the same for Memory.

I've gone through the SDK and can't seem to find how to make those changes. I might be able to use the VIM API to make these changes with a VirtualMachineConfigSpec but was hoping to do it with a single API. Does anyone have a similar issue and a possible solution?
Thanks.

0 Kudos
2 Replies
lamw
Community Manager
Community Manager

FYI - VIJAVA is NOT an official VMware SDK

All VM reconfigurations does use a single API call, which is the ReconfigVM_Task() method and that accepts a spec that contains the changes you wish to make (add, update or remove). 

For CPU RSL (Reservation, Shares & Limits), refer to cpuAllocation property and for MEM RSL, refer to memoryAllocation property r-public/bf660c0a-f060-46e8-a94d-4b5e6ffc77ad/208bc706-e281-49b6-a0ce-b402ec19ef82/SDK/vsphere-ws/docs/ReferenceGuide/vim.vm.ConfigSpec.html#field_detail

If you're new to vSphere API, a VERY hand tool that is available is Code Capture built right into vSphere UI (HTML5) Client. You enable that in admin settings and you can record the operation (applies only to vSphere SOAP API) and you can see the objects/method used

 

djurgens
Contributor
Contributor

Thanks for your reply, I see that I can do some of the same things as I did before if I use the vimPort to access a limited number of methods like ReconfigVM_Task. Some not all. For this question I did get Limits, Reservations and Shares to work. I have other questions, but guess that will be another post. Thanks for your quick reply, it helped confirm what I suspected. 

0 Kudos