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