Search in sources :

Example 1 with RevertSnapshotCommand

use of org.apache.cloudstack.storage.command.RevertSnapshotCommand in project cloudstack by apache.

the class CloudStackPrimaryDataStoreDriverImpl method revertSnapshot.

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

Aggregations

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