Search in sources :

Example 11 with DedicatedResources

use of com.cloud.dc.DedicatedResources in project cosmic by MissionCriticalCloud.

the class DedicatePodCmd method execute.

// ///////////////////////////////////////////////////
// ///////////////// Accessors ///////////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
    final List<? extends DedicatedResources> result = dedicatedService.dedicatePod(getPodId(), getDomainId(), getAccountName());
    final ListResponse<DedicatePodResponse> response = new ListResponse<>();
    final List<DedicatePodResponse> podResponseList = new ArrayList<>();
    if (result != null) {
        for (final DedicatedResources resource : result) {
            final 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(com.cloud.api.response.ListResponse) ServerApiException(com.cloud.api.ServerApiException) DedicatePodResponse(com.cloud.api.response.DedicatePodResponse) DedicatedResources(com.cloud.dc.DedicatedResources) ArrayList(java.util.ArrayList)

Example 12 with DedicatedResources

use of com.cloud.dc.DedicatedResources in project cosmic by MissionCriticalCloud.

the class ListDedicatedClustersCmd method execute.

// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
    final Pair<List<? extends DedicatedResourceVO>, Integer> result = dedicatedService.listDedicatedClusters(this);
    final ListResponse<DedicateClusterResponse> response = new ListResponse<>();
    final List<DedicateClusterResponse> Responses = new ArrayList<>();
    if (result != null) {
        for (final DedicatedResources resource : result.first()) {
            final 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(com.cloud.api.response.DedicateClusterResponse) ListResponse(com.cloud.api.response.ListResponse) ServerApiException(com.cloud.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 13 with DedicatedResources

use of com.cloud.dc.DedicatedResources in project cosmic by MissionCriticalCloud.

the class ListDedicatedZonesCmd method execute.

// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
    final Pair<List<? extends DedicatedResourceVO>, Integer> result = _dedicatedservice.listDedicatedZones(this);
    final ListResponse<DedicateZoneResponse> response = new ListResponse<>();
    final List<DedicateZoneResponse> Responses = new ArrayList<>();
    if (result != null) {
        for (final DedicatedResources resource : result.first()) {
            final 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(com.cloud.api.response.ListResponse) ServerApiException(com.cloud.api.ServerApiException) DedicatedResources(com.cloud.dc.DedicatedResources) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) DedicateZoneResponse(com.cloud.api.response.DedicateZoneResponse) DedicatedResourceVO(com.cloud.dc.DedicatedResourceVO)

Example 14 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 15 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)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