VMware {code} Community

To Set configSpecification while we clone virtual machine.

Hi all,

I want to clone a VM using Java code .When i clone a VM it means it will create a new VM with same specification as of the previous VM.

My Question is "Can i do any changes in specification of clone?"

for eg: Can i change the numofcpu,memory etc while cloning .

Is such functionality available???

If yes please provide some reference code for the same.

Note: I'm using websphere SDK 4.0.



0 Kudos
1 Reply

In the clone spec, there is a config property, so you could try something like:

VirtualMachineConfigSpec configSpec = new VirtualMachineConfigSpec();
configSpec.numCPUs = 2;
configSpec.numCPUsSpecified = true;
cloneSpec.config = configSpec;

If you aren't already aware of it, check on http://www.vmware.com/support/developer/vc-sdk/visdk400pubs/ReferenceGuide/ then click on Data Object Types and search for VirtualMachineConfigSpec for all the options you have that you can change there. For that matter, if you do a search for VirtualMachineCloneSpec, you'll probably find a lot of other cool options for cloning. That link is probably the second most important tool a developer can have right after his computer.

EDIT: I just noticed you said Java. Same stuff applies, it'll probably just be something like configSpec.setNumCPUs(2);