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