use of org.ovirt.engine.ui.frontend.AsyncQuery in project ovirt-engine by oVirt.
the class NewTemplateVmModelBehavior method updateTemplate.
protected void updateTemplate() {
final DataCenterWithCluster dataCenterWithCluster = getModel().getDataCenterWithClustersList().getSelectedItem();
StoragePool dataCenter = dataCenterWithCluster == null ? null : dataCenterWithCluster.getDataCenter();
if (dataCenter == null) {
return;
}
AsyncDataProvider.getInstance().getTemplateListByDataCenter(new AsyncQuery<>(templates -> postInitTemplate(AsyncDataProvider.getInstance().filterTemplatesByArchitecture(templates, dataCenterWithCluster.getCluster().getArchitecture()))), dataCenter.getId());
}
use of org.ovirt.engine.ui.frontend.AsyncQuery in project ovirt-engine by oVirt.
the class NewVmModelBehavior method updateTemplate.
private void updateTemplate() {
final DataCenterWithCluster dataCenterWithCluster = getModel().getDataCenterWithClustersList().getSelectedItem();
StoragePool dataCenter = dataCenterWithCluster == null ? null : dataCenterWithCluster.getDataCenter();
if (dataCenter == null) {
return;
}
AsyncDataProvider.getInstance().getTemplateListByDataCenter(asyncQuery(templates -> postInitTemplate(AsyncDataProvider.getInstance().filterTemplatesByArchitecture(templates, dataCenterWithCluster.getCluster().getArchitecture()))), dataCenter.getId());
}
use of org.ovirt.engine.ui.frontend.AsyncQuery in project ovirt-engine by oVirt.
the class ExistingVmModelBehavior method loadDataCenter.
private void loadDataCenter() {
// Preinitialize the VM compatibility version because it's needed during init
Version newCustomCompatibilityVersion = ((ExistingVmModelBehavior) getModel().getBehavior()).getVm().getStaticData().getCustomCompatibilityVersion();
if (newCustomCompatibilityVersion != null) {
getModel().getCustomCompatibilityVersion().setItems(Collections.singletonList(newCustomCompatibilityVersion), newCustomCompatibilityVersion);
}
AsyncDataProvider.getInstance().getDataCenterById(asyncQuery(dataCenter -> {
if (dataCenter != null) {
final List<StoragePool> dataCenters = new ArrayList<>(Arrays.asList(new StoragePool[] { dataCenter }));
initClusters(dataCenters);
} else {
ExistingVmModelBehavior behavior = (ExistingVmModelBehavior) getModel().getBehavior();
VM currentVm = behavior.vm;
Cluster cluster = new Cluster();
cluster.setId(currentVm.getClusterId());
cluster.setName(currentVm.getClusterName());
cluster.setCompatibilityVersion(currentVm.getClusterCompatibilityVersion());
cluster.setStoragePoolId(currentVm.getStoragePoolId());
DataCenterWithCluster dataCenterWithCluster = new DataCenterWithCluster(null, cluster);
getModel().getDataCenterWithClustersList().setItems(Arrays.asList(dataCenterWithCluster));
getModel().getDataCenterWithClustersList().setSelectedItem(dataCenterWithCluster);
behavior.initTemplate();
behavior.updateCdImage();
}
}), vm.getStoragePoolId());
}
use of org.ovirt.engine.ui.frontend.AsyncQuery in project ovirt-engine by oVirt.
the class TemplateVmModelBehavior method initialize.
@Override
public void initialize() {
super.initialize();
getModel().getTemplateWithVersion().setIsChangeable(false);
getModel().getBaseTemplate().setIsChangeable(false);
getModel().getTemplateWithVersion().setIsChangeable(false);
getModel().getProvisioning().setIsChangeable(false);
getModel().getStorageDomain().setIsChangeable(false);
getModel().getIsSoundcardEnabled().setIsChangeable(true);
getModel().getVmType().setIsChangeable(true);
getModel().getTemplateVersionName().setIsChangeable(!template.isBaseTemplate());
getModel().getName().setIsChangeable(template.isBaseTemplate());
if (template.getStoragePoolId() != null && !template.getStoragePoolId().equals(Guid.Empty)) {
AsyncDataProvider.getInstance().getDataCenterById(new AsyncQuery<>(dataCenter -> AsyncDataProvider.getInstance().getClusterListByService(new AsyncQuery<>(clusters -> {
ArrayList<Cluster> clustersSupportingVirt = new ArrayList<>();
// filter clusters supporting virt service only
for (Cluster cluster : clusters) {
if (cluster.supportsVirtService()) {
clustersSupportingVirt.add(cluster);
}
}
List<Cluster> filteredClusters = AsyncDataProvider.getInstance().filterByArchitecture(clustersSupportingVirt, template.getClusterArch());
getModel().setDataCentersAndClusters(getModel(), new ArrayList<>(Arrays.asList(new StoragePool[] { dataCenter })), filteredClusters, template.getClusterId());
updateRngDevice(template.getId());
AsyncDataProvider.getInstance().isSoundcardEnabled(new AsyncQuery<>(returnValue -> {
getModel().getIsSoundcardEnabled().setEntity(returnValue);
initTemplate();
initCdImage();
}), template.getId());
Frontend.getInstance().runQuery(QueryType.IsBalloonEnabled, new IdQueryParameters(template.getId()), new AsyncQuery<>((QueryReturnValue returnValue) -> getModel().getMemoryBalloonDeviceEnabled().setEntity((Boolean) returnValue.getReturnValue())));
AsyncDataProvider.getInstance().isVirtioScsiEnabledForVm(new AsyncQuery<>(returnValue -> getModel().getIsVirtioScsiEnabled().setEntity(returnValue)), template.getId());
}), true, false)), template.getStoragePoolId());
}
AsyncDataProvider.getInstance().getWatchdogByVmId(new AsyncQuery<>((AsyncCallback<QueryReturnValue>) returnValue -> {
UnitVmModel model = getModel();
@SuppressWarnings("unchecked") Collection<VmWatchdog> watchdogs = returnValue.getReturnValue();
for (VmWatchdog watchdog : watchdogs) {
model.getWatchdogAction().setSelectedItem(watchdog.getAction());
model.getWatchdogModel().setSelectedItem(watchdog.getModel());
}
}), template.getId());
getModel().getMigrationMode().setSelectedItem(template.getMigrationSupport());
setupBaseTemplate(template.getBaseTemplateId());
}
use of org.ovirt.engine.ui.frontend.AsyncQuery in project ovirt-engine by oVirt.
the class SpiceNativeImpl method invokeClient.
@Override
public void invokeClient() {
// todo avoid code duplication with vnc
AsyncQuery<QueryReturnValue> callback = new AsyncQuery<>(returnValue -> // $NON-NLS-1$
ConsoleModel.makeConsoleConfigRequest(// $NON-NLS-1$
"console.vv", // $NON-NLS-1$
"application/x-virt-viewer; charset=UTF-8", returnValue.getReturnValue()));
Frontend.getInstance().runQuery(QueryType.GetConsoleDescriptorFile, new ConsoleOptionsParams(getOptions()), callback);
}
Aggregations