Search in sources :

Example 1 with ResourceLimit

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

the class UpdateResourceLimitCmd method execute.

@Override
public void execute() {
    ResourceLimit result = _resourceLimitService.updateResourceLimit(finalyzeAccountId(accountName, domainId, projectId, true), getDomainId(), resourceType, max);
    if (result != null || (result == null && max != null && max.longValue() == -1L)) {
        ResourceLimitResponse response = _responseGenerator.createResourceLimitResponse(result);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update resource limit");
    }
}
Also used : ServerApiException(com.cloud.api.ServerApiException) ResourceLimitResponse(com.cloud.api.response.ResourceLimitResponse) ResourceLimit(com.cloud.configuration.ResourceLimit)

Example 2 with ResourceLimit

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

the class ListResourceLimitsCmd method execute.

@Override
public void execute() {
    List<? extends ResourceLimit> result = _resourceLimitService.searchForLimits(id, finalyzeAccountId(this.getAccountName(), this.getDomainId(), this.getProjectId(), false), this.getDomainId(), resourceType, this.getStartIndex(), this.getPageSizeVal());
    ListResponse<ResourceLimitResponse> response = new ListResponse<ResourceLimitResponse>();
    List<ResourceLimitResponse> limitResponses = new ArrayList<ResourceLimitResponse>();
    for (ResourceLimit limit : result) {
        ResourceLimitResponse resourceLimitResponse = _responseGenerator.createResourceLimitResponse(limit);
        resourceLimitResponse.setObjectName("resourcelimit");
        limitResponses.add(resourceLimitResponse);
    }
    response.setResponses(limitResponses);
    response.setResponseName(getCommandName());
    this.setResponseObject(response);
}
Also used : ListResponse(com.cloud.api.response.ListResponse) ResourceLimitResponse(com.cloud.api.response.ResourceLimitResponse) ArrayList(java.util.ArrayList) ResourceLimit(com.cloud.configuration.ResourceLimit)

Example 3 with ResourceLimit

use of com.cloud.configuration.ResourceLimit in project cosmic by MissionCriticalCloud.

the class ResourceLimitManagerImplTest method resourceLimitServiceCall.

private void resourceLimitServiceCall(final Long accountId, final Long domainId, final Integer resourceType, final Long max) {
    final String msg = "Update Resource Limit: TEST FAILED";
    ResourceLimit result;
    try {
        result = _resourceLimitService.updateResourceLimit(accountId, domainId, resourceType, max);
        assertFalse(msg, (result != null || (result == null && max != null && max.longValue() == -1L)));
    } catch (final Exception ex) {
        fail(msg);
    }
}
Also used : ResourceLimit(com.cloud.configuration.ResourceLimit)

Example 4 with ResourceLimit

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

the class UpdateResourceLimitCmd method execute.

@Override
public void execute() {
    ResourceLimit result = _resourceLimitService.updateResourceLimit(_accountService.finalyzeAccountId(accountName, domainId, projectId, true), getDomainId(), resourceType, max);
    if (result != null || (result == null && max != null && max.longValue() == -1L)) {
        ResourceLimitResponse response = _responseGenerator.createResourceLimitResponse(result);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update resource limit");
    }
}
Also used : ServerApiException(org.apache.cloudstack.api.ServerApiException) ResourceLimitResponse(org.apache.cloudstack.api.response.ResourceLimitResponse) ResourceLimit(com.cloud.configuration.ResourceLimit)

Example 5 with ResourceLimit

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

the class ResourceLimitManagerImplTest method resourceLimitServiceCall.

private void resourceLimitServiceCall(Long accountId, Long domainId, Integer resourceType, Long max) {
    String msg = "Update Resource Limit: TEST FAILED";
    ResourceLimit result = null;
    try {
        result = _resourceLimitService.updateResourceLimit(accountId, domainId, resourceType, max);
        assertFalse(msg, (result != null || (result == null && max != null && max.longValue() == -1L)));
    } catch (Exception ex) {
        fail(msg);
    }
}
Also used : ResourceLimit(com.cloud.configuration.ResourceLimit)

Aggregations

ResourceLimit (com.cloud.configuration.ResourceLimit)8 ResourceLimitResponse (com.cloud.api.response.ResourceLimitResponse)4 ArrayList (java.util.ArrayList)3 ServerApiException (com.cloud.api.ServerApiException)2 ListResponse (com.cloud.api.response.ListResponse)2 ResourceLimitResponse (org.apache.cloudstack.api.response.ResourceLimitResponse)2 ServerApiException (org.apache.cloudstack.api.ServerApiException)1 ListResponse (org.apache.cloudstack.api.response.ListResponse)1