Search in sources :

Example 6 with SnapshotResponse

use of com.cloud.api.response.SnapshotResponse in project cosmic by MissionCriticalCloud.

the class ListSnapshotsCmd method execute.

@Override
public void execute() {
    final Pair<List<? extends Snapshot>, Integer> result = _snapshotService.listSnapshots(this);
    final ListResponse<SnapshotResponse> response = new ListResponse<>();
    final List<SnapshotResponse> snapshotResponses = new ArrayList<>();
    for (final Snapshot snapshot : result.first()) {
        final SnapshotResponse snapshotResponse = _responseGenerator.createSnapshotResponse(snapshot);
        snapshotResponse.setObjectName("snapshot");
        snapshotResponses.add(snapshotResponse);
    }
    response.setResponses(snapshotResponses, result.second());
    response.setResponseName(getCommandName());
    setResponseObject(response);
}
Also used : Snapshot(com.cloud.storage.Snapshot) ListResponse(com.cloud.api.response.ListResponse) SnapshotResponse(com.cloud.api.response.SnapshotResponse) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 7 with SnapshotResponse

use of com.cloud.api.response.SnapshotResponse in project cosmic by MissionCriticalCloud.

the class RevertSnapshotCmd method execute.

@Override
public void execute() {
    CallContext.current().setEventDetails("Snapshot Id: " + getId());
    final Snapshot snapshot = _snapshotService.revertSnapshot(getId());
    if (snapshot != null) {
        final SnapshotResponse response = _responseGenerator.createSnapshotResponse(snapshot);
        response.setResponseName(getCommandName());
        setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to revert snapshot");
    }
}
Also used : Snapshot(com.cloud.storage.Snapshot) ServerApiException(com.cloud.api.ServerApiException) SnapshotResponse(com.cloud.api.response.SnapshotResponse)

Aggregations

SnapshotResponse (com.cloud.api.response.SnapshotResponse)7 Snapshot (com.cloud.storage.Snapshot)6 ServerApiException (com.cloud.api.ServerApiException)4 ArrayList (java.util.ArrayList)3 ListResponse (com.cloud.api.response.ListResponse)2 VMSnapshotResponse (com.cloud.api.response.VMSnapshotResponse)2 PermissionDeniedException (com.cloud.exception.PermissionDeniedException)2 ResourceAllocationException (com.cloud.exception.ResourceAllocationException)2 InvalidParameterValueException (com.cloud.utils.exception.InvalidParameterValueException)2 ResourceTagResponse (com.cloud.api.response.ResourceTagResponse)1 DataCenter (com.cloud.dc.DataCenter)1 SnapshotInfo (com.cloud.engine.subsystem.api.storage.SnapshotInfo)1 ResourceTag (com.cloud.server.ResourceTag)1 DataStoreRole (com.cloud.storage.DataStoreRole)1 VolumeVO (com.cloud.storage.VolumeVO)1 VMSnapshot (com.cloud.vm.snapshot.VMSnapshot)1 List (java.util.List)1