Search in sources :

Example 1 with SnapshotPolicyResponse

use of com.cloud.api.response.SnapshotPolicyResponse 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 SnapshotPolicyResponse

use of com.cloud.api.response.SnapshotPolicyResponse in project CloudStack-archive by CloudStack-extras.

the class ListSnapshotPoliciesCmd method execute.

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

Aggregations

SnapshotPolicyResponse (com.cloud.api.response.SnapshotPolicyResponse)2 SnapshotPolicy (com.cloud.storage.snapshot.SnapshotPolicy)2 ServerApiException (com.cloud.api.ServerApiException)1 ListResponse (com.cloud.api.response.ListResponse)1 ArrayList (java.util.ArrayList)1