Search in sources :

Example 1 with DedicateClusterResponse

use of com.cloud.api.response.DedicateClusterResponse in project cosmic by MissionCriticalCloud.

the class DedicatedResourceManagerImpl method createDedicateClusterResponse.

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

Example 2 with DedicateClusterResponse

use of com.cloud.api.response.DedicateClusterResponse in project cosmic by MissionCriticalCloud.

the class DedicateClusterCmd method execute.

@Override
public void execute() {
    final List<? extends DedicatedResources> result = dedicatedService.dedicateCluster(getClusterId(), getDomainId(), getAccountName());
    final ListResponse<DedicateClusterResponse> response = new ListResponse<>();
    final List<DedicateClusterResponse> clusterResponseList = new ArrayList<>();
    if (result != null) {
        for (final DedicatedResources resource : result) {
            final DedicateClusterResponse clusterResponse = dedicatedService.createDedicateClusterResponse(resource);
            clusterResponseList.add(clusterResponse);
        }
        response.setResponses(clusterResponseList);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to dedicate cluster");
    }
}
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)

Example 3 with DedicateClusterResponse

use of com.cloud.api.response.DedicateClusterResponse 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)

Aggregations

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