Search in sources :

Example 26 with EndPoint

use of com.cloud.engine.subsystem.api.storage.EndPoint in project cosmic by MissionCriticalCloud.

the class CloudStackPrimaryDataStoreDriverImpl method revertSnapshot.

@Override
public void revertSnapshot(final SnapshotInfo snapshot, final SnapshotInfo snapshotOnPrimaryStore, final AsyncCompletionCallback<CommandResult> callback) {
    final SnapshotObjectTO snapshotTO = (SnapshotObjectTO) snapshot.getTO();
    final RevertSnapshotCommand cmd = new RevertSnapshotCommand(snapshotTO);
    final CommandResult result = new CommandResult();
    try {
        final EndPoint ep = epSelector.select(snapshotOnPrimaryStore);
        if (ep == null) {
            final String errMsg = "No remote endpoint to send RevertSnapshotCommand, check if host or ssvm is down?";
            s_logger.error(errMsg);
            result.setResult(errMsg);
        } else {
            final Answer answer = ep.sendMessage(cmd);
            if (answer != null && !answer.getResult()) {
                result.setResult(answer.getDetails());
            }
        }
    } catch (final Exception ex) {
        s_logger.debug("Unable to revert snapshot " + snapshot.getId(), ex);
        result.setResult(ex.toString());
    }
    callback.complete(result);
}
Also used : SnapshotObjectTO(com.cloud.storage.to.SnapshotObjectTO) ResizeVolumeAnswer(com.cloud.agent.api.storage.ResizeVolumeAnswer) Answer(com.cloud.agent.api.Answer) CopyCmdAnswer(com.cloud.storage.command.CopyCmdAnswer) EndPoint(com.cloud.engine.subsystem.api.storage.EndPoint) RevertSnapshotCommand(com.cloud.storage.command.RevertSnapshotCommand) StorageUnavailableException(com.cloud.exception.StorageUnavailableException) CommandResult(com.cloud.storage.command.CommandResult) CopyCommandResult(com.cloud.engine.subsystem.api.storage.CopyCommandResult)

Example 27 with EndPoint

use of com.cloud.engine.subsystem.api.storage.EndPoint in project cosmic by MissionCriticalCloud.

the class BaseImageStoreDriverImpl method deleteAsync.

@Override
public void deleteAsync(final DataStore dataStore, final DataObject data, final AsyncCompletionCallback<CommandResult> callback) {
    final CommandResult result = new CommandResult();
    try {
        final DeleteCommand cmd = new DeleteCommand(data.getTO());
        final EndPoint ep = _epSelector.select(data);
        Answer answer = null;
        if (ep == null) {
            final 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 (final Exception ex) {
        s_logger.debug("Unable to destoy " + data.getType().toString() + ": " + data.getId(), ex);
        result.setResult(ex.toString());
    }
    callback.complete(result);
}
Also used : DeleteCommand(com.cloud.storage.command.DeleteCommand) DownloadAnswer(com.cloud.agent.api.storage.DownloadAnswer) Answer(com.cloud.agent.api.Answer) EndPoint(com.cloud.engine.subsystem.api.storage.EndPoint) CommandResult(com.cloud.storage.command.CommandResult) CopyCommandResult(com.cloud.engine.subsystem.api.storage.CopyCommandResult)

Example 28 with EndPoint

use of com.cloud.engine.subsystem.api.storage.EndPoint in project cosmic by MissionCriticalCloud.

the class AncientDataMotionStrategy method createTemplateFromSnapshot.

@DB
protected Answer createTemplateFromSnapshot(DataObject srcData, final DataObject destData) {
    final String value = configDao.getValue(Config.CreatePrivateTemplateFromSnapshotWait.toString());
    final int _createprivatetemplatefromsnapshotwait = NumbersUtil.parseInt(value, Integer.parseInt(Config.CreatePrivateTemplateFromSnapshotWait.getDefaultValue()));
    boolean needCache = false;
    if (needCacheStorage(srcData, destData)) {
        needCache = true;
        final SnapshotInfo snapshot = (SnapshotInfo) srcData;
        srcData = cacheSnapshotChain(snapshot, snapshot.getDataStore().getScope());
    }
    EndPoint ep = null;
    if (srcData.getDataStore().getRole() == DataStoreRole.Primary) {
        ep = selector.select(destData);
    } else {
        ep = selector.select(srcData, destData);
    }
    final CopyCommand cmd = new CopyCommand(srcData.getTO(), destData.getTO(), _createprivatetemplatefromsnapshotwait, VirtualMachineManager.ExecuteInSequence.value());
    Answer answer = null;
    if (ep == null) {
        final 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);
    }
    // clean up snapshot copied to staging
    if (needCache && srcData != null) {
        // reduce ref count, but keep it there on cache which is converted from previous secondary storage
        cacheMgr.releaseCacheObject(srcData);
    }
    return answer;
}
Also used : MigrateVolumeAnswer(com.cloud.agent.api.storage.MigrateVolumeAnswer) Answer(com.cloud.agent.api.Answer) SnapshotInfo(com.cloud.engine.subsystem.api.storage.SnapshotInfo) CopyCommand(com.cloud.storage.command.CopyCommand) RemoteHostEndPoint(com.cloud.storage.RemoteHostEndPoint) EndPoint(com.cloud.engine.subsystem.api.storage.EndPoint) RemoteHostEndPoint(com.cloud.storage.RemoteHostEndPoint) EndPoint(com.cloud.engine.subsystem.api.storage.EndPoint) DB(com.cloud.utils.db.DB)

Example 29 with EndPoint

use of com.cloud.engine.subsystem.api.storage.EndPoint in project cosmic by MissionCriticalCloud.

the class AncientDataMotionStrategy method migrateVolumeToPool.

protected Answer migrateVolumeToPool(final DataObject srcData, final DataObject destData) {
    final String value = configDao.getValue(Config.MigrateWait.key());
    final int waitInterval = NumbersUtil.parseInt(value, Integer.parseInt(Config.MigrateWait.getDefaultValue()));
    final VolumeInfo volume = (VolumeInfo) srcData;
    final StoragePool destPool = (StoragePool) dataStoreMgr.getDataStore(destData.getDataStore().getId(), DataStoreRole.Primary);
    final MigrateVolumeCommand command = new MigrateVolumeCommand(volume.getId(), volume.getPath(), destPool, volume.getAttachedVmName(), volume.getVolumeType(), waitInterval);
    final EndPoint ep = selector.select(srcData, StorageAction.MIGRATEVOLUME);
    Answer answer = null;
    if (ep == null) {
        final String errMsg = "No remote endpoint to send command, check if host or ssvm is down?";
        s_logger.error(errMsg);
        answer = new Answer(command, false, errMsg);
    } else {
        answer = ep.sendMessage(command);
    }
    if (answer == null || !answer.getResult()) {
        throw new CloudRuntimeException("Failed to migrate volume " + volume + " to storage pool " + destPool);
    } else {
        // Update the volume details after migration.
        final VolumeVO volumeVo = volDao.findById(volume.getId());
        final Long oldPoolId = volume.getPoolId();
        volumeVo.setPath(((MigrateVolumeAnswer) answer).getVolumePath());
        final String chainInfo = ((MigrateVolumeAnswer) answer).getVolumeChainInfo();
        if (chainInfo != null) {
            volumeVo.setChainInfo(chainInfo);
        }
        volumeVo.setPodId(destPool.getPodId());
        volumeVo.setPoolId(destPool.getId());
        volumeVo.setLastPoolId(oldPoolId);
        // For SMB, pool credentials are also stored in the uri query string.  We trim the query string
        // part  here to make sure the credentials do not get stored in the db unencrypted.
        String folder = destPool.getPath();
        if (destPool.getPoolType() == StoragePoolType.SMB && folder != null && folder.contains("?")) {
            folder = folder.substring(0, folder.indexOf("?"));
        }
        volumeVo.setFolder(folder);
        volDao.update(volume.getId(), volumeVo);
    }
    return answer;
}
Also used : MigrateVolumeCommand(com.cloud.agent.api.storage.MigrateVolumeCommand) MigrateVolumeAnswer(com.cloud.agent.api.storage.MigrateVolumeAnswer) Answer(com.cloud.agent.api.Answer) StoragePool(com.cloud.storage.StoragePool) VolumeVO(com.cloud.storage.VolumeVO) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) MigrateVolumeAnswer(com.cloud.agent.api.storage.MigrateVolumeAnswer) VolumeInfo(com.cloud.engine.subsystem.api.storage.VolumeInfo) RemoteHostEndPoint(com.cloud.storage.RemoteHostEndPoint) EndPoint(com.cloud.engine.subsystem.api.storage.EndPoint) RemoteHostEndPoint(com.cloud.storage.RemoteHostEndPoint) EndPoint(com.cloud.engine.subsystem.api.storage.EndPoint)

Example 30 with EndPoint

use of com.cloud.engine.subsystem.api.storage.EndPoint in project cosmic by MissionCriticalCloud.

the class AncientDataMotionStrategy method copyVolumeBetweenPools.

protected Answer copyVolumeBetweenPools(final DataObject srcData, final DataObject destData) {
    final String value = configDao.getValue(Config.CopyVolumeWait.key());
    final int _copyvolumewait = NumbersUtil.parseInt(value, Integer.parseInt(Config.CopyVolumeWait.getDefaultValue()));
    final Scope destScope = getZoneScope(destData.getDataStore().getScope());
    final DataStore cacheStore = cacheMgr.getCacheStorage(destScope);
    if (cacheStore == null) {
        // need to find a nfs or cifs image store, assuming that can't copy volume
        final ImageStoreEntity imageStore = (ImageStoreEntity) dataStoreMgr.getImageStore(destScope.getScopeId());
        if (!imageStore.getProtocol().equalsIgnoreCase("nfs") && !imageStore.getProtocol().equalsIgnoreCase("cifs")) {
            s_logger.debug("can't find a nfs (or cifs) image store to satisfy the need for a staging store");
            return null;
        }
        final DataObject objOnImageStore = imageStore.create(srcData);
        objOnImageStore.processEvent(Event.CreateOnlyRequested);
        Answer answer = copyObject(srcData, objOnImageStore);
        if (answer == null || !answer.getResult()) {
            if (answer != null) {
                s_logger.debug("copy to image store failed: " + answer.getDetails());
            }
            objOnImageStore.processEvent(Event.OperationFailed);
            imageStore.delete(objOnImageStore);
            return answer;
        }
        objOnImageStore.processEvent(Event.OperationSuccessed, answer);
        objOnImageStore.processEvent(Event.CopyingRequested);
        final CopyCommand cmd = new CopyCommand(objOnImageStore.getTO(), destData.getTO(), _copyvolumewait, VirtualMachineManager.ExecuteInSequence.value());
        final EndPoint ep = selector.select(objOnImageStore, destData);
        if (ep == null) {
            final 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()) {
            if (answer != null) {
                s_logger.debug("copy to primary store failed: " + answer.getDetails());
            }
            objOnImageStore.processEvent(Event.OperationFailed);
            imageStore.delete(objOnImageStore);
            return answer;
        }
        objOnImageStore.processEvent(Event.OperationSuccessed);
        imageStore.delete(objOnImageStore);
        return answer;
    } else {
        final DataObject cacheData = cacheMgr.createCacheObject(srcData, destScope);
        final CopyCommand cmd = new CopyCommand(cacheData.getTO(), destData.getTO(), _copyvolumewait, VirtualMachineManager.ExecuteInSequence.value());
        final EndPoint ep = selector.select(cacheData, destData);
        Answer answer = null;
        if (ep == null) {
            final 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);
        }
        // delete volume on cache store
        if (cacheData != null) {
            cacheMgr.deleteCacheObject(cacheData);
        }
        return answer;
    }
}
Also used : MigrateVolumeAnswer(com.cloud.agent.api.storage.MigrateVolumeAnswer) Answer(com.cloud.agent.api.Answer) DataObject(com.cloud.engine.subsystem.api.storage.DataObject) ClusterScope(com.cloud.engine.subsystem.api.storage.ClusterScope) Scope(com.cloud.engine.subsystem.api.storage.Scope) ZoneScope(com.cloud.engine.subsystem.api.storage.ZoneScope) HostScope(com.cloud.engine.subsystem.api.storage.HostScope) CopyCommand(com.cloud.storage.command.CopyCommand) DataStore(com.cloud.engine.subsystem.api.storage.DataStore) ImageStoreEntity(com.cloud.storage.image.datastore.ImageStoreEntity) RemoteHostEndPoint(com.cloud.storage.RemoteHostEndPoint) EndPoint(com.cloud.engine.subsystem.api.storage.EndPoint) RemoteHostEndPoint(com.cloud.storage.RemoteHostEndPoint) EndPoint(com.cloud.engine.subsystem.api.storage.EndPoint)

Aggregations

EndPoint (com.cloud.engine.subsystem.api.storage.EndPoint)36 Answer (com.cloud.agent.api.Answer)25 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)17 DataStore (com.cloud.engine.subsystem.api.storage.DataStore)14 RemoteHostEndPoint (com.cloud.storage.RemoteHostEndPoint)12 DataObject (com.cloud.engine.subsystem.api.storage.DataObject)8 CopyCmdAnswer (com.cloud.storage.command.CopyCmdAnswer)8 CopyCommand (com.cloud.storage.command.CopyCommand)8 Date (java.util.Date)8 MigrateVolumeAnswer (com.cloud.agent.api.storage.MigrateVolumeAnswer)7 ZoneScope (com.cloud.engine.subsystem.api.storage.ZoneScope)6 ResizeVolumeAnswer (com.cloud.agent.api.storage.ResizeVolumeAnswer)5 CopyCommandResult (com.cloud.engine.subsystem.api.storage.CopyCommandResult)4 VolumeVO (com.cloud.storage.VolumeVO)4 CreateEntityDownloadURLCommand (com.cloud.agent.api.storage.CreateEntityDownloadURLCommand)3 ListVolumeAnswer (com.cloud.agent.api.storage.ListVolumeAnswer)3 VolumeInfo (com.cloud.engine.subsystem.api.storage.VolumeInfo)3 StorageUnavailableException (com.cloud.exception.StorageUnavailableException)3 UploadVO (com.cloud.storage.UploadVO)3 CommandResult (com.cloud.storage.command.CommandResult)3