Search in sources :

Example 1 with DedicateHostResponse

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;
}
Also used : DomainVO(com.cloud.domain.DomainVO) DedicateHostResponse(com.cloud.api.response.DedicateHostResponse) AccountVO(com.cloud.user.AccountVO) HostVO(com.cloud.host.HostVO) AffinityGroup(com.cloud.affinity.AffinityGroup)

Example 2 with 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");
    }
}
Also used : DedicateHostResponse(com.cloud.api.response.DedicateHostResponse) 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)

Example 3 with DedicateHostResponse

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");
    }
}
Also used : DedicateHostResponse(com.cloud.api.response.DedicateHostResponse) ListResponse(com.cloud.api.response.ListResponse) ServerApiException(com.cloud.api.ServerApiException) DedicatedResources(com.cloud.dc.DedicatedResources) ArrayList(java.util.ArrayList)

Aggregations

DedicateHostResponse (com.cloud.api.response.DedicateHostResponse)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 DedicatedResourceVO (com.cloud.dc.DedicatedResourceVO)1 DomainVO (com.cloud.domain.DomainVO)1 HostVO (com.cloud.host.HostVO)1 AccountVO (com.cloud.user.AccountVO)1 List (java.util.List)1