The following is a code snippet boiled down to it's basic elements. The code executes without issue, produces no faults (and thus no exceptions) yet completely fails to alter the cpu count of the target VM. Can anyone provide some insight into what I might be doing wrong? Am I missing some critical component here?
public void modifyCpu( ManagedObjectReference vmMoRef, ManagedObjectReference hostMoRef, int cpuCount ) {
// create requisite objects
VirtualMachineConfigSpec vmcs = new VirtualMachineConfigSpec();
vmcs.setNumCPUs( cpuCount );
service.reconfigVMTask( vmMoRef, vmcs );
}
What does the returned Task object's info property say once the task
is complete?
TaskInfoState.success
Additionally, VC gives every indication (even when viewed with the vi client) that the task was succesfully executed against the specified VM. There are, of course, no details in the task log which might indicate how the VM was reconfigured but it certainly says that it was reconfigured
silly question, but does the host have enough physical cpus to satisfy
the number you are attempting to set the vm to?
--
-a
"condensing fact from the vapor of nuance"
It does. I experience the same issue with setMemoryMB so resource limitations are not the source of the problem. Also, I believe that would produce a fault.
You are quite correct, it would. Thanks for catching that. The best avenue I can offer is for me to try the same thing. For reasons too long to share here I had to rebuild my primary server today so I will need to get the new version of VMware server installed prior to me testing the code. Thank you for your patience! : )
Jon, so far no significant help, though I found another thread about changing RAM and the difference between java and C#. Not sure if it applies.
If you haven't already, it was suggested that you verify the values, post execution, via the MOB because sometimes the changes aren't immediately reflected in VC. I'll keep searching for help.
Bryan
I have indeed verified the values post execution. I've looked at the other thread and it may be applicable. If it is, it means that I'm going to have to define and set a property object of some kind myself. I'll give this a shot and post the results.
No luck so far.
I added the following:
OptionValue cpuOV = new OptionValue();
cpuOV.setKey( "NumCPUsSpecified" );
cpuOV.setValue( "true" );
vmcs.setExtraConfig( 0, cpuOV );
Hi,
I tried updating the cpu count and memory size for a VM using VI API, and was able to get through it sucessfully.
Couple of things that you can try here:
1) Are you able to change the CPU count of the target VM through VC, when connected via VI Client?
2) Below is the method from the code snippet that I used to modify the respective values. Can you try to incorporate it and see if it works for you?
public void reconfig(ManagedObjectReference vmmor) {
try{
long memMb = 512;
Integer numCPU = new Integer(2);
VirtualMachineConfigSpec cs = new VirtualMachineConfigSpec();
cs.setMemoryMB(memMb);
cs.setNumCPUs(numCPU);
ManagedObjectReference rawTask = service.reconfigVMTask(vmmor, cs);
} catch( Exception e ) {
System.out.println(e.getMessage());
e.printStackTrace();
}
}
3) I captured the SOAP response for this operation. Try to capture it at your end and compare it with the below:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<ReconfigVM_Task xmlns="urn:vim2">
<_this type="VirtualMachine">vm-1893</_this>
<spec>
<numCPUs>2</numCPUs>
<memoryMB>512</memoryMB>
</spec>
</ReconfigVM_Task>
</soapenv:Body>
</soapenv:Envelope>
Hopefully, with above information, you would be able to nail down the issue at your end.
Let me know the results that you capture at your end.
~ Sidharth
Yes, I am able to manipulate them via VC.
Your code is, essentially, identical to my own.
I'll see what I can do about capturing the SOAP response.
I suppose it's possible that we're using two different versions of the Java API....