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");
}
}
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;
}
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");
}
}
Aggregations