Search in sources :

Example 16 with ResourcePool

use of com.vmware.vim25.mo.ResourcePool in project vsphere-cloud-plugin by jenkinsci.

the class VSphere method createRelocateSpec.

private VirtualMachineRelocateSpec createRelocateSpec(PrintStream jLogger, boolean linkedClone, String resourcePoolName, String cluster, String datastoreName, boolean isResourcePoolRequired) throws RemoteException, MalformedURLException, VSphereException {
    VirtualMachineRelocateSpec rel = new VirtualMachineRelocateSpec();
    if (linkedClone) {
        rel.setDiskMoveType("createNewChildDiskBacking");
    } else {
        rel.setDiskMoveType("moveAllDiskBackingsAndDisallowSharing");
    }
    ClusterComputeResource clusterResource = getClusterByName(cluster);
    // probably only of interest if someone actually entered a cluster name
    if (clusterResource == null && StringUtils.isNotBlank(cluster)) {
        logMessage(jLogger, "Cluster resource " + cluster + " does not exist, root folder will be used for getting resource pool and datastore");
    }
    if (resourcePoolName != null && !resourcePoolName.isEmpty()) {
        ResourcePool resourcePool = getResourcePoolByName(resourcePoolName, clusterResource);
        if (resourcePool == null) {
            throw new VSphereNotFoundException("Resource pool", resourcePoolName);
        }
        rel.setPool(resourcePool.getMOR());
    } else if (isResourcePoolRequired) {
        throw new VSphereException("You must specify a resource  pool  when using a template");
    }
    if (datastoreName != null && !datastoreName.isEmpty()) {
        Datastore datastore = getDatastoreByName(datastoreName, clusterResource);
        if (datastore == null) {
            throw new VSphereNotFoundException("Datastore", datastoreName);
        }
        rel.setDatastore(datastore.getMOR());
    }
    return rel;
}
Also used : VirtualMachineRelocateSpec(com.vmware.vim25.VirtualMachineRelocateSpec) ClusterComputeResource(com.vmware.vim25.mo.ClusterComputeResource) Datastore(com.vmware.vim25.mo.Datastore) ResourcePool(com.vmware.vim25.mo.ResourcePool)

Aggregations

ManagedObjectReference (com.vmware.vim25.ManagedObjectReference)8 TraversalSpec (com.vmware.vim25.TraversalSpec)6 ArrayOfManagedObjectReference (com.vmware.vim25.ArrayOfManagedObjectReference)5 VirtualMachineConfigSpec (com.vmware.vim25.VirtualMachineConfigSpec)5 GetMoRef (com.vmware.photon.controller.model.adapters.vsphere.util.connection.GetMoRef)4 FinderException (com.vmware.photon.controller.model.adapters.vsphere.util.finders.FinderException)4 MethodFault (com.vmware.vim25.MethodFault)4 TaskInfo (com.vmware.vim25.TaskInfo)4 VirtualMachineDefinedProfileSpec (com.vmware.vim25.VirtualMachineDefinedProfileSpec)4 VirtualMachineRelocateSpec (com.vmware.vim25.VirtualMachineRelocateSpec)4 ArrayList (java.util.ArrayList)4 Lock (java.util.concurrent.locks.Lock)4 ReentrantLock (java.util.concurrent.locks.ReentrantLock)4 ClientUtils.findMatchingVirtualDevice (com.vmware.photon.controller.model.adapters.vsphere.ClientUtils.findMatchingVirtualDevice)3 OvfDeployer (com.vmware.photon.controller.model.adapters.vsphere.ovf.OvfDeployer)3 OvfParser (com.vmware.photon.controller.model.adapters.vsphere.ovf.OvfParser)3 OvfRetriever (com.vmware.photon.controller.model.adapters.vsphere.ovf.OvfRetriever)3 ArrayOfVirtualDevice (com.vmware.vim25.ArrayOfVirtualDevice)3 DuplicateName (com.vmware.vim25.DuplicateName)3 FileAlreadyExists (com.vmware.vim25.FileAlreadyExists)3