private void verifyCopyCmdAnswer(CopyCmdAnswer copyCmdAnswer, DataObject dataObject) { if (copyCmdAnswer == null) { throw new CloudRuntimeException("Unable to create a volume from a " + dataObject.getType().toString().toLowerCase() + " (copyCmdAnswer == null)"); } if (copyCmdAnswer.getResult()) { return; } String details = copyCmdAnswer.getDetails(); if (StringUtils.isEmpty(details)) { throw new CloudRuntimeException("Unable to create a volume from a " + dataObject.getType().toString().toLowerCase() + " (no error details specified)"); } throw new CloudRuntimeException(details); }
@Override public void copyAsync(DataObject srcData, DataObject destData, Host destHost, AsyncCompletionCallback<CopyCommandResult> callback) { if (srcData.getDataStore() == null || destData.getDataStore() == null) { throw new CloudRuntimeException("can't find data store"); } if (srcData.getDataStore().getDriver().canCopy(srcData, destData)) { srcData.getDataStore().getDriver().copyAsync(srcData, destData, callback); return; } else if (destData.getDataStore().getDriver().canCopy(srcData, destData)) { destData.getDataStore().getDriver().copyAsync(srcData, destData, callback); return; } DataMotionStrategy strategy = storageStrategyFactory.getDataMotionStrategy(srcData, destData); if (strategy == null) { // OfflineVmware volume migration // Cleanup volumes from target and reset the state of volume at source cleanUpVolumesForFailedMigrations(srcData, destData); throw new CloudRuntimeException("Can't find strategy to move data. " + "Source: " + srcData.getType().name() + " '" + srcData.getUuid() + ", Destination: " + destData.getType().name() + " '" + destData.getUuid() + "'"); } strategy.copyAsync(srcData, destData, destHost, callback); }
@Override public String createEntityExtractUrl(DataStore store, String installPath, ImageFormat format, DataObject dataObject) { SwiftTO swiftTO = (SwiftTO)store.getTO(); String tempKey = UUID.randomUUID().toString(); boolean result = SwiftUtil.setTempKey(swiftTO, tempKey); if (!result) { String errMsg = "Unable to set Temp-Key: " + tempKey; s_logger.error(errMsg); throw new CloudRuntimeException(errMsg); } String containerName = SwiftUtil.getContainerName(dataObject.getType().toString(), dataObject.getId()); String objectName = installPath.split("\\/")[1]; // Get extract url expiration interval set in global configuration (in seconds) int urlExpirationInterval = Integer.parseInt(_configDao.getValue(Config.ExtractURLExpirationInterval.toString())); URL swiftUrl = SwiftUtil.generateTempUrl(swiftTO, containerName, objectName, tempKey, urlExpirationInterval); if (swiftUrl != null) { s_logger.debug("Swift temp-url: " + swiftUrl.toString()); return swiftUrl.toString(); } throw new CloudRuntimeException("Unable to create extraction URL"); }
@Override public void deleteAsync(DataStore dataStore, DataObject data, AsyncCompletionCallback<CommandResult> callback) { CommandResult result = new CommandResult(); try { DeleteCommand cmd = new DeleteCommand(data.getTO()); EndPoint ep = _epSelector.select(data); Answer answer = null; if (ep == null) { String errMsg = "No remote endpoint to send command, check if host or ssvm is down?"; s_logger.error(errMsg); answer = new Answer(cmd, false, errMsg); } else { answer = ep.sendMessage(cmd); } if (answer != null && !answer.getResult()) { result.setResult(answer.getDetails()); } } catch (Exception ex) { s_logger.debug("Unable to destoy " + data.getType().toString() + ": " + data.getId(), ex); result.setResult(ex.toString()); } callback.complete(result); }
final String cacheType = cacheData.getType().toString(); final String cacheUuid = cacheData.getUuid().toString();
String containerName = SwiftUtil.getContainerName(destData.getObjectType().toString(), pathId); String swiftPath = SwiftUtil.putObject(swift, srcFile, containerName, srcFile.getName());
String errMsg = null; try { s_logger.debug("copyAsync inspecting src type " + srcData.getType().toString() + " copyAsync inspecting dest type " + destData.getType().toString()); if (srcData.getType() == DataObjectType.SNAPSHOT && destData.getType() == DataObjectType.VOLUME) { answer = copyVolumeFromSnapshot(srcData, destData);
.getChecksum(), tmpl.getType().toString(), template.getUniqueName(), template.getFormat().toString(), templateOnStore.getDataStore().getUri(), templateOnStore.getDataStore().getRole().toString());
TemplateOrVolumePostUploadCommand command = new TemplateOrVolumePostUploadCommand(vol.getId(), vol.getUuid(), volumeStore.getInstallPath(), cmd.getChecksum(), vol.getType().toString(), vol.getName(), vol.getFormat().toString(), dataObject.getDataStore().getUri(), dataObject.getDataStore().getRole().toString()); command.setLocalPath(volumeStore.getLocalDownloadPath());