Search in sources :

Example 1 with RevertSnapshotCommand

use of com.cloud.storage.command.RevertSnapshotCommand 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)

Aggregations

Answer (com.cloud.agent.api.Answer)1 ResizeVolumeAnswer (com.cloud.agent.api.storage.ResizeVolumeAnswer)1 CopyCommandResult (com.cloud.engine.subsystem.api.storage.CopyCommandResult)1 EndPoint (com.cloud.engine.subsystem.api.storage.EndPoint)1 StorageUnavailableException (com.cloud.exception.StorageUnavailableException)1 CommandResult (com.cloud.storage.command.CommandResult)1 CopyCmdAnswer (com.cloud.storage.command.CopyCmdAnswer)1 RevertSnapshotCommand (com.cloud.storage.command.RevertSnapshotCommand)1 SnapshotObjectTO (com.cloud.storage.to.SnapshotObjectTO)1