protected Answer cloneVolume(DataObject template, DataObject volume) { CopyCommand cmd = new CopyCommand(template.getTO(), addFullCloneFlagOnVMwareDest(volume.getTO()), 0, VirtualMachineManager.ExecuteInSequence.value()); try { EndPoint ep = selector.select(volume.getDataStore()); 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); } return answer; } catch (Exception e) { s_logger.debug("Failed to send to storage pool", e); throw new CloudRuntimeException("Failed to send to storage pool", e); } }
protected boolean needCacheStorage(DataObject srcData, DataObject destData) { DataTO srcTO = srcData.getTO(); DataStoreTO srcStoreTO = srcTO.getDataStore(); if (srcStoreTO instanceof NfsTO || srcStoreTO.getRole() == DataStoreRole.ImageCache) { return false; } DataTO destTO = destData.getTO(); DataStoreTO destStoreTO = destTO.getDataStore(); if (destStoreTO instanceof NfsTO || destStoreTO.getRole() == DataStoreRole.ImageCache) { return false; } if (s_logger.isDebugEnabled()) { s_logger.debug("needCacheStorage true, dest at " + destTO.getPath() + " dest role " + destStoreTO.getRole().toString() + srcTO.getPath() + " src role " + srcStoreTO.getRole().toString()); } return true; }
private boolean needCacheStorage(DataObject srcData, DataObject destData) { DataTO srcTO = srcData.getTO(); DataStoreTO srcStoreTO = srcTO.getDataStore(); DataTO destTO = destData.getTO(); DataStoreTO destStoreTO = destTO.getDataStore(); // both snapshot and volume are on primary datastore - no need for a cache storage as hypervisor will copy directly if (srcStoreTO instanceof PrimaryDataStoreTO && destStoreTO instanceof PrimaryDataStoreTO) { return false; } if (srcStoreTO instanceof NfsTO || srcStoreTO.getRole() == DataStoreRole.ImageCache) { return false; } if (destStoreTO instanceof NfsTO || destStoreTO.getRole() == DataStoreRole.ImageCache) { return false; } if (LOGGER.isDebugEnabled()) { LOGGER.debug("needCacheStorage true; dest at " + destTO.getPath() + ", dest role " + destStoreTO.getRole().toString() + "; src at " + srcTO.getPath() + ", src role " + srcStoreTO.getRole().toString()); } return true; }
@Override public List<DatadiskTO> getDataDiskTemplates(DataObject obj) { List<DatadiskTO> dataDiskDetails = new ArrayList<DatadiskTO>(); if (s_logger.isDebugEnabled()) { s_logger.debug("Get the data disks present in the OVA template"); } DataStore store = obj.getDataStore(); GetDatadisksCommand cmd = new GetDatadisksCommand(obj.getTO()); EndPoint ep = _defaultEpSelector.select(store); 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()) { GetDatadisksAnswer getDatadisksAnswer = (GetDatadisksAnswer)answer; dataDiskDetails = getDatadisksAnswer.getDataDiskDetails(); // Details - Disk path, virtual size } else { throw new CloudRuntimeException("Get Data disk command failed " + answer.getDetails()); } return dataDiskDetails; }
cacheData = cacheMgr.getCacheObject(srcData, selectedScope); CopyCommand cmd = new CopyCommand(srcData.getTO(), addFullCloneFlagOnVMwareDest(destData.getTO()), _backupsnapshotwait, VirtualMachineManager.ExecuteInSequence.value()); cmd.setCacheTO(cacheData.getTO()); cmd.setOptions(options); EndPoint ep = selector.select(srcData, destData); addFullCloneFlagOnVMwareDest(destData.getTO()); CopyCommand cmd = new CopyCommand(srcData.getTO(), destData.getTO(), _backupsnapshotwait, VirtualMachineManager.ExecuteInSequence.value()); cmd.setOptions(options); EndPoint ep = selector.select(srcData, destData, StorageAction.BACKUPSNAPSHOT);
@Override public String createEntityExtractUrl(DataStore store, String installPath, ImageFormat format, DataObject dataObject) { // find an endpoint to send command EndPoint ep = _epSelector.select(store); // Create Symlink at ssvm String path = installPath; String uuid = UUID.randomUUID().toString() + "." + format.getFileExtension(); CreateEntityDownloadURLCommand cmd = new CreateEntityDownloadURLCommand(((ImageStoreEntity)store).getMountPoint(), path, uuid, dataObject.getTO()); Answer ans = null; if (ep == null) { String errMsg = "No remote endpoint to send command, check if host or ssvm is down?"; s_logger.error(errMsg); ans = new Answer(cmd, false, errMsg); } else { ans = ep.sendMessage(cmd); } if (ans == null || !ans.getResult()) { String errorString = "Unable to create a link for entity at " + installPath + " on ssvm," + ans.getDetails(); s_logger.error(errorString); throw new CloudRuntimeException(errorString); } // Construct actual URL locally now that the symlink exists at SSVM return generateCopyUrl(ep.getPublicAddr(), uuid); }
@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); }
@Override public void deleteAsync(DataStore dataStore, DataObject data, AsyncCompletionCallback<CommandResult> callback) { DeleteCommand cmd = new DeleteCommand(data.getTO()); CommandResult result = new CommandResult(); try { EndPoint ep = null; if (data.getType() == DataObjectType.VOLUME) { ep = epSelector.select(data, StorageAction.DELETEVOLUME); } else { ep = epSelector.select(data); } if (ep == null) { String errMsg = "No remote endpoint to send DeleteCommand, check if host or ssvm is down?"; s_logger.error(errMsg); result.setResult(errMsg); } else { Answer answer = ep.sendMessage(cmd); if (answer != null && !answer.getResult()) { result.setResult(answer.getDetails()); } } } catch (Exception ex) { s_logger.debug("Unable to destoy volume" + data.getId(), ex); result.setResult(ex.toString()); } callback.complete(result); }
CopyCommand cmd = new CopyCommand(srcForCopy.getTO(), addFullCloneFlagOnVMwareDest(destData.getTO()), _primaryStorageDownloadWait, VirtualMachineManager.ExecuteInSequence.value()); EndPoint ep = destHost != null ? RemoteHostEndPoint.getHypervisorHostEndPoint(destHost) : selector.select(srcForCopy, destData); if (ep == null) {
CopyCommand cmd = new CopyCommand(objOnImageStore.getTO(), addFullCloneFlagOnVMwareDest(destData.getTO()), _copyvolumewait, VirtualMachineManager.ExecuteInSequence.value()); EndPoint ep = selector.select(objOnImageStore, destData); if (ep == null) { } else { DataObject cacheData = cacheMgr.createCacheObject(srcData, destScope); CopyCommand cmd = new CopyCommand(cacheData.getTO(), destData.getTO(), _copyvolumewait, VirtualMachineManager.ExecuteInSequence.value()); EndPoint ep = selector.select(cacheData, destData); Answer answer = null;
private CopyCmdAnswer copyImageToVolume(DataObject srcDataObject, VolumeInfo destVolumeInfo, HostVO hostVO) { String value = _configDao.getValue(Config.PrimaryStorageDownloadWait.toString()); int primaryStorageDownloadWait = NumbersUtil.parseInt(value, Integer.parseInt(Config.PrimaryStorageDownloadWait.getDefaultValue())); CopyCommand copyCommand = new CopyCommand(srcDataObject.getTO(), destVolumeInfo.getTO(), primaryStorageDownloadWait, VirtualMachineManager.ExecuteInSequence.value()); CopyCmdAnswer copyCmdAnswer; try { _volumeService.grantAccess(destVolumeInfo, hostVO, destVolumeInfo.getDataStore()); Map<String, String> destDetails = getVolumeDetails(destVolumeInfo); copyCommand.setOptions2(destDetails); copyCmdAnswer = (CopyCmdAnswer)_agentMgr.send(hostVO.getId(), copyCommand); } catch (CloudRuntimeException | AgentUnavailableException | OperationTimedoutException ex) { String msg = "Failed to copy image : "; LOGGER.warn(msg, ex); throw new CloudRuntimeException(msg + ex.getMessage(), ex); } finally { _volumeService.revokeAccess(destVolumeInfo, hostVO, destVolumeInfo.getDataStore()); } VolumeObjectTO volumeObjectTO = (VolumeObjectTO)copyCmdAnswer.getNewData(); volumeObjectTO.setFormat(ImageFormat.QCOW2); return copyCmdAnswer; }
start(); VirtualMachineTemplate tmpl = _templateDao.findById(template.getId()); DownloadCommand dcmd = new DownloadCommand((TemplateObjectTO)(template.getTO()), maxTemplateSizeInBytes); dcmd.setProxy(getHttpProxy()); if (downloadJobExists) {
CopyCommand copyCommand = new CopyCommand(snapshotInfo.getTO(), destOnStore.getTO(), primaryStorageDownloadWait, VirtualMachineManager.ExecuteInSequence.value()); CopyCommand cmd = new CopyCommand(destOnStore.getTO(), destData.getTO(), primaryStorageDownloadWait, VirtualMachineManager.ExecuteInSequence.value()); EndPoint ep = selector.select(destOnStore, destData);
@Override public void createAsync(DataStore dataStore, DataObject data, AsyncCompletionCallback<CreateCmdResult> callback) { Long maxTemplateSizeInBytes = getMaxTemplateSizeInBytes(); VirtualMachineTemplate tmpl = _templateDao.findById(data.getId()); DataStore cacheStore = cacheManager.getCacheStorage(dataStore.getScope()); DownloadCommand dcmd = new DownloadCommand((TemplateObjectTO)(data.getTO()), maxTemplateSizeInBytes); dcmd.setCacheStore(cacheStore.getTO()); dcmd.setProxy(getHttpProxy()); EndPoint ep = _epSelector.select(data); if (ep == null) { String errMsg = "No remote endpoint to send command, check if host or ssvm is down?"; s_logger.error(errMsg); throw new CloudRuntimeException(errMsg); } CreateContext<CreateCmdResult> context = new CreateContext<CreateCmdResult>(callback, data); AsyncCallbackDispatcher<SwiftImageStoreDriverImpl, DownloadAnswer> caller = AsyncCallbackDispatcher.create(this); caller.setContext(context); if (data.getType() == DataObjectType.TEMPLATE) { caller.setCallback(caller.getTarget().createTemplateAsyncCallback(null, null)); } else if (data.getType() == DataObjectType.VOLUME) { caller.setCallback(caller.getTarget().createVolumeAsyncCallback(null, null)); } ep.sendMessageAsync(dcmd, caller); }
CopyCommand copyCommand = new CopyCommand(srcData.getTO(), volumeInfo.getTO(), primaryStorageDownloadWait, VirtualMachineManager.ExecuteInSequence.value());
start(); Volume vol = _volumeDao.findById(volume.getId()); DownloadCommand dcmd = new DownloadCommand((VolumeObjectTO)(volume.getTO()), maxVolumeSizeInBytes, checkSum, url, format); dcmd.setProxy(getHttpProxy()); if (downloadJobExists) {