use of com.cloud.api.response.DedicateHostResponse in project cosmic by MissionCriticalCloud.
the class DedicatedResourceManagerImpl method createDedicateHostResponse.
@Override
public DedicateHostResponse createDedicateHostResponse(final DedicatedResources resource) {
final DedicateHostResponse dedicateHostResponse = new DedicateHostResponse();
final HostVO host = _hostDao.findById(resource.getHostId());
final DomainVO domain = _domainDao.findById(resource.getDomainId());
final AccountVO account = _accountDao.findById(resource.getAccountId());
final AffinityGroup group = _affinityGroupDao.findById(resource.getAffinityGroupId());
dedicateHostResponse.setId(resource.getUuid());
dedicateHostResponse.setHostId(host.getUuid());
dedicateHostResponse.setHostName(host.getName());
dedicateHostResponse.setDomainId(domain.getUuid());
dedicateHostResponse.setDomainName(domain.getName());
dedicateHostResponse.setAffinityGroupId(group.getUuid());
if (account != null) {
dedicateHostResponse.setAccountId(account.getUuid());
dedicateHostResponse.setAccountName(account.getAccountName());
}
dedicateHostResponse.setObjectName("dedicatedhost");
return dedicateHostResponse;
}
use of com.cloud.api.response.DedicateHostResponse in project cosmic by MissionCriticalCloud.
the class ListDedicatedHostsCmd method execute.
// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////l
// ///////////////////////////////////////////////////
@Override
public void execute() {
final Pair<List<? extends DedicatedResourceVO>, Integer> result = dedicatedService.listDedicatedHosts(this);
final ListResponse<DedicateHostResponse> response = new ListResponse<>();
final List<DedicateHostResponse> Responses = new ArrayList<>();
if (result != null) {
for (final DedicatedResources resource : result.first()) {
final DedicateHostResponse hostResponse = dedicatedService.createDedicateHostResponse(resource);
Responses.add(hostResponse);
}
response.setResponses(Responses, result.second());
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to list dedicated hosts");
}
}
use of com.cloud.api.response.DedicateHostResponse in project cosmic by MissionCriticalCloud.
the class DedicateHostCmd method execute.
// ///////////////////////////////////////////////////
// ///////////////// Accessors ///////////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
final List<? extends DedicatedResources> result = dedicatedService.dedicateHost(getHostId(), getDomainId(), getAccountName());
final ListResponse<DedicateHostResponse> response = new ListResponse<>();
final List<DedicateHostResponse> hostResponseList = new ArrayList<>();
if (result != null) {
for (final DedicatedResources resource : result) {
final 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");
}
}
Aggregations