Search in sources :

Example 1 with RevertSnapshotCommand

use of com.cloud.legacymodel.communication.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.legacymodel.to.SnapshotObjectTO) Answer(com.cloud.legacymodel.communication.answer.Answer) ResizeVolumeAnswer(com.cloud.legacymodel.communication.answer.ResizeVolumeAnswer) CopyCmdAnswer(com.cloud.legacymodel.communication.answer.CopyCmdAnswer) EndPoint(com.cloud.engine.subsystem.api.storage.EndPoint) RevertSnapshotCommand(com.cloud.legacymodel.communication.command.RevertSnapshotCommand) StorageUnavailableException(com.cloud.legacymodel.exceptions.StorageUnavailableException) CommandResult(com.cloud.storage.command.CommandResult) CopyCommandResult(com.cloud.engine.subsystem.api.storage.CopyCommandResult)

Aggregations

CopyCommandResult (com.cloud.engine.subsystem.api.storage.CopyCommandResult)1 EndPoint (com.cloud.engine.subsystem.api.storage.EndPoint)1 Answer (com.cloud.legacymodel.communication.answer.Answer)1 CopyCmdAnswer (com.cloud.legacymodel.communication.answer.CopyCmdAnswer)1 ResizeVolumeAnswer (com.cloud.legacymodel.communication.answer.ResizeVolumeAnswer)1 RevertSnapshotCommand (com.cloud.legacymodel.communication.command.RevertSnapshotCommand)1 StorageUnavailableException (com.cloud.legacymodel.exceptions.StorageUnavailableException)1 SnapshotObjectTO (com.cloud.legacymodel.to.SnapshotObjectTO)1 CommandResult (com.cloud.storage.command.CommandResult)1