Search in sources :

Example 1 with DedicatePodResponse

use of org.apache.cloudstack.api.response.DedicatePodResponse in project cloudstack by apache.

the class DedicatedResourceManagerImpl method createDedicatePodResponse.

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

Example 2 with DedicatePodResponse

use of org.apache.cloudstack.api.response.DedicatePodResponse in project cloudstack by apache.

the class ListDedicatedPodsCmd method execute.

@Override
public void execute() {
    Pair<List<? extends DedicatedResourceVO>, Integer> result = dedicatedService.listDedicatedPods(this);
    ListResponse<DedicatePodResponse> response = new ListResponse<DedicatePodResponse>();
    List<DedicatePodResponse> Responses = new ArrayList<DedicatePodResponse>();
    if (result != null) {
        for (DedicatedResources resource : result.first()) {
            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(org.apache.cloudstack.api.response.ListResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) DedicatePodResponse(org.apache.cloudstack.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 3 with DedicatePodResponse

use of org.apache.cloudstack.api.response.DedicatePodResponse in project cloudstack by apache.

the class DedicatePodCmd method execute.

@Override
public void execute() {
    List<? extends DedicatedResources> result = dedicatedService.dedicatePod(getPodId(), getDomainId(), getAccountName());
    ListResponse<DedicatePodResponse> response = new ListResponse<DedicatePodResponse>();
    List<DedicatePodResponse> podResponseList = new ArrayList<DedicatePodResponse>();
    if (result != null) {
        for (DedicatedResources resource : result) {
            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(org.apache.cloudstack.api.response.ListResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) DedicatePodResponse(org.apache.cloudstack.api.response.DedicatePodResponse) DedicatedResources(com.cloud.dc.DedicatedResources) ArrayList(java.util.ArrayList)

Aggregations

DedicatePodResponse (org.apache.cloudstack.api.response.DedicatePodResponse)3 DedicatedResources (com.cloud.dc.DedicatedResources)2 ArrayList (java.util.ArrayList)2 ServerApiException (org.apache.cloudstack.api.ServerApiException)2 ListResponse (org.apache.cloudstack.api.response.ListResponse)2 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 AffinityGroup (org.apache.cloudstack.affinity.AffinityGroup)1