Search in sources :

Example 1 with DedicateClusterResponse

use of org.apache.cloudstack.api.response.DedicateClusterResponse 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 2 with DedicateClusterResponse

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

the class DedicatedResourceManagerImpl method createDedicateClusterResponse.

@Override
public DedicateClusterResponse createDedicateClusterResponse(DedicatedResources resource) {
    DedicateClusterResponse dedicateClusterResponse = new DedicateClusterResponse();
    ClusterVO cluster = _clusterDao.findById(resource.getClusterId());
    DomainVO domain = _domainDao.findById(resource.getDomainId());
    AccountVO account = _accountDao.findById(resource.getAccountId());
    AffinityGroup group = _affinityGroupDao.findById(resource.getAffinityGroupId());
    dedicateClusterResponse.setId(resource.getUuid());
    dedicateClusterResponse.setClusterId(cluster.getUuid());
    dedicateClusterResponse.setClusterName(cluster.getName());
    dedicateClusterResponse.setDomainId(domain.getUuid());
    dedicateClusterResponse.setAffinityGroupId(group.getUuid());
    if (account != null) {
        dedicateClusterResponse.setAccountId(account.getUuid());
    }
    dedicateClusterResponse.setObjectName("dedicatedcluster");
    return dedicateClusterResponse;
}
Also used : DomainVO(com.cloud.domain.DomainVO) ClusterVO(com.cloud.dc.ClusterVO) DedicateClusterResponse(org.apache.cloudstack.api.response.DedicateClusterResponse) AccountVO(com.cloud.user.AccountVO) AffinityGroup(org.apache.cloudstack.affinity.AffinityGroup)

Example 3 with DedicateClusterResponse

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

the class DedicateClusterCmd method execute.

@Override
public void execute() {
    List<? extends DedicatedResources> result = dedicatedService.dedicateCluster(getClusterId(), getDomainId(), getAccountName());
    ListResponse<DedicateClusterResponse> response = new ListResponse<DedicateClusterResponse>();
    List<DedicateClusterResponse> clusterResponseList = new ArrayList<DedicateClusterResponse>();
    // List of result should always contain single element as only one cluster will be associated with each cluster ID.
    if (result != null && result.size() == 1) {
        DedicateClusterResponse clusterResponse = dedicatedService.createDedicateClusterResponse(result.get(0));
        clusterResponse.setResponseName(getCommandName());
        this.setResponseObject(clusterResponse);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to dedicate cluster");
    }
}
Also used : DedicateClusterResponse(org.apache.cloudstack.api.response.DedicateClusterResponse) ListResponse(org.apache.cloudstack.api.response.ListResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) ArrayList(java.util.ArrayList)

Aggregations

DedicateClusterResponse (org.apache.cloudstack.api.response.DedicateClusterResponse)3 ArrayList (java.util.ArrayList)2 ServerApiException (org.apache.cloudstack.api.ServerApiException)2 ListResponse (org.apache.cloudstack.api.response.ListResponse)2 ClusterVO (com.cloud.dc.ClusterVO)1 DedicatedResourceVO (com.cloud.dc.DedicatedResourceVO)1 DedicatedResources (com.cloud.dc.DedicatedResources)1 DomainVO (com.cloud.domain.DomainVO)1 AccountVO (com.cloud.user.AccountVO)1 List (java.util.List)1 AffinityGroup (org.apache.cloudstack.affinity.AffinityGroup)1