Search in sources :

Example 1 with ListResponse

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

the class PrepareTemplateCmd method execute.

@Override
public void execute() {
    ListResponse<TemplateResponse> response = new ListResponse<TemplateResponse>();
    VirtualMachineTemplate vmTemplate = _templateService.prepareTemplate(templateId, zoneId);
    List<TemplateResponse> templateResponses = _responseGenerator.createTemplateResponses(vmTemplate.getId(), zoneId, true);
    response.setResponses(templateResponses);
    response.setResponseName(getCommandName());
    this.setResponseObject(response);
}
Also used : ListResponse(com.cloud.api.response.ListResponse) VirtualMachineTemplate(com.cloud.template.VirtualMachineTemplate) TemplateResponse(com.cloud.api.response.TemplateResponse)

Example 2 with ListResponse

use of com.cloud.api.response.ListResponse 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 3 with ListResponse

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

the class RegisterTemplateCmd method execute.

@Override
public void execute() throws ResourceAllocationException {
    try {
        VirtualMachineTemplate template = _templateService.registerTemplate(this);
        if (template != null) {
            ListResponse<TemplateResponse> response = new ListResponse<TemplateResponse>();
            List<TemplateResponse> templateResponses = _responseGenerator.createTemplateResponses(template.getId(), zoneId, false);
            response.setResponses(templateResponses);
            response.setResponseName(getCommandName());
            this.setResponseObject(response);
        } else {
            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to register template");
        }
    } catch (URISyntaxException ex1) {
        s_logger.info(ex1);
        throw new ServerApiException(BaseCmd.PARAM_ERROR, ex1.getMessage());
    }
}
Also used : VirtualMachineTemplate(com.cloud.template.VirtualMachineTemplate) ListResponse(com.cloud.api.response.ListResponse) ServerApiException(com.cloud.api.ServerApiException) TemplateResponse(com.cloud.api.response.TemplateResponse) URISyntaxException(java.net.URISyntaxException)

Example 4 with ListResponse

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

the class ListVirtualRouterElementsCmd method execute.

@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
    List<? extends VirtualRouterProvider> providers = _service.searchForVirtualRouterElement(this);
    ListResponse<VirtualRouterProviderResponse> response = new ListResponse<VirtualRouterProviderResponse>();
    List<VirtualRouterProviderResponse> providerResponses = new ArrayList<VirtualRouterProviderResponse>();
    for (VirtualRouterProvider provider : providers) {
        VirtualRouterProviderResponse providerResponse = _responseGenerator.createVirtualRouterProviderResponse(provider);
        providerResponses.add(providerResponse);
    }
    response.setResponses(providerResponses);
    response.setResponseName(getCommandName());
    this.setResponseObject(response);
}
Also used : VirtualRouterProviderResponse(com.cloud.api.response.VirtualRouterProviderResponse) ListResponse(com.cloud.api.response.ListResponse) VirtualRouterProvider(com.cloud.network.VirtualRouterProvider) ArrayList(java.util.ArrayList)

Example 5 with ListResponse

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

the class ListVlanIpRangesCmd method execute.

@Override
public void execute() {
    List<? extends Vlan> vlans = _mgr.searchForVlans(this);
    ListResponse<VlanIpRangeResponse> response = new ListResponse<VlanIpRangeResponse>();
    List<VlanIpRangeResponse> vlanResponses = new ArrayList<VlanIpRangeResponse>();
    for (Vlan vlan : vlans) {
        VlanIpRangeResponse vlanResponse = _responseGenerator.createVlanIpRangeResponse(vlan);
        vlanResponse.setObjectName("vlaniprange");
        vlanResponses.add(vlanResponse);
    }
    response.setResponses(vlanResponses);
    response.setResponseName(getCommandName());
    this.setResponseObject(response);
}
Also used : VlanIpRangeResponse(com.cloud.api.response.VlanIpRangeResponse) ListResponse(com.cloud.api.response.ListResponse) ArrayList(java.util.ArrayList) Vlan(com.cloud.dc.Vlan)

Aggregations

ListResponse (com.cloud.api.response.ListResponse)156 ArrayList (java.util.ArrayList)139 List (java.util.List)60 ServerApiException (com.cloud.api.ServerApiException)30 TemplateResponse (com.cloud.api.response.TemplateResponse)13 InvalidParameterValueException (com.cloud.utils.exception.InvalidParameterValueException)11 ResponseView (com.cloud.api.ResponseObject.ResponseView)10 Network (com.cloud.network.Network)9 DedicatedResources (com.cloud.dc.DedicatedResources)8 VirtualMachineTemplate (com.cloud.template.VirtualMachineTemplate)8 DomainResponse (com.cloud.api.response.DomainResponse)7 DedicatedResourceVO (com.cloud.dc.DedicatedResourceVO)7 Domain (com.cloud.domain.Domain)7 VirtualMachine (com.cloud.vm.VirtualMachine)7 StoragePoolResponse (com.cloud.api.response.StoragePoolResponse)6 UserResponse (com.cloud.api.response.UserResponse)6 UserVmResponse (com.cloud.api.response.UserVmResponse)6 Host (com.cloud.host.Host)6 AccountResponse (com.cloud.api.response.AccountResponse)5 HostResponse (com.cloud.api.response.HostResponse)5