Search in sources :

Example 1 with DedicateZoneResponse

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

the class DedicateZoneCmd method execute.

@Override
public void execute() {
    List<? extends DedicatedResources> result = dedicatedService.dedicateZone(getZoneId(), getDomainId(), getAccountName());
    ListResponse<DedicateZoneResponse> response = new ListResponse<DedicateZoneResponse>();
    List<DedicateZoneResponse> zoneResponseList = new ArrayList<DedicateZoneResponse>();
    if (result != null) {
        for (DedicatedResources resource : result) {
            DedicateZoneResponse zoneresponse = dedicatedService.createDedicateZoneResponse(resource);
            zoneResponseList.add(zoneresponse);
        }
        response.setResponses(zoneResponseList);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to dedicate zone");
    }
}
Also used : ListResponse(org.apache.cloudstack.api.response.ListResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) DedicatedResources(com.cloud.dc.DedicatedResources) ArrayList(java.util.ArrayList) DedicateZoneResponse(org.apache.cloudstack.api.response.DedicateZoneResponse)

Example 2 with DedicateZoneResponse

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

the class ListDedicatedZonesCmd method execute.

@Override
public void execute() {
    Pair<List<? extends DedicatedResourceVO>, Integer> result = _dedicatedservice.listDedicatedZones(this);
    ListResponse<DedicateZoneResponse> response = new ListResponse<DedicateZoneResponse>();
    List<DedicateZoneResponse> Responses = new ArrayList<DedicateZoneResponse>();
    if (result != null) {
        for (DedicatedResources resource : result.first()) {
            DedicateZoneResponse zoneResponse = _dedicatedservice.createDedicateZoneResponse(resource);
            Responses.add(zoneResponse);
        }
        response.setResponses(Responses, result.second());
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to list dedicated zones");
    }
}
Also used : ListResponse(org.apache.cloudstack.api.response.ListResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) DedicatedResources(com.cloud.dc.DedicatedResources) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) DedicateZoneResponse(org.apache.cloudstack.api.response.DedicateZoneResponse) DedicatedResourceVO(com.cloud.dc.DedicatedResourceVO)

Example 3 with DedicateZoneResponse

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

the class DedicatedResourceManagerImpl method createDedicateZoneResponse.

@Override
public DedicateZoneResponse createDedicateZoneResponse(DedicatedResources resource) {
    DedicateZoneResponse dedicateZoneResponse = new DedicateZoneResponse();
    DataCenterVO dc = _zoneDao.findById(resource.getDataCenterId());
    DomainVO domain = _domainDao.findById(resource.getDomainId());
    AccountVO account = _accountDao.findById(resource.getAccountId());
    AffinityGroup group = _affinityGroupDao.findById(resource.getAffinityGroupId());
    dedicateZoneResponse.setId(resource.getUuid());
    dedicateZoneResponse.setZoneId(dc.getUuid());
    dedicateZoneResponse.setZoneName(dc.getName());
    dedicateZoneResponse.setDomainId(domain.getUuid());
    dedicateZoneResponse.setAffinityGroupId(group.getUuid());
    if (account != null) {
        dedicateZoneResponse.setAccountId(account.getUuid());
    }
    dedicateZoneResponse.setObjectName("dedicatedzone");
    return dedicateZoneResponse;
}
Also used : DataCenterVO(com.cloud.dc.DataCenterVO) DomainVO(com.cloud.domain.DomainVO) DedicateZoneResponse(org.apache.cloudstack.api.response.DedicateZoneResponse) AccountVO(com.cloud.user.AccountVO) AffinityGroup(org.apache.cloudstack.affinity.AffinityGroup)

Aggregations

DedicateZoneResponse (org.apache.cloudstack.api.response.DedicateZoneResponse)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 DataCenterVO (com.cloud.dc.DataCenterVO)1 DedicatedResourceVO (com.cloud.dc.DedicatedResourceVO)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