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;
}
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");
}
}
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");
}
}
Aggregations