Search in sources :

Example 1 with SnapshotPolicy

use of com.cloud.storage.snapshot.SnapshotPolicy in project CloudStack-archive by CloudStack-extras.

the class CreateSnapshotPolicyCmd method execute.

@Override
public void execute() {
    SnapshotPolicy result = _snapshotService.createPolicy(this, _accountService.getAccount(getEntityOwnerId()));
    if (result != null) {
        SnapshotPolicyResponse response = _responseGenerator.createSnapshotPolicyResponse(result);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create snapshot policy");
    }
}
Also used : SnapshotPolicyResponse(com.cloud.api.response.SnapshotPolicyResponse) SnapshotPolicy(com.cloud.storage.snapshot.SnapshotPolicy) ServerApiException(com.cloud.api.ServerApiException)

Example 2 with SnapshotPolicy

use of com.cloud.storage.snapshot.SnapshotPolicy in project cloudstack by apache.

the class CreateSnapshotPolicyCmd method execute.

@Override
public void execute() {
    SnapshotPolicy result = _snapshotService.createPolicy(this, _accountService.getAccount(getEntityOwnerId()));
    if (result != null) {
        SnapshotPolicyResponse response = _responseGenerator.createSnapshotPolicyResponse(result);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create snapshot policy");
    }
}
Also used : SnapshotPolicyResponse(org.apache.cloudstack.api.response.SnapshotPolicyResponse) SnapshotPolicy(com.cloud.storage.snapshot.SnapshotPolicy) ServerApiException(org.apache.cloudstack.api.ServerApiException)

Example 3 with SnapshotPolicy

use of com.cloud.storage.snapshot.SnapshotPolicy in project cloudstack by apache.

the class UpdateSnapshotPolicyCmd method getEntityOwnerId.

@Override
public long getEntityOwnerId() {
    SnapshotPolicy policy = _entityMgr.findById(SnapshotPolicy.class, getId());
    if (policy == null) {
        throw new InvalidParameterValueException("Invalid snapshot policy id was provided");
    }
    Volume volume = _responseGenerator.findVolumeById(policy.getVolumeId());
    if (volume == null) {
        throw new InvalidParameterValueException("Snapshot policy's volume id doesnt exist");
    } else {
        return volume.getAccountId();
    }
}
Also used : SnapshotPolicy(com.cloud.storage.snapshot.SnapshotPolicy) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) Volume(com.cloud.storage.Volume)

Example 4 with SnapshotPolicy

use of com.cloud.storage.snapshot.SnapshotPolicy in project cloudstack by apache.

the class ListSnapshotPoliciesCmd method execute.

@Override
public void execute() {
    Pair<List<? extends SnapshotPolicy>, Integer> result = _snapshotService.listPoliciesforVolume(this);
    ListResponse<SnapshotPolicyResponse> response = new ListResponse<SnapshotPolicyResponse>();
    List<SnapshotPolicyResponse> policyResponses = new ArrayList<SnapshotPolicyResponse>();
    for (SnapshotPolicy policy : result.first()) {
        SnapshotPolicyResponse policyResponse = _responseGenerator.createSnapshotPolicyResponse(policy);
        policyResponse.setObjectName("snapshotpolicy");
        policyResponses.add(policyResponse);
    }
    response.setResponses(policyResponses, result.second());
    response.setResponseName(getCommandName());
    this.setResponseObject(response);
}
Also used : SnapshotPolicyResponse(org.apache.cloudstack.api.response.SnapshotPolicyResponse) SnapshotPolicy(com.cloud.storage.snapshot.SnapshotPolicy) ListResponse(org.apache.cloudstack.api.response.ListResponse) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 5 with SnapshotPolicy

use of com.cloud.storage.snapshot.SnapshotPolicy in project cloudstack by apache.

the class ApiResponseHelper method createSnapshotScheduleResponse.

@Override
public SnapshotScheduleResponse createSnapshotScheduleResponse(SnapshotSchedule snapshotSchedule) {
    SnapshotScheduleResponse response = new SnapshotScheduleResponse();
    response.setId(snapshotSchedule.getUuid());
    if (snapshotSchedule.getVolumeId() != null) {
        Volume vol = ApiDBUtils.findVolumeById(snapshotSchedule.getVolumeId());
        if (vol != null) {
            response.setVolumeId(vol.getUuid());
        }
    }
    if (snapshotSchedule.getPolicyId() != null) {
        SnapshotPolicy policy = ApiDBUtils.findSnapshotPolicyById(snapshotSchedule.getPolicyId());
        if (policy != null) {
            response.setSnapshotPolicyId(policy.getUuid());
        }
    }
    response.setScheduled(snapshotSchedule.getScheduledTimestamp());
    response.setObjectName("snapshot");
    return response;
}
Also used : SnapshotPolicy(com.cloud.storage.snapshot.SnapshotPolicy) Volume(com.cloud.storage.Volume) SnapshotScheduleResponse(org.apache.cloudstack.api.response.SnapshotScheduleResponse)

Aggregations

SnapshotPolicy (com.cloud.storage.snapshot.SnapshotPolicy)7 SnapshotPolicyResponse (org.apache.cloudstack.api.response.SnapshotPolicyResponse)3 SnapshotPolicyResponse (com.cloud.api.response.SnapshotPolicyResponse)2 Volume (com.cloud.storage.Volume)2 ArrayList (java.util.ArrayList)2 ServerApiException (org.apache.cloudstack.api.ServerApiException)2 ServerApiException (com.cloud.api.ServerApiException)1 ListResponse (com.cloud.api.response.ListResponse)1 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)1 List (java.util.List)1 ListResponse (org.apache.cloudstack.api.response.ListResponse)1 SnapshotScheduleResponse (org.apache.cloudstack.api.response.SnapshotScheduleResponse)1