Search in sources :

Example 6 with DedicatedResources

use of com.cloud.dc.DedicatedResources 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)

Example 7 with DedicatedResources

use of com.cloud.dc.DedicatedResources in project cloudstack by apache.

the class DedicateHostCmd method execute.

@Override
public void execute() {
    List<? extends DedicatedResources> result = dedicatedService.dedicateHost(getHostId(), getDomainId(), getAccountName());
    ListResponse<DedicateHostResponse> response = new ListResponse<DedicateHostResponse>();
    List<DedicateHostResponse> hostResponseList = new ArrayList<DedicateHostResponse>();
    if (result != null) {
        for (DedicatedResources resource : result) {
            DedicateHostResponse hostResponse = dedicatedService.createDedicateHostResponse(resource);
            hostResponseList.add(hostResponse);
        }
        response.setResponses(hostResponseList);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to dedicate host");
    }
}
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)

Example 8 with DedicatedResources

use of com.cloud.dc.DedicatedResources in project cloudstack by apache.

the class DedicatePodCmd method execute.

@Override
public void execute() {
    List<? extends DedicatedResources> result = dedicatedService.dedicatePod(getPodId(), getDomainId(), getAccountName());
    ListResponse<DedicatePodResponse> response = new ListResponse<DedicatePodResponse>();
    List<DedicatePodResponse> podResponseList = new ArrayList<DedicatePodResponse>();
    if (result != null) {
        for (DedicatedResources resource : result) {
            DedicatePodResponse podresponse = dedicatedService.createDedicatePodResponse(resource);
            podResponseList.add(podresponse);
        }
        response.setResponses(podResponseList);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to dedicate pod");
    }
}
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)

Aggregations

DedicatedResources (com.cloud.dc.DedicatedResources)8 ArrayList (java.util.ArrayList)8 ServerApiException (org.apache.cloudstack.api.ServerApiException)8 ListResponse (org.apache.cloudstack.api.response.ListResponse)8 DedicatedResourceVO (com.cloud.dc.DedicatedResourceVO)4 List (java.util.List)4 DedicateClusterResponse (org.apache.cloudstack.api.response.DedicateClusterResponse)2 DedicateHostResponse (org.apache.cloudstack.api.response.DedicateHostResponse)2 DedicatePodResponse (org.apache.cloudstack.api.response.DedicatePodResponse)2 DedicateZoneResponse (org.apache.cloudstack.api.response.DedicateZoneResponse)2