use of com.linbit.linstor.api.model.ResourceDefinitionCloneStarted in project cloudstack by apache.
the class LinstorPrimaryDataStoreDriverImpl method cloneResource.
private String cloneResource(long csCloneId, VolumeInfo volumeInfo, StoragePoolVO storagePoolVO) {
// get the cached template on this storage
VMTemplateStoragePoolVO tmplPoolRef = _vmTemplatePoolDao.findByPoolTemplate(storagePoolVO.getId(), csCloneId, null);
if (tmplPoolRef != null) {
final String cloneRes = LinstorUtil.RSC_PREFIX + tmplPoolRef.getLocalDownloadPath();
final String rscName = LinstorUtil.RSC_PREFIX + volumeInfo.getUuid();
final DevelopersApi linstorApi = LinstorUtil.getLinstorAPI(storagePoolVO.getHostAddress());
try {
s_logger.debug("Clone resource definition " + cloneRes + " to " + rscName);
ResourceDefinitionCloneRequest cloneRequest = new ResourceDefinitionCloneRequest();
cloneRequest.setName(rscName);
ResourceDefinitionCloneStarted cloneStarted = linstorApi.resourceDefinitionClone(cloneRes, cloneRequest);
checkLinstorAnswersThrow(cloneStarted.getMessages());
if (!CloneWaiter.waitFor(linstorApi, cloneStarted)) {
throw new CloudRuntimeException("Clone for resource " + rscName + " failed.");
}
return getDeviceName(linstorApi, rscName);
} catch (ApiException apiEx) {
s_logger.error("Linstor: ApiEx - " + apiEx.getMessage());
throw new CloudRuntimeException(apiEx.getBestMessage(), apiEx);
}
} else {
throw new CloudRuntimeException("Unable to find Linstor resource for the following template data-object ID: " + csCloneId);
}
}
Aggregations