Search in sources :

Example 1 with DedicatePodResponse

use of com.cloud.api.response.DedicatePodResponse in project cosmic by MissionCriticalCloud.

the class ListDedicatedPodsCmd method execute.

// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
    final Pair<List<? extends DedicatedResourceVO>, Integer> result = dedicatedService.listDedicatedPods(this);
    final ListResponse<DedicatePodResponse> response = new ListResponse<>();
    final List<DedicatePodResponse> Responses = new ArrayList<>();
    if (result != null) {
        for (final DedicatedResources resource : result.first()) {
            final DedicatePodResponse podresponse = dedicatedService.createDedicatePodResponse(resource);
            Responses.add(podresponse);
        }
        response.setResponses(Responses, result.second());
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to list dedicated pods");
    }
}
Also used : ListResponse(com.cloud.api.response.ListResponse) ServerApiException(com.cloud.api.ServerApiException) DedicatePodResponse(com.cloud.api.response.DedicatePodResponse) DedicatedResources(com.cloud.dc.DedicatedResources) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) DedicatedResourceVO(com.cloud.dc.DedicatedResourceVO)

Example 2 with DedicatePodResponse

use of com.cloud.api.response.DedicatePodResponse in project cosmic by MissionCriticalCloud.

the class DedicatedResourceManagerImpl method createDedicatePodResponse.

@Override
public DedicatePodResponse createDedicatePodResponse(final DedicatedResources resource) {
    final DedicatePodResponse dedicatePodResponse = new DedicatePodResponse();
    final HostPodVO pod = _podDao.findById(resource.getPodId());
    final DomainVO domain = _domainDao.findById(resource.getDomainId());
    final AccountVO account = _accountDao.findById(resource.getAccountId());
    final AffinityGroup group = _affinityGroupDao.findById(resource.getAffinityGroupId());
    dedicatePodResponse.setId(resource.getUuid());
    dedicatePodResponse.setPodId(pod.getUuid());
    dedicatePodResponse.setPodName(pod.getName());
    dedicatePodResponse.setDomainId(domain.getUuid());
    dedicatePodResponse.setDomainName(domain.getName());
    dedicatePodResponse.setAffinityGroupId(group.getUuid());
    if (account != null) {
        dedicatePodResponse.setAccountId(account.getUuid());
        dedicatePodResponse.setAccountName(account.getAccountName());
    }
    dedicatePodResponse.setObjectName("dedicatedpod");
    return dedicatePodResponse;
}
Also used : DomainVO(com.cloud.domain.DomainVO) DedicatePodResponse(com.cloud.api.response.DedicatePodResponse) HostPodVO(com.cloud.dc.HostPodVO) AccountVO(com.cloud.user.AccountVO) AffinityGroup(com.cloud.affinity.AffinityGroup)

Example 3 with DedicatePodResponse

use of com.cloud.api.response.DedicatePodResponse in project cosmic by MissionCriticalCloud.

the class DedicatePodCmd method execute.

// ///////////////////////////////////////////////////
// ///////////////// Accessors ///////////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
    final List<? extends DedicatedResources> result = dedicatedService.dedicatePod(getPodId(), getDomainId(), getAccountName());
    final ListResponse<DedicatePodResponse> response = new ListResponse<>();
    final List<DedicatePodResponse> podResponseList = new ArrayList<>();
    if (result != null) {
        for (final DedicatedResources resource : result) {
            final DedicatePodResponse podresponse = dedicatedService.createDedicatePodResponse(resource);
            podResponseList.add(podresponse);
        }
        response.setResponses(podResponseList);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to dedicate pod");
    }
}
Also used : ListResponse(com.cloud.api.response.ListResponse) ServerApiException(com.cloud.api.ServerApiException) DedicatePodResponse(com.cloud.api.response.DedicatePodResponse) DedicatedResources(com.cloud.dc.DedicatedResources) ArrayList(java.util.ArrayList)

Aggregations

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