use of com.cloud.api.response.ListResponse in project cosmic by MissionCriticalCloud.
the class ApiResponseHelper method createUpgradeRouterTemplateResponse.
@Override
public ListResponse<UpgradeRouterTemplateResponse> createUpgradeRouterTemplateResponse(final List<Long> jobIds) {
final ListResponse<UpgradeRouterTemplateResponse> response = new ListResponse<>();
final List<UpgradeRouterTemplateResponse> responses = new ArrayList<>();
for (final Long jobId : jobIds) {
final UpgradeRouterTemplateResponse routerResponse = new UpgradeRouterTemplateResponse();
final AsyncJob job = _entityMgr.findById(AsyncJob.class, jobId);
routerResponse.setAsyncJobId(job.getUuid());
routerResponse.setObjectName("asyncjobs");
responses.add(routerResponse);
}
response.setResponses(responses);
return response;
}
use of com.cloud.api.response.ListResponse in project cosmic by MissionCriticalCloud.
the class QueryManagerImpl method searchForDomains.
@Override
public ListResponse<DomainResponse> searchForDomains(final ListDomainsCmd cmd) {
final Pair<List<DomainJoinVO>, Integer> result = searchForDomainsInternal(cmd);
final ListResponse<DomainResponse> response = new ListResponse<>();
ResponseView respView = ResponseView.Restricted;
if (cmd instanceof ListDomainsCmdByAdmin) {
respView = ResponseView.Full;
}
final List<DomainResponse> domainResponses = ViewResponseHelper.createDomainResponse(respView, result.first().toArray(new DomainJoinVO[result.first().size()]));
response.setResponses(domainResponses, result.second());
return response;
}
use of com.cloud.api.response.ListResponse in project cosmic by MissionCriticalCloud.
the class QueryManagerImpl method listHAWorkers.
@Override
public ListResponse<HAWorkerResponse> listHAWorkers(final ListHAWorkersCmd cmd) {
final ListResponse<HAWorkerResponse> haWorkerList = new ListResponse<>();
final List<HaWorkVO> haWorkers = _haDao.listAll();
final List<HAWorkerResponse> haWorkerResponses = new ArrayList<>();
haWorkers.stream().filter(haWorker -> {
final Account account = CallContext.current().getCallingAccount();
if (account.getDomainId() == Domain.ROOT_DOMAIN) {
return cmd.getId() == null || (cmd.getId() != null && cmd.getId() == haWorker.getId());
}
// Not a root administrator, check if the user owns the virtual machine
final VirtualMachine virtualMachine = _vmInstanceDao.findByIdIncludingRemoved(haWorker.getInstanceId());
return virtualMachine != null && virtualMachine.getDomainId() == account.getDomainId() && (cmd.getId() == null || (cmd.getId() != null && haWorker.getId() == cmd.getId()));
}).forEach(haWorker -> {
final HAWorkerResponse haWorkerResponse = new HAWorkerResponse();
haWorkerResponse.setObjectName("haworker");
haWorkerResponse.setId(haWorker.getId());
haWorkerResponse.setType(haWorker.getWorkType());
haWorkerResponse.setCreated(haWorker.getCreated());
haWorkerResponse.setStep(haWorker.getStep());
haWorkerResponse.setTaken(haWorker.getDateTaken());
haWorkerResponse.setState(haWorker.getPreviousState());
final VirtualMachine virtualMachine = _vmInstanceDao.findByIdIncludingRemoved(haWorker.getInstanceId());
if (virtualMachine != null) {
haWorkerResponse.setVirtualMachineId(virtualMachine.getUuid());
haWorkerResponse.setVirtualMachineName(virtualMachine.getInstanceName());
haWorkerResponse.setVirtualMachineState(virtualMachine.getState());
final Domain domain = _domainDao.findById(virtualMachine.getDomainId());
if (domain != null) {
haWorkerResponse.setDomainId(domain.getUuid());
haWorkerResponse.setDomainName(domain.getName());
}
}
final Host host = _hostDao.findById(haWorker.getHostId());
if (host != null) {
haWorkerResponse.setHypervisor(host.getName());
}
if (haWorker.getServerId() != null) {
final ManagementServerHost managementServerHost = _mgmtServerHostDao.findByMsid(haWorker.getServerId());
if (managementServerHost != null) {
haWorkerResponse.setManagementServerName(managementServerHost.getName());
}
}
haWorkerResponses.add(haWorkerResponse);
});
haWorkerList.setResponses(haWorkerResponses);
return haWorkerList;
}
use of com.cloud.api.response.ListResponse in project cosmic by MissionCriticalCloud.
the class QueryManagerImpl method searchForStoragePools.
@Override
public ListResponse<StoragePoolResponse> searchForStoragePools(final ListStoragePoolsCmd cmd) {
final Pair<List<StoragePoolJoinVO>, Integer> result = searchForStoragePoolsInternal(cmd);
final ListResponse<StoragePoolResponse> response = new ListResponse<>();
final List<StoragePoolResponse> poolResponses = ViewResponseHelper.createStoragePoolResponse(result.first().toArray(new StoragePoolJoinVO[result.first().size()]));
for (final StoragePoolResponse poolResponse : poolResponses) {
final DataStore store = dataStoreManager.getPrimaryDataStore(poolResponse.getId());
if (store != null) {
final DataStoreDriver driver = store.getDriver();
if (driver != null && driver.getCapabilities() != null) {
poolResponse.setCaps(driver.getCapabilities());
}
}
}
response.setResponses(poolResponses, result.second());
return response;
}
use of com.cloud.api.response.ListResponse in project cosmic by MissionCriticalCloud.
the class QueryManagerImpl method listDataCenters.
@Override
public ListResponse<ZoneResponse> listDataCenters(final ListZonesCmd cmd) {
final Pair<List<DataCenterJoinVO>, Integer> result = listDataCentersInternal(cmd);
final ListResponse<ZoneResponse> response = new ListResponse<>();
ResponseView respView = ResponseView.Restricted;
if (cmd instanceof ListZonesCmdByAdmin) {
respView = ResponseView.Full;
}
final List<ZoneResponse> dcResponses = ViewResponseHelper.createDataCenterResponse(respView, cmd.getShowCapacities(), result.first().toArray(new DataCenterJoinVO[result.first().size()]));
response.setResponses(dcResponses, result.second());
return response;
}
Aggregations