use of org.apache.cloudstack.api.response.DedicateHostResponse in project cloudstack by apache.
the class ListDedicatedHostsCmd method execute.
@Override
public void execute() {
Pair<List<? extends DedicatedResourceVO>, Integer> result = dedicatedService.listDedicatedHosts(this);
ListResponse<DedicateHostResponse> response = new ListResponse<DedicateHostResponse>();
List<DedicateHostResponse> Responses = new ArrayList<DedicateHostResponse>();
if (result != null) {
for (DedicatedResources resource : result.first()) {
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 org.apache.cloudstack.api.response.DedicateHostResponse in project cloudstack by apache.
the class DedicatedResourceManagerImpl method createDedicateHostResponse.
@Override
public DedicateHostResponse createDedicateHostResponse(DedicatedResources resource) {
DedicateHostResponse dedicateHostResponse = new DedicateHostResponse();
HostVO host = _hostDao.findById(resource.getHostId());
DomainVO domain = _domainDao.findById(resource.getDomainId());
AccountVO account = _accountDao.findById(resource.getAccountId());
AffinityGroup group = _affinityGroupDao.findById(resource.getAffinityGroupId());
dedicateHostResponse.setId(resource.getUuid());
dedicateHostResponse.setHostId(host.getUuid());
dedicateHostResponse.setHostName(host.getName());
dedicateHostResponse.setDomainId(domain.getUuid());
dedicateHostResponse.setAffinityGroupId(group.getUuid());
if (account != null) {
dedicateHostResponse.setAccountId(account.getUuid());
}
dedicateHostResponse.setObjectName("dedicatedhost");
return dedicateHostResponse;
}
use of org.apache.cloudstack.api.response.DedicateHostResponse in project cloudstack by apache.
the class DedicateHostCmd method execute.
@Override
public void execute() {
List<? extends DedicatedResources> result = dedicatedService.dedicateHost(getHostId(), getDomainId(), getAccountName());
ListResponse<DedicateHostResponse> response = new ListResponse<DedicateHostResponse>();
List<DedicateHostResponse> hostResponseList = new ArrayList<DedicateHostResponse>();
if (result != null) {
for (DedicatedResources resource : result) {
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