use of org.ovirt.engine.core.common.queries.SearchParameters in project ovirt-engine by oVirt.
the class VnicProfileModel method populateDataCenters.
private void populateDataCenters(Guid dcId) {
if (dcId == null) {
// $NON-NLS-1$
SearchParameters tempVar = new SearchParameters("DataCenter:", SearchType.StoragePool);
Frontend.getInstance().runQuery(QueryType.Search, tempVar, new AsyncQuery<QueryReturnValue>(returnValue -> getDataCenters().setItems(returnValue.getReturnValue())));
} else {
AsyncDataProvider.getInstance().getDataCenterById(new AsyncQuery<StoragePool>(returnValue -> getDataCenters().setItems(Arrays.asList(returnValue))), dcId);
getDataCenters().setIsChangeable(false);
}
}
use of org.ovirt.engine.core.common.queries.SearchParameters in project ovirt-engine by oVirt.
the class AbstractBackendCollectionResourceTest method setUpQueryExpectations.
protected void setUpQueryExpectations(String query, Object failure) throws Exception {
QueryReturnValue queryResult = new QueryReturnValue();
SearchParameters params = new SearchParameters(prefix + query, searchType);
queryResult.setSucceeded(failure == null);
if (failure == null) {
List<Q> entities = new ArrayList<>();
for (int i = 0; i < NAMES.length; i++) {
entities.add(getEntity(i));
}
queryResult.setReturnValue(entities);
when(backend.runQuery(eq(QueryType.Search), eqSearchParams(params))).thenReturn(queryResult);
} else {
if (failure instanceof String) {
queryResult.setExceptionString((String) failure);
setUpL10nExpectations((String) failure);
when(backend.runQuery(eq(QueryType.Search), eqSearchParams(params))).thenReturn(queryResult);
} else if (failure instanceof Exception) {
when(backend.runQuery(eq(QueryType.Search), eqSearchParams(params))).thenThrow((Exception) failure);
}
}
enqueueInteraction(() -> verify(backend, atLeastOnce()).runQuery(eq(QueryType.Search), eqSearchParams(params)));
}
use of org.ovirt.engine.core.common.queries.SearchParameters in project ovirt-engine by oVirt.
the class VmImportGeneralModel method updateProperties.
private void updateProperties() {
VM vm = getEntity().getVm();
updateVmNamesMap(getName().getEntity());
editedVmId = vm.getId();
super.updateProperties(vm.getId());
addVmOriginalNameToMapIfMissing();
getName().setEntity(getVmEditedName());
getOperatingSystems().setItems(AsyncDataProvider.getInstance().getOsIds(vm.getClusterArch()));
setDescription(vm.getVmDescription());
// $NON-NLS-1$
setQuotaName(vm.getQuotaName() != null ? vm.getQuotaName() : "");
setQuotaAvailable(vm.getQuotaEnforcementType() != null && !vm.getQuotaEnforcementType().equals(QuotaEnforcementTypeEnum.DISABLED));
setTemplate(vmTemplateNameRenderer.render(vm));
// $NON-NLS-1$
setDefinedMemory(vm.getVmMemSizeMb() + " MB");
// $NON-NLS-1$
setMinAllocatedMemory(vm.getMinAllocatedMem() + " MB");
if (vm.isRunningOrPaused() && vm.getGuestMemoryBuffered() != null && vm.getGuestMemoryCached() != null && vm.getGuestMemoryFree() != null) {
setGuestFreeCachedBufferedMemInfo(// $NON-NLS-1$
(vm.getGuestMemoryFree() / 1024L) + " / " + (vm.getGuestMemoryBuffered() / 1024L) + // $NON-NLS-1$
" / " + (vm.getGuestMemoryCached() / 1024L) + // $NON-NLS-1$
" MB");
} else {
// Handled in form
setGuestFreeCachedBufferedMemInfo(null);
}
setOS(AsyncDataProvider.getInstance().getOsName(vm.getVmOsId()));
setDefaultDisplayType(translator.translate(vm.getDefaultDisplayType()));
setIsHighlyAvailable(vm.isAutoStartup());
setPriority(AsyncDataProvider.getInstance().priorityToString(vm.getPriority()));
setMonitorCount(vm.getNumOfMonitors());
setUsbPolicy(translator.translate(vm.getUsbPolicy()));
setCpuInfo(ConstantsManager.getInstance().getMessages().cpuInfoLabel(vm.getNumOfCpus(), vm.getNumOfSockets(), vm.getCpuPerSocket(), vm.getThreadsPerCpu()));
setGuestCpuCount(vm.getGuestCpuCount());
setHasDomain(AsyncDataProvider.getInstance().isWindowsOsType(vm.getVmOsId()));
if (vm.getVmInit() != null) {
setDomain(vm.getVmInit().getDomain());
}
setHasTimeZone(AsyncDataProvider.getInstance().isWindowsOsType(vm.getVmOsId()));
setTimeZone(vm.getTimeZone());
setHasCustomProperties(!StringHelper.isNullOrEmpty(vm.getCustomProperties()));
setCustomProperties(getHasCustomProperties() ? constants.configured() : constants.notConfigured());
setCompatibilityVersion(vm.getCompatibilityVersion() != null ? vm.getCompatibilityVersion().toString() : // $NON-NLS-1$
"");
setVmId(vm.getId().toString());
setFqdn(vm.getFqdn());
setHasAlert(vm.getVmPauseStatus() != VmPauseStatus.NONE && vm.getVmPauseStatus() != VmPauseStatus.NOERR);
if (getHasAlert()) {
setAlert(translator.translate(vm.getVmPauseStatus()));
} else {
setAlert(null);
}
setHasDefaultHost(!vm.getDedicatedVmForVdsList().isEmpty());
if (getHasDefaultHost()) {
Frontend.getInstance().runQuery(QueryType.Search, new SearchParameters(// $NON-NLS-1$
"Host: cluster = " + vm.getClusterName() + " sortby name", SearchType.VDS), new AsyncQuery<QueryReturnValue>(returnValue -> {
// $NON-NLS-1$
VM localVm = getEntity() != null ? getEntity().getVm() : null;
if (localVm == null) {
return;
}
ArrayList<VDS> hosts = returnValue.getReturnValue();
for (VDS host : hosts) {
if (localVm.getDedicatedVmForVdsList().contains(host.getId())) {
setDefaultHost(host.getName());
break;
}
}
}));
} else {
setDefaultHost(ConstantsManager.getInstance().getConstants().anyHostInCluster());
}
setOptimizedForSystemProfile(translator.translate(vm.getVmType()));
}
Aggregations