Search in sources :

Example 36 with CopyCommandResult

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

the class AncientDataMotionStrategy method copyAsync.

@Override
public Void copyAsync(final Map<VolumeInfo, DataStore> volumeMap, final VirtualMachineTO vmTo, final Host srcHost, final Host destHost, final AsyncCompletionCallback<CopyCommandResult> callback) {
    final CopyCommandResult result = new CopyCommandResult(null, null);
    result.setResult("Unsupported operation requested for copying data.");
    callback.complete(result);
    return null;
}
Also used : CopyCommandResult(com.cloud.engine.subsystem.api.storage.CopyCommandResult)

Example 37 with CopyCommandResult

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

the class AncientDataMotionStrategy method copyAsync.

// Note: destHost is currently only used if the copyObject method is invoked
@Override
public Void copyAsync(final DataObject srcData, final DataObject destData, final Host destHost, final AsyncCompletionCallback<CopyCommandResult> callback) {
    Answer answer = null;
    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);
        } else if (srcData.getType() == DataObjectType.SNAPSHOT && destData.getType() == DataObjectType.TEMPLATE) {
            answer = createTemplateFromSnapshot(srcData, destData);
        } else if (srcData.getType() == DataObjectType.TEMPLATE && destData.getType() == DataObjectType.VOLUME) {
            answer = cloneVolume(srcData, destData);
        } else if (destData.getType() == DataObjectType.VOLUME && srcData.getType() == DataObjectType.VOLUME && srcData.getDataStore().getRole() == DataStoreRole.Primary && destData.getDataStore().getRole() == DataStoreRole.Primary) {
            if (srcData.getId() == destData.getId()) {
                // The volume has to be migrated across storage pools.
                answer = migrateVolumeToPool(srcData, destData);
            } else {
                answer = copyVolumeBetweenPools(srcData, destData);
            }
        } else if (srcData.getType() == DataObjectType.SNAPSHOT && destData.getType() == DataObjectType.SNAPSHOT) {
            answer = copySnapshot(srcData, destData);
        } else {
            answer = copyObject(srcData, destData, destHost);
        }
        if (answer != null && !answer.getResult()) {
            errMsg = answer.getDetails();
        }
    } catch (final Exception e) {
        s_logger.debug("copy failed", e);
        errMsg = e.toString();
    }
    final CopyCommandResult result = new CopyCommandResult(null, answer);
    result.setResult(errMsg);
    callback.complete(result);
    return null;
}
Also used : MigrateVolumeAnswer(com.cloud.agent.api.storage.MigrateVolumeAnswer) Answer(com.cloud.agent.api.Answer) CopyCommandResult(com.cloud.engine.subsystem.api.storage.CopyCommandResult) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException)

Aggregations

CopyCommandResult (com.cloud.engine.subsystem.api.storage.CopyCommandResult)37 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)26 ExecutionException (java.util.concurrent.ExecutionException)17 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)14 ResourceAllocationException (com.cloud.exception.ResourceAllocationException)14 VolumeInfo (com.cloud.engine.subsystem.api.storage.VolumeInfo)12 AsyncCallFuture (com.cloud.framework.async.AsyncCallFuture)12 DataObject (com.cloud.engine.subsystem.api.storage.DataObject)9 NoTransitionException (com.cloud.utils.fsm.NoTransitionException)7 CopyCmdAnswer (com.cloud.storage.command.CopyCmdAnswer)6 DataStore (com.cloud.engine.subsystem.api.storage.DataStore)5 SnapshotInfo (com.cloud.engine.subsystem.api.storage.SnapshotInfo)5 Answer (com.cloud.agent.api.Answer)4 CreateCmdResult (com.cloud.engine.subsystem.api.storage.CreateCmdResult)4 PrimaryDataStore (com.cloud.engine.subsystem.api.storage.PrimaryDataStore)4 SnapshotResult (com.cloud.engine.subsystem.api.storage.SnapshotResult)4 TemplateInfo (com.cloud.engine.subsystem.api.storage.TemplateInfo)4 CommandResult (com.cloud.storage.command.CommandResult)4 DB (com.cloud.utils.db.DB)4 CopyCommand (com.cloud.storage.command.CopyCommand)3