Search in sources :

Example 1 with ResourceCount

use of com.cloud.configuration.ResourceCount in project CloudStack-archive by CloudStack-extras.

the class UpdateResourceCountCmd method execute.

@Override
public void execute() {
    List<? extends ResourceCount> result = _resourceLimitService.recalculateResourceCount(finalyzeAccountId(accountName, domainId, projectId, true), getDomainId(), getResourceType());
    if ((result != null) && (result.size() > 0)) {
        ListResponse<ResourceCountResponse> response = new ListResponse<ResourceCountResponse>();
        List<ResourceCountResponse> countResponses = new ArrayList<ResourceCountResponse>();
        for (ResourceCount count : result) {
            ResourceCountResponse resourceCountResponse = _responseGenerator.createResourceCountResponse(count);
            resourceCountResponse.setObjectName("resourcecount");
            countResponses.add(resourceCountResponse);
        }
        response.setResponses(countResponses);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to recalculate resource counts");
    }
}
Also used : ListResponse(com.cloud.api.response.ListResponse) ServerApiException(com.cloud.api.ServerApiException) ResourceCount(com.cloud.configuration.ResourceCount) ArrayList(java.util.ArrayList) ResourceCountResponse(com.cloud.api.response.ResourceCountResponse)

Example 2 with ResourceCount

use of com.cloud.configuration.ResourceCount in project cloudstack by apache.

the class UpdateResourceCountCmd method execute.

@Override
public void execute() {
    List<? extends ResourceCount> result = _resourceLimitService.recalculateResourceCount(_accountService.finalyzeAccountId(accountName, domainId, projectId, true), getDomainId(), getResourceType());
    if ((result != null) && (result.size() > 0)) {
        ListResponse<ResourceCountResponse> response = new ListResponse<ResourceCountResponse>();
        List<ResourceCountResponse> countResponses = new ArrayList<ResourceCountResponse>();
        for (ResourceCount count : result) {
            ResourceCountResponse resourceCountResponse = _responseGenerator.createResourceCountResponse(count);
            resourceCountResponse.setObjectName("resourcecount");
            countResponses.add(resourceCountResponse);
        }
        response.setResponses(countResponses);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to recalculate resource counts");
    }
}
Also used : ListResponse(org.apache.cloudstack.api.response.ListResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) ResourceCount(com.cloud.configuration.ResourceCount) ArrayList(java.util.ArrayList) ResourceCountResponse(org.apache.cloudstack.api.response.ResourceCountResponse)

Aggregations

ResourceCount (com.cloud.configuration.ResourceCount)2 ArrayList (java.util.ArrayList)2 ServerApiException (com.cloud.api.ServerApiException)1 ListResponse (com.cloud.api.response.ListResponse)1 ResourceCountResponse (com.cloud.api.response.ResourceCountResponse)1 ServerApiException (org.apache.cloudstack.api.ServerApiException)1 ListResponse (org.apache.cloudstack.api.response.ListResponse)1 ResourceCountResponse (org.apache.cloudstack.api.response.ResourceCountResponse)1