legioon
Enthusiast
Enthusiast

How to change vCpu reservation of VM

Jump to solution

Hi,

I'm working with vRO 7.6 and added vCenter 7.0 as endpoint to VRO. There is a workflow named "Change vCPU of VM" but I could not found any workflow about change vCPU reservation of VM. 

I've checked existing workflows and tried to create a new one about this. I can change vcpu of vm with the following code marked with blue. But I can't change vCpu reservation with the following code marked with red. I'm getting the following error : "TypeError: Cannot read property "reservation" from null" What's wrong ?

legioon_0-1622645035025.png

 

 

 

0 Kudos
1 Solution

Accepted Solutions
qc4vmware
Virtuoso
Virtuoso

You need to put everything into the configSpec and just run a single update task.  

configSpec.cpu is an instance of VcResourceAllocationInfo.  So something like

var myVcResourceAllocationInfo = new VcResourceAllocationInfo() ;

var myVcSharesInfo = new VcSharesInfo() ;

myVcSharesInfo.shares = 1000;

myVcSharesInfo.level = VcSharesLevel("normal") ;

myVcResourceAllocationInfo.shares = myVcSharesInfo;

configSpec.cpuAllocation = myVcResourceAllocaionInfo;

Then run your update.  I haven't run that code so could be some typo's but that is the gist of it.

View solution in original post

0 Kudos
2 Replies
qc4vmware
Virtuoso
Virtuoso

You need to put everything into the configSpec and just run a single update task.  

configSpec.cpu is an instance of VcResourceAllocationInfo.  So something like

var myVcResourceAllocationInfo = new VcResourceAllocationInfo() ;

var myVcSharesInfo = new VcSharesInfo() ;

myVcSharesInfo.shares = 1000;

myVcSharesInfo.level = VcSharesLevel("normal") ;

myVcResourceAllocationInfo.shares = myVcSharesInfo;

configSpec.cpuAllocation = myVcResourceAllocaionInfo;

Then run your update.  I haven't run that code so could be some typo's but that is the gist of it.

View solution in original post

0 Kudos
legioon
Enthusiast
Enthusiast

Hi qc4vmware

I fixed the issue with your direction. Thank you very much.

var spec = new VcVirtualMachineConfigSpec();
spec.cpuAllocation = new VcResourceAllocationInfo();
spec.cpuAllocation.reservation = vcpureservation;
var task = vm.reconfigVM_Task(spec);