private boolean storageSystemSupportsCapability(long storagePoolId, String capability) { boolean supportsCapability = false; DataStore dataStore = dataStoreMgr.getDataStore(storagePoolId, DataStoreRole.Primary); Map<String, String> mapCapabilities = dataStore.getDriver().getCapabilities(); if (mapCapabilities != null) { String value = mapCapabilities.get(capability); supportsCapability = Boolean.valueOf(value); } return supportsCapability; }
@Override public DataTO getTO() { DataTO to = store.getDriver().getTO(this); if (to == null) { return new SnapshotObjectTO(this); } return to; }
@Override public DataStoreTO getTO() { DataStoreTO to = getDriver().getStoreTO(this); if (to == null) { PrimaryDataStoreTO primaryTO = new PrimaryDataStoreTO(this); return primaryTO; } return to; } }
/** * If the underlying storage system needed to create a volume from a snapshot for createVolumeFromSnapshot(SnapshotInfo), then * this is its opportunity to delete that temporary volume and restore properties in snapshot_details to the way they were before the * invocation of createVolumeFromSnapshot(SnapshotInfo). */ private void deleteVolumeFromSnapshot(SnapshotInfo snapshotInfo) { SnapshotDetailsVO snapshotDetails = handleSnapshotDetails(snapshotInfo.getId(), "delete"); try { snapshotInfo.getDataStore().getDriver().createAsync(snapshotInfo.getDataStore(), snapshotInfo, null); } finally { _snapshotDetailsDao.remove(snapshotDetails.getId()); } }
@Override public boolean deleteSnapshot(SnapshotInfo snapInfo) { snapInfo.processEvent(ObjectInDataStoreStateMachine.Event.DestroyRequested); AsyncCallFuture<SnapshotResult> future = new AsyncCallFuture<SnapshotResult>(); DeleteSnapshotContext<CommandResult> context = new DeleteSnapshotContext<CommandResult>(null, snapInfo, future); AsyncCallbackDispatcher<SnapshotServiceImpl, CommandResult> caller = AsyncCallbackDispatcher.create(this); caller.setCallback(caller.getTarget().deleteSnapshotCallback(null, null)).setContext(context); DataStore store = snapInfo.getDataStore(); store.getDriver().deleteAsync(store, snapInfo, caller); SnapshotResult result = null; try { result = future.get(); if (result.isFailed()) { throw new CloudRuntimeException(result.getResult()); } return true; } catch (InterruptedException e) { s_logger.debug("delete snapshot is failed: " + e.toString()); } catch (ExecutionException e) { s_logger.debug("delete snapshot is failed: " + e.toString()); } return false; }
@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); }
/** * If the underlying storage system is making use of read-only snapshots, this gives the storage system the opportunity to * create a volume from the snapshot so that we can copy the VHD file that should be inside of the snapshot to secondary storage. * * The resultant volume must be writable because we need to resign the SR and the VDI that should be inside of it before we copy * the VHD file to secondary storage. * * If the storage system is using writable snapshots, then nothing need be done by that storage system here because we can just * resign the SR and the VDI that should be inside of the snapshot before copying the VHD file to secondary storage. */ private void createVolumeFromSnapshot(SnapshotInfo snapshotInfo) { SnapshotDetailsVO snapshotDetails = handleSnapshotDetails(snapshotInfo.getId(), "create"); try { snapshotInfo.getDataStore().getDriver().createAsync(snapshotInfo.getDataStore(), snapshotInfo, null); } finally { _snapshotDetailsDao.remove(snapshotDetails.getId()); } }
@Override public void deleteAsync(DataObject data, AsyncCompletionCallback<CommandResult> callback) { try { objectInDataStoreMgr.update(data, Event.DestroyRequested); } catch (NoTransitionException e) { s_logger.debug("destroy failed", e); CreateCmdResult res = new CreateCmdResult(null, null); callback.complete(res); } catch (ConcurrentOperationException e) { s_logger.debug("destroy failed", e); CreateCmdResult res = new CreateCmdResult(null, null); callback.complete(res); } DeleteContext<CommandResult> context = new DeleteContext<CommandResult>(callback, data); AsyncCallbackDispatcher<DataObjectManagerImpl, CommandResult> caller = AsyncCallbackDispatcher.create(this); caller.setCallback(caller.getTarget().deleteAsynCallback(null, null)).setContext(context); data.getDataStore().getDriver().deleteAsync(data.getDataStore(), data, caller); return; }
private boolean storageSystemSupportsCapability(long storagePoolId, String capability) { boolean supportsCapability = false; DataStore dataStore = dataStoreMgr.getDataStore(storagePoolId, DataStoreRole.Primary); Map<String, String> mapCapabilities = dataStore.getDriver().getCapabilities(); if (mapCapabilities != null) { String value = mapCapabilities.get(capability); supportsCapability = Boolean.valueOf(value); } return supportsCapability; }
AsyncCallbackDispatcher<TemplateServiceImpl, CreateCmdResult> caller = AsyncCallbackDispatcher.create(this); caller.setCallback(caller.getTarget().copyTemplateCrossZoneCallBack(null, null)).setContext(context); destStore.getDriver().createAsync(destStore, templateOnStore, caller); } catch (CloudRuntimeException ex) {
@Override public AsyncCallFuture<TemplateApiResult> deleteTemplateAsync(TemplateInfo template) { TemplateObject to = (TemplateObject)template; // update template_store_ref status to.processEvent(ObjectInDataStoreStateMachine.Event.DestroyRequested); AsyncCallFuture<TemplateApiResult> future = new AsyncCallFuture<TemplateApiResult>(); TemplateOpContext<TemplateApiResult> context = new TemplateOpContext<TemplateApiResult>(null, to, future); AsyncCallbackDispatcher<TemplateServiceImpl, CommandResult> caller = AsyncCallbackDispatcher.create(this); caller.setCallback(caller.getTarget().deleteTemplateCallback(null, null)).setContext(context); to.getDataStore().getDriver().deleteAsync(to.getDataStore(), to, caller); return future; }
@Override public DataTO getTO() { DataTO to = getDataStore().getDriver().getTO(this); if (to == null) { to = new VolumeObjectTO(this); } return to; }
@Override public DataStoreTO getTO() { DataStoreTO to = getDriver().getStoreTO(this); if (to == null) { ImageStoreTO primaryTO = new ImageStoreTO(); primaryTO.setProviderName(getProviderName()); primaryTO.setRole(getRole()); primaryTO.setType(getProtocol()); primaryTO.setUri(getUri()); return primaryTO; } return to; }
private boolean canCloneVolume() { return Boolean.valueOf(getDriver().getCapabilities().get(DataStoreCapabilities.CAN_CREATE_VOLUME_FROM_VOLUME.toString())); }
destVolumeInfo.getDataStore().getDriver().createAsync(destVolumeInfo.getDataStore(), destVolumeInfo, null);
private void handleFailedVolumeMigration(VolumeInfo srcVolumeInfo, VolumeInfo destVolumeInfo, HostVO hostVO) { try { _volumeService.revokeAccess(destVolumeInfo, hostVO, destVolumeInfo.getDataStore()); } catch (Exception ex) { LOGGER.warn("Failed to revoke access to the volume with the following ID: " + destVolumeInfo.getId()); } try { VolumeDetailVO volumeDetailVO = new VolumeDetailVO(destVolumeInfo.getId(), PrimaryDataStoreDriver.BASIC_DELETE_BY_FOLDER, Boolean.TRUE.toString(), false); volumeDetailsDao.persist(volumeDetailVO); destVolumeInfo.getDataStore().getDriver().deleteAsync(destVolumeInfo.getDataStore(), destVolumeInfo, null); volumeDetailsDao.removeDetails(srcVolumeInfo.getId()); } catch (Exception ex) { LOGGER.warn(ex.getMessage()); } VolumeVO volumeVO = _volumeDao.findById(srcVolumeInfo.getId()); volumeVO.setPoolId(srcVolumeInfo.getPoolId()); volumeVO.setLastPoolId(srcVolumeInfo.getLastPoolId()); volumeVO.setFolder(srcVolumeInfo.getFolder()); volumeVO.set_iScsiName(srcVolumeInfo.get_iScsiName()); _volumeDao.update(srcVolumeInfo.getId(), volumeVO); }
@Override public DataTO getTO() { DataTO to = null; if (dataStore == null) { to = new TemplateObjectTO(this); } else { to = dataStore.getDriver().getTO(this); if (to == null) { to = new TemplateObjectTO(this); } } return to; }
private boolean canHandle(DataObject dataObject) { Preconditions.checkArgument(dataObject != null, "Passing 'null' to dataObject of canHandle(DataObject) is not supported."); DataStore dataStore = dataObject.getDataStore(); if (dataStore.getRole() == DataStoreRole.Primary) { Map<String, String> mapCapabilities = dataStore.getDriver().getCapabilities(); if (mapCapabilities == null) { return false; } if (dataObject instanceof VolumeInfo || dataObject instanceof SnapshotInfo) { String value = mapCapabilities.get(DataStoreCapabilities.STORAGE_SYSTEM_SNAPSHOT.toString()); Boolean supportsStorageSystemSnapshots = Boolean.valueOf(value); if (supportsStorageSystemSnapshots) { LOGGER.info("Using 'StorageSystemDataMotionStrategy' (dataObject is a volume or snapshot and the storage system supports snapshots)"); return true; } } else if (dataObject instanceof TemplateInfo) { // If the storage system can clone volumes, we can cache templates on it. String value = mapCapabilities.get(DataStoreCapabilities.CAN_CREATE_VOLUME_FROM_VOLUME.toString()); Boolean canCloneVolume = Boolean.valueOf(value); if (canCloneVolume) { LOGGER.info("Using 'StorageSystemDataMotionStrategy' (dataObject is a template and the storage system can create a volume from a volume)"); return true; } } } return false; }
destVolumeInfo.getDataStore().getDriver().createAsync(destVolumeInfo.getDataStore(), destVolumeInfo, null);
@Override public AsyncCallFuture<TemplateApiResult> deleteTemplateOnPrimary(TemplateInfo template, StoragePool pool) { TemplateObject templateObject = (TemplateObject)_templateFactory.getTemplate(template.getId(), (DataStore)pool); templateObject.processEvent(ObjectInDataStoreStateMachine.Event.DestroyRequested); DataStore dataStore = _storeMgr.getPrimaryDataStore(pool.getId()); AsyncCallFuture<TemplateApiResult> future = new AsyncCallFuture<>(); TemplateOpContext<TemplateApiResult> context = new TemplateOpContext<>(null, templateObject, future); AsyncCallbackDispatcher<TemplateServiceImpl, CommandResult> caller = AsyncCallbackDispatcher.create(this); caller.setCallback(caller.getTarget().deleteTemplateCallback(null, null)).setContext(context); dataStore.getDriver().deleteAsync(dataStore, templateObject, caller); return future; }