Search in sources :

Example 1 with DedicateZoneResponse

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

the class DedicateZoneCmd method execute.

// ///////////////////////////////////////////////////
// ///////////////// Accessors ///////////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
    final List<? extends DedicatedResources> result = dedicatedService.dedicateZone(getZoneId(), getDomainId(), getAccountName());
    final ListResponse<DedicateZoneResponse> response = new ListResponse<>();
    final List<DedicateZoneResponse> zoneResponseList = new ArrayList<>();
    if (result != null) {
        for (final DedicatedResources resource : result) {
            final 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(com.cloud.api.response.ListResponse) ServerApiException(com.cloud.api.ServerApiException) DedicatedResources(com.cloud.dc.DedicatedResources) ArrayList(java.util.ArrayList) DedicateZoneResponse(com.cloud.api.response.DedicateZoneResponse)

Example 2 with DedicateZoneResponse

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

the class DedicatedResourceManagerImpl method createDedicateZoneResponse.

@Override
public DedicateZoneResponse createDedicateZoneResponse(final DedicatedResources resource) {
    final DedicateZoneResponse dedicateZoneResponse = new DedicateZoneResponse();
    final Zone zone = zoneRepository.findOne(resource.getDataCenterId());
    final DomainVO domain = _domainDao.findById(resource.getDomainId());
    final AccountVO account = _accountDao.findById(resource.getAccountId());
    final AffinityGroup group = _affinityGroupDao.findById(resource.getAffinityGroupId());
    dedicateZoneResponse.setId(resource.getUuid());
    dedicateZoneResponse.setZoneId(zone.getUuid());
    dedicateZoneResponse.setZoneName(zone.getName());
    dedicateZoneResponse.setDomainId(domain.getUuid());
    dedicateZoneResponse.setDomainName(domain.getName());
    dedicateZoneResponse.setAffinityGroupId(group.getUuid());
    if (account != null) {
        dedicateZoneResponse.setAccountId(account.getUuid());
        dedicateZoneResponse.setAccountName(account.getAccountName());
    }
    dedicateZoneResponse.setObjectName("dedicatedzone");
    return dedicateZoneResponse;
}
Also used : DomainVO(com.cloud.domain.DomainVO) Zone(com.cloud.db.model.Zone) DedicateZoneResponse(com.cloud.api.response.DedicateZoneResponse) AccountVO(com.cloud.user.AccountVO) AffinityGroup(com.cloud.affinity.AffinityGroup)

Example 3 with DedicateZoneResponse

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

the class ListDedicatedZonesCmd method execute.

// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
    final Pair<List<? extends DedicatedResourceVO>, Integer> result = _dedicatedservice.listDedicatedZones(this);
    final ListResponse<DedicateZoneResponse> response = new ListResponse<>();
    final List<DedicateZoneResponse> Responses = new ArrayList<>();
    if (result != null) {
        for (final DedicatedResources resource : result.first()) {
            final 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(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) DedicateZoneResponse(com.cloud.api.response.DedicateZoneResponse) DedicatedResourceVO(com.cloud.dc.DedicatedResourceVO)

Aggregations

DedicateZoneResponse (com.cloud.api.response.DedicateZoneResponse)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 Zone (com.cloud.db.model.Zone)1 DedicatedResourceVO (com.cloud.dc.DedicatedResourceVO)1 DomainVO (com.cloud.domain.DomainVO)1 AccountVO (com.cloud.user.AccountVO)1 List (java.util.List)1