Search in sources :

Example 6 with ListResponse

use of org.apache.cloudstack.api.response.ListResponse in project cloudstack by apache.

the class DedicateZoneCmd method execute.

@Override
public void execute() {
    List<? extends DedicatedResources> result = dedicatedService.dedicateZone(getZoneId(), getDomainId(), getAccountName());
    ListResponse<DedicateZoneResponse> response = new ListResponse<DedicateZoneResponse>();
    List<DedicateZoneResponse> zoneResponseList = new ArrayList<DedicateZoneResponse>();
    if (result != null) {
        for (DedicatedResources resource : result) {
            DedicateZoneResponse zoneresponse = dedicatedService.createDedicateZoneResponse(resource);
            zoneResponseList.add(zoneresponse);
        }
        response.setResponses(zoneResponseList);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to dedicate zone");
    }
}
Also used : ListResponse(org.apache.cloudstack.api.response.ListResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) DedicatedResources(com.cloud.dc.DedicatedResources) ArrayList(java.util.ArrayList) DedicateZoneResponse(org.apache.cloudstack.api.response.DedicateZoneResponse)

Example 7 with ListResponse

use of org.apache.cloudstack.api.response.ListResponse in project cloudstack by apache.

the class ListDedicatedClustersCmd method execute.

@Override
public void execute() {
    Pair<List<? extends DedicatedResourceVO>, Integer> result = dedicatedService.listDedicatedClusters(this);
    ListResponse<DedicateClusterResponse> response = new ListResponse<DedicateClusterResponse>();
    List<DedicateClusterResponse> Responses = new ArrayList<DedicateClusterResponse>();
    if (result != null) {
        for (DedicatedResources resource : result.first()) {
            DedicateClusterResponse clusterResponse = dedicatedService.createDedicateClusterResponse(resource);
            Responses.add(clusterResponse);
        }
        response.setResponses(Responses, result.second());
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to list dedicated clusters");
    }
}
Also used : ListResponse(org.apache.cloudstack.api.response.ListResponse) DedicateClusterResponse(org.apache.cloudstack.api.response.DedicateClusterResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) DedicatedResources(com.cloud.dc.DedicatedResources) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) DedicatedResourceVO(com.cloud.dc.DedicatedResourceVO)

Example 8 with ListResponse

use of org.apache.cloudstack.api.response.ListResponse in project cloudstack by apache.

the class ListDedicatedHostsCmd method execute.

@Override
public void execute() {
    Pair<List<? extends DedicatedResourceVO>, Integer> result = dedicatedService.listDedicatedHosts(this);
    ListResponse<DedicateHostResponse> response = new ListResponse<DedicateHostResponse>();
    List<DedicateHostResponse> Responses = new ArrayList<DedicateHostResponse>();
    if (result != null) {
        for (DedicatedResources resource : result.first()) {
            DedicateHostResponse hostResponse = dedicatedService.createDedicateHostResponse(resource);
            Responses.add(hostResponse);
        }
        response.setResponses(Responses, result.second());
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to list dedicated hosts");
    }
}
Also used : DedicateHostResponse(org.apache.cloudstack.api.response.DedicateHostResponse) ListResponse(org.apache.cloudstack.api.response.ListResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) DedicatedResources(com.cloud.dc.DedicatedResources) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) DedicatedResourceVO(com.cloud.dc.DedicatedResourceVO)

Example 9 with ListResponse

use of org.apache.cloudstack.api.response.ListResponse in project cloudstack by apache.

the class ListDedicatedPodsCmd method execute.

@Override
public void execute() {
    Pair<List<? extends DedicatedResourceVO>, Integer> result = dedicatedService.listDedicatedPods(this);
    ListResponse<DedicatePodResponse> response = new ListResponse<DedicatePodResponse>();
    List<DedicatePodResponse> Responses = new ArrayList<DedicatePodResponse>();
    if (result != null) {
        for (DedicatedResources resource : result.first()) {
            DedicatePodResponse podresponse = dedicatedService.createDedicatePodResponse(resource);
            Responses.add(podresponse);
        }
        response.setResponses(Responses, result.second());
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to list dedicated pods");
    }
}
Also used : ListResponse(org.apache.cloudstack.api.response.ListResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) DedicatePodResponse(org.apache.cloudstack.api.response.DedicatePodResponse) DedicatedResources(com.cloud.dc.DedicatedResources) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) DedicatedResourceVO(com.cloud.dc.DedicatedResourceVO)

Example 10 with ListResponse

use of org.apache.cloudstack.api.response.ListResponse in project cloudstack by apache.

the class ListDedicatedZonesCmd method execute.

@Override
public void execute() {
    Pair<List<? extends DedicatedResourceVO>, Integer> result = _dedicatedservice.listDedicatedZones(this);
    ListResponse<DedicateZoneResponse> response = new ListResponse<DedicateZoneResponse>();
    List<DedicateZoneResponse> Responses = new ArrayList<DedicateZoneResponse>();
    if (result != null) {
        for (DedicatedResources resource : result.first()) {
            DedicateZoneResponse zoneResponse = _dedicatedservice.createDedicateZoneResponse(resource);
            Responses.add(zoneResponse);
        }
        response.setResponses(Responses, result.second());
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to list dedicated zones");
    }
}
Also used : ListResponse(org.apache.cloudstack.api.response.ListResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) DedicatedResources(com.cloud.dc.DedicatedResources) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) DedicateZoneResponse(org.apache.cloudstack.api.response.DedicateZoneResponse) DedicatedResourceVO(com.cloud.dc.DedicatedResourceVO)

Aggregations

ListResponse (org.apache.cloudstack.api.response.ListResponse)149 ArrayList (java.util.ArrayList)134 List (java.util.List)62 ServerApiException (org.apache.cloudstack.api.ServerApiException)44 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)29 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)21 Network (com.cloud.network.Network)9 DedicatedResources (com.cloud.dc.DedicatedResources)8 NetworkResponse (org.apache.cloudstack.api.response.NetworkResponse)8 ResponseView (org.apache.cloudstack.api.ResponseObject.ResponseView)7 TemplateResponse (org.apache.cloudstack.api.response.TemplateResponse)7 Host (com.cloud.host.Host)6 Domain (com.cloud.domain.Domain)5 VirtualMachineTemplate (com.cloud.template.VirtualMachineTemplate)5 DedicatedResourceVO (com.cloud.dc.DedicatedResourceVO)4 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)4 InsufficientCapacityException (com.cloud.exception.InsufficientCapacityException)4 ResourceAllocationException (com.cloud.exception.ResourceAllocationException)4 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)4 Account (com.cloud.user.Account)4