Java Code Examples for com.vmware.vim25.VirtualMachineRelocateSpec#setPool()
The following examples show how to use
com.vmware.vim25.VirtualMachineRelocateSpec#setPool() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VmUtils.java From cs-actions with Apache License 2.0 | 6 votes |
public VirtualMachineRelocateSpec getVirtualMachineRelocateSpec(ManagedObjectReference resourcePool, ManagedObjectReference host, ManagedObjectReference dataStore, VmInputs vmInputs) { VirtualMachineRelocateSpec vmRelocateSpec = new VirtualMachineRelocateSpec(); vmRelocateSpec.setPool(resourcePool); vmRelocateSpec.setHost(host); vmRelocateSpec.setDatastore(dataStore); if (vmInputs.isThickProvision()) { vmRelocateSpec.setTransform(VirtualMachineRelocateTransformation.FLAT); } else { vmRelocateSpec.setTransform(VirtualMachineRelocateTransformation.SPARSE); } return vmRelocateSpec; }
Example 2
Source File: VirtualMachineMO.java From cloudstack with Apache License 2.0 | 6 votes |
public boolean createFullClone(String cloneName, ManagedObjectReference morFolder, ManagedObjectReference morResourcePool, ManagedObjectReference morDs) throws Exception { VirtualMachineCloneSpec cloneSpec = new VirtualMachineCloneSpec(); VirtualMachineRelocateSpec relocSpec = new VirtualMachineRelocateSpec(); cloneSpec.setLocation(relocSpec); cloneSpec.setPowerOn(false); cloneSpec.setTemplate(false); relocSpec.setDatastore(morDs); relocSpec.setPool(morResourcePool); ManagedObjectReference morTask = _context.getService().cloneVMTask(_mor, morFolder, cloneName, cloneSpec); boolean result = _context.getVimClient().waitForTask(morTask); if (result) { _context.waitForTaskProgressDone(morTask); return true; } else { s_logger.error("VMware cloneVM_Task failed due to " + TaskMO.getTaskFailureInfo(_context, morTask)); } return false; }
Example 3
Source File: VmwareProcessClient.java From primecloud-controller with GNU General Public License v2.0 | 5 votes |
protected VirtualMachineCloneSpec createCloneSpec(String computeResourceName, String resourcePoolName, String datastoreName) { VirtualMachineRelocateSpec relocateSpec = new VirtualMachineRelocateSpec(); // ComputeResource ComputeResource computeResource = vmwareClient.search(ComputeResource.class, computeResourceName); if (computeResource == null) { // ComputeResourceが見つからない場合 throw new AutoException("EPROCESS-000503", computeResourceName); } // ResourcePool if (StringUtils.isEmpty(resourcePoolName)) { resourcePoolName = "Resources"; } ResourcePool resourcePool = vmwareClient.search(computeResource, ResourcePool.class, resourcePoolName); if (resourcePool == null) { // ResourcePoolが見つからない場合 throw new AutoException("EPROCESS-000504", resourcePoolName); } relocateSpec.setPool(resourcePool.getMOR()); // Datastore if (StringUtils.isNotEmpty(datastoreName)) { // データストアが指定されている場合 Datastore datastore = vmwareClient.search(Datastore.class, datastoreName); if (datastore == null) { // データストアが見つからない場合 throw new AutoException("EPROCESS-000505", datastoreName); } relocateSpec.setDatastore(datastore.getMOR()); } VirtualMachineCloneSpec cloneSpec = new VirtualMachineCloneSpec(); cloneSpec.setLocation(relocateSpec); cloneSpec.setPowerOn(false); cloneSpec.setTemplate(false); return cloneSpec; }
Example 4
Source File: VirtualMachineMO.java From cloudstack with Apache License 2.0 | 4 votes |
public boolean createLinkedClone(String cloneName, ManagedObjectReference morBaseSnapshot, ManagedObjectReference morFolder, ManagedObjectReference morResourcePool, ManagedObjectReference morDs) throws Exception { assert (morBaseSnapshot != null); assert (morFolder != null); assert (morResourcePool != null); assert (morDs != null); VirtualDisk[] independentDisks = getAllIndependentDiskDevice(); VirtualMachineRelocateSpec rSpec = new VirtualMachineRelocateSpec(); if (independentDisks.length > 0) { List<VirtualMachineRelocateSpecDiskLocator> diskLocator = new ArrayList<VirtualMachineRelocateSpecDiskLocator>(independentDisks.length); for (int i = 0; i < independentDisks.length; i++) { VirtualMachineRelocateSpecDiskLocator loc = new VirtualMachineRelocateSpecDiskLocator(); loc.setDatastore(morDs); loc.setDiskId(independentDisks[i].getKey()); loc.setDiskMoveType(VirtualMachineRelocateDiskMoveOptions.MOVE_ALL_DISK_BACKINGS_AND_DISALLOW_SHARING.value()); diskLocator.add(loc); } rSpec.setDiskMoveType(VirtualMachineRelocateDiskMoveOptions.CREATE_NEW_CHILD_DISK_BACKING.value()); rSpec.getDisk().addAll(diskLocator); } else { rSpec.setDiskMoveType(VirtualMachineRelocateDiskMoveOptions.CREATE_NEW_CHILD_DISK_BACKING.value()); } rSpec.setPool(morResourcePool); VirtualMachineCloneSpec cloneSpec = new VirtualMachineCloneSpec(); cloneSpec.setPowerOn(false); cloneSpec.setTemplate(false); cloneSpec.setLocation(rSpec); cloneSpec.setSnapshot(morBaseSnapshot); ManagedObjectReference morTask = _context.getService().cloneVMTask(_mor, morFolder, cloneName, cloneSpec); boolean result = _context.getVimClient().waitForTask(morTask); if (result) { _context.waitForTaskProgressDone(morTask); return true; } else { s_logger.error("VMware cloneVM_Task failed due to " + TaskMO.getTaskFailureInfo(_context, morTask)); } return false; }