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;
}
Aggregations