Reputation: 1561
I have a virtual machine template in VMware vCenter. I wanted to use that VM template, again and again, to create multiple virtual machines using Java API. I looked at site http://pubs.vmware.com/vsphere-50/index.jsp?topic=/com.vmware.wssdk.pg.doc_50/PG_Ch10_VM_Config.12.3.html for reference. Here I got the creation of VM with new gest os, But I wanted to create VMs using a specific template within vCenter.
Any code snippet to create VMs using VM template will be very helpful.
Upvotes: 0
Views: 1313
Reputation: 1561
Finally I found a good example https://github.com/Juniper/vijava/blob/master/src/com/vmware/vim25/mo/samples/vm/VMClone.java
In my case, I had to add ResourcePool MOR to VirtualMachineRelocateSpec object.
Upvotes: 0
Reputation: 2121
Instead of using the "CreateVM_Task" method, you'll want to use the "CloneVM_Task" method.
Here's some example code: https://communities.vmware.com/docs/DOC-10818
Upvotes: 0