Search in sources :

Example 16 with AsyncQuery

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());
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) Arrays(java.util.Arrays) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) DiskByDiskAliasComparator(org.ovirt.engine.core.common.businessentities.comparators.DiskByDiskAliasComparator) StorageDomainStatus(org.ovirt.engine.core.common.businessentities.StorageDomainStatus) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) ArrayList(java.util.ArrayList) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) AsyncQuery(org.ovirt.engine.ui.frontend.AsyncQuery) NameableComparator(org.ovirt.engine.core.common.businessentities.comparators.NameableComparator) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) DisplayType(org.ovirt.engine.core.common.businessentities.DisplayType) StorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType) VmBase(org.ovirt.engine.core.common.businessentities.VmBase) DiskStorageType(org.ovirt.engine.core.common.businessentities.storage.DiskStorageType) Linq(org.ovirt.engine.ui.uicommonweb.Linq) BuilderExecutor(org.ovirt.engine.ui.uicommonweb.builders.BuilderExecutor) Collection(java.util.Collection) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) VolumeType(org.ovirt.engine.core.common.businessentities.storage.VolumeType) List(java.util.List) VM(org.ovirt.engine.core.common.businessentities.VM) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) UIConstants(org.ovirt.engine.ui.uicompat.UIConstants) ActionGroup(org.ovirt.engine.core.common.businessentities.ActionGroup) Collections(java.util.Collections) CommonVmBaseToUnitBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.CommonVmBaseToUnitBuilder) DisksAllocationModel(org.ovirt.engine.ui.uicommonweb.models.storage.DisksAllocationModel) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool)

Example 17 with AsyncQuery

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());
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) TemplateWithVersion(org.ovirt.engine.ui.uicommonweb.models.templates.TemplateWithVersion) StoragePoolStatus(org.ovirt.engine.core.common.businessentities.StoragePoolStatus) VmBase(org.ovirt.engine.core.common.businessentities.VmBase) VmType(org.ovirt.engine.core.common.businessentities.VmType) Linq(org.ovirt.engine.ui.uicommonweb.Linq) BuilderExecutor(org.ovirt.engine.ui.uicommonweb.builders.BuilderExecutor) Guid(org.ovirt.engine.core.compat.Guid) CoreVmBaseToUnitBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.CoreVmBaseToUnitBuilder) Collection(java.util.Collection) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) InstanceType(org.ovirt.engine.core.common.businessentities.InstanceType) NewVmInstanceTypeManager(org.ovirt.engine.ui.uicommonweb.models.vms.instancetypes.NewVmInstanceTypeManager) StringHelper(org.ovirt.engine.core.compat.StringHelper) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) ArrayList(java.util.ArrayList) List(java.util.List) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) RepoImage(org.ovirt.engine.core.common.businessentities.storage.RepoImage) VnicProfileView(org.ovirt.engine.core.common.businessentities.network.VnicProfileView) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) AsyncQuery(org.ovirt.engine.ui.frontend.AsyncQuery) InstanceTypeManager(org.ovirt.engine.ui.uicommonweb.models.vms.instancetypes.InstanceTypeManager) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool)

Example 18 with AsyncQuery

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());
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) QueryType(org.ovirt.engine.core.common.queries.QueryType) Arrays(java.util.Arrays) Guid(org.ovirt.engine.core.compat.Guid) DiskByDiskAliasComparator(org.ovirt.engine.core.common.businessentities.comparators.DiskByDiskAliasComparator) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ArrayList(java.util.ArrayList) ActionType(org.ovirt.engine.core.common.action.ActionType) Frontend(org.ovirt.engine.ui.frontend.Frontend) CommentVmBaseToUnitBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.CommentVmBaseToUnitBuilder) Map(java.util.Map) AsyncQuery(org.ovirt.engine.ui.frontend.AsyncQuery) Version(org.ovirt.engine.core.compat.Version) InstanceTypeManager(org.ovirt.engine.ui.uicommonweb.models.vms.instancetypes.InstanceTypeManager) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) EnumSet(java.util.EnumSet) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) VmActionByVmOriginTypeValidator(org.ovirt.engine.core.common.validation.VmActionByVmOriginTypeValidator) VmBase(org.ovirt.engine.core.common.businessentities.VmBase) Linq(org.ovirt.engine.ui.uicommonweb.Linq) BuilderExecutor(org.ovirt.engine.ui.uicommonweb.builders.BuilderExecutor) VmNumaNode(org.ovirt.engine.core.common.businessentities.VmNumaNode) NameAndDescriptionVmBaseToUnitBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.NameAndDescriptionVmBaseToUnitBuilder) ConfigValues(org.ovirt.engine.core.common.config.ConfigValues) StringHelper(org.ovirt.engine.core.compat.StringHelper) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) List(java.util.List) VM(org.ovirt.engine.core.common.businessentities.VM) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) RepoImage(org.ovirt.engine.core.common.businessentities.storage.RepoImage) CommonCompatibilityVersionUtils(org.ovirt.engine.core.common.utils.CommonCompatibilityVersionUtils) ExistingVmInstanceTypeManager(org.ovirt.engine.ui.uicommonweb.models.vms.instancetypes.ExistingVmInstanceTypeManager) Collections(java.util.Collections) VDS(org.ovirt.engine.core.common.businessentities.VDS) CommonVmBaseToUnitBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.CommonVmBaseToUnitBuilder) VMStatus(org.ovirt.engine.core.common.businessentities.VMStatus) Version(org.ovirt.engine.core.compat.Version) VM(org.ovirt.engine.core.common.businessentities.VM) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) ArrayList(java.util.ArrayList) List(java.util.List)

Example 19 with AsyncQuery

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());
}
Also used : DisplayType(org.ovirt.engine.core.common.businessentities.DisplayType) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) QueryType(org.ovirt.engine.core.common.queries.QueryType) Arrays(java.util.Arrays) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) VmBase(org.ovirt.engine.core.common.businessentities.VmBase) BuilderExecutor(org.ovirt.engine.ui.uicommonweb.builders.BuilderExecutor) NameAndDescriptionVmBaseToUnitBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.NameAndDescriptionVmBaseToUnitBuilder) Guid(org.ovirt.engine.core.compat.Guid) Collection(java.util.Collection) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ArrayList(java.util.ArrayList) AsyncCallback(org.ovirt.engine.ui.frontend.AsyncCallback) Frontend(org.ovirt.engine.ui.frontend.Frontend) List(java.util.List) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) CommentVmBaseToUnitBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.CommentVmBaseToUnitBuilder) AsyncQuery(org.ovirt.engine.ui.frontend.AsyncQuery) Collections(java.util.Collections) VmWatchdog(org.ovirt.engine.core.common.businessentities.VmWatchdog) CommonVmBaseToUnitBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.CommonVmBaseToUnitBuilder) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) AsyncCallback(org.ovirt.engine.ui.frontend.AsyncCallback) ArrayList(java.util.ArrayList) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) VmWatchdog(org.ovirt.engine.core.common.businessentities.VmWatchdog) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) AsyncQuery(org.ovirt.engine.ui.frontend.AsyncQuery) ArrayList(java.util.ArrayList) List(java.util.List)

Example 20 with AsyncQuery

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);
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) ConsoleOptionsParams(org.ovirt.engine.core.common.queries.ConsoleOptionsParams) AsyncQuery(org.ovirt.engine.ui.frontend.AsyncQuery)

Aggregations

AsyncQuery (org.ovirt.engine.ui.frontend.AsyncQuery)35 List (java.util.List)25 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)24 Guid (org.ovirt.engine.core.compat.Guid)24 Frontend (org.ovirt.engine.ui.frontend.Frontend)24 AsyncDataProvider (org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)24 ArrayList (java.util.ArrayList)22 VmBase (org.ovirt.engine.core.common.businessentities.VmBase)21 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)21 VmTemplate (org.ovirt.engine.core.common.businessentities.VmTemplate)20 QueryType (org.ovirt.engine.core.common.queries.QueryType)20 Collection (java.util.Collection)19 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)19 Linq (org.ovirt.engine.ui.uicommonweb.Linq)19 BuilderExecutor (org.ovirt.engine.ui.uicommonweb.builders.BuilderExecutor)18 Arrays (java.util.Arrays)17 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)17 StringHelper (org.ovirt.engine.core.compat.StringHelper)17 VDS (org.ovirt.engine.core.common.businessentities.VDS)16 Collections (java.util.Collections)15