Create VM in vSphere using template but without Resource Pool in java -
i want clone vm in vmware using template.
currently able clone using hostsystem, resource pool , datastore. want skip resource pool , need create vm in datastore, such data stores present in storagepod(storage clusters).
i using storage pod instead resource pool.
curent code:
virtualmachine vminstace = (virtualmachine) new inventorynavigator(rootfolder) .searchmanagedentity("virtualmachine","template name"); hostsystem hostsystem = (hostsystem) new inventorynavigator(rootfolder).searchmanagedentity("hostsystem","host name"); resourcepool resourcepool = (resourcepool) new inventorynavigator(rootfolder) .searchmanagedentity("resourcepool","resource pool name"); virtualmachinerelocatespec relocatespec = new virtualmachinerelocatespec(); virtualmachineclonespec clonespec = new virtualmachineclonespec(); datastore[] datastore = vminstace.getdatastores(); relocatespec.setdatastore(datastore[0].getmor()); relocatespec.sethost(hostsystem.getmor()); relocatespec.setpool(resourcepool.getmor()); clonespec.setpoweron(true); clonespec.setlocation(relocatespec); task task = vminstace.clonevm_task((folder) vminstace.getparent(), "testvm name", clonespec);
Comments
Post a Comment