Search in sources :

Example 1 with DedicatedResources

use of com.cloud.dc.DedicatedResources 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 2 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 3 with DedicatedResources

use of com.cloud.dc.DedicatedResources 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 : DedicateClusterResponse(org.apache.cloudstack.api.response.DedicateClusterResponse) 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 4 with DedicatedResources

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

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

Aggregations

DedicatedResources (com.cloud.dc.DedicatedResources)15 ArrayList (java.util.ArrayList)15 ServerApiException (com.cloud.api.ServerApiException)8 ListResponse (com.cloud.api.response.ListResponse)8 DedicatedResourceVO (com.cloud.dc.DedicatedResourceVO)8 List (java.util.List)8 ServerApiException (org.apache.cloudstack.api.ServerApiException)7 ListResponse (org.apache.cloudstack.api.response.ListResponse)7 DedicateClusterResponse (com.cloud.api.response.DedicateClusterResponse)2 DedicateHostResponse (com.cloud.api.response.DedicateHostResponse)2 DedicatePodResponse (com.cloud.api.response.DedicatePodResponse)2 DedicateZoneResponse (com.cloud.api.response.DedicateZoneResponse)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 DedicateClusterResponse (org.apache.cloudstack.api.response.DedicateClusterResponse)1