Search in sources :

Example 1 with KeyValueModel

use of org.ovirt.engine.ui.uicommonweb.models.vms.key_value.KeyValueModel in project ovirt-engine by oVirt.

the class ClusterModel method init.

public void init(final boolean isEdit) {
    setIsEdit(isEdit);
    setName(new EntityModel<>());
    setDescription(new EntityModel<>());
    setComment(new EntityModel<>());
    setEnableTrustedService(new EntityModel<>(false));
    setEnableHaReservation(new EntityModel<>(false));
    setEnableOptionalReason(new EntityModel<>(false));
    setMigrationPolicies(new ListModel<>());
    getMigrationPolicies().getSelectedItemChangedEvent().addListener(this);
    getEnableOptionalReason().setIsAvailable(ApplicationModeHelper.isModeSupported(ApplicationMode.VirtOnly));
    setEnableHostMaintenanceReason(new EntityModel<>(false));
    setAllowClusterWithVirtGlusterEnabled(true);
    setGlusterTunedProfile(new ListModel<>());
    AsyncDataProvider.getInstance().getAllowClusterWithVirtGlusterEnabled(new AsyncQuery<>(this::setAllowClusterWithVirtGlusterEnabled));
    setEnableOvirtService(new EntityModel<>());
    setEnableGlusterService(new EntityModel<>());
    setAdditionalClusterFeatures(new ListModel<>());
    List<List<AdditionalFeature>> additionalFeatures = new ArrayList<>();
    additionalFeatures.add(Collections.emptyList());
    getAdditionalClusterFeatures().setItems(additionalFeatures, null);
    setSpiceProxyEnabled(new EntityModel<>());
    getSpiceProxyEnabled().setEntity(false);
    getSpiceProxyEnabled().getEntityChangedEvent().addListener(this);
    setSpiceProxy(new EntityModel<>());
    getSpiceProxy().setIsChangeable(false);
    setFencingEnabledModel(new EntityModel<>());
    getFencingEnabledModel().setEntity(true);
    getFencingEnabledModel().getEntityChangedEvent().addListener((ev, sender, args) -> updateFencingPolicyContent(getVersion() == null ? null : getVersion().getSelectedItem()));
    setSkipFencingIfSDActiveEnabled(new EntityModel<>());
    getSkipFencingIfSDActiveEnabled().setEntity(true);
    setSkipFencingIfGlusterBricksUp(new EntityModel<>());
    getSkipFencingIfGlusterBricksUp().setEntity(false);
    getSkipFencingIfGlusterBricksUp().setIsAvailable(false);
    setSkipFencingIfGlusterQuorumNotMet(new EntityModel<>());
    getSkipFencingIfGlusterQuorumNotMet().setEntity(false);
    getSkipFencingIfGlusterQuorumNotMet().setIsAvailable(false);
    setSkipFencingIfConnectivityBrokenEnabled(new EntityModel<>());
    getSkipFencingIfConnectivityBrokenEnabled().setEntity(true);
    setEnableOvirtService(new EntityModel<>());
    setEnableGlusterService(new EntityModel<>());
    setSerialNumberPolicy(new SerialNumberPolicyModel());
    setAutoConverge(new ListModel<>());
    getAutoConverge().setItems(Arrays.asList(null, true, false));
    setMigrateCompressed(new ListModel<>());
    getMigrateCompressed().setItems(Arrays.asList(null, true, false));
    getEnableOvirtService().getEntityChangedEvent().addListener((ev, sender, args) -> {
        refreshAdditionalClusterFeaturesList();
        if (!getAllowClusterWithVirtGlusterEnabled() && getEnableOvirtService().getEntity()) {
            getEnableGlusterService().setEntity(Boolean.FALSE);
        }
        updateGlusterFencingPolicyAvailability();
        getEnableGlusterService().setIsChangeable(true);
        getEnableTrustedService().setEntity(false);
        if (getEnableOvirtService().getEntity() != null && getEnableOvirtService().getEntity()) {
            if (getEnableGlusterService().getEntity() != null && !getEnableGlusterService().getEntity()) {
                getEnableTrustedService().setIsChangeable(true);
            } else {
                getEnableTrustedService().setIsChangeable(false);
            }
        } else {
            getEnableTrustedService().setIsChangeable(false);
        }
    });
    getEnableOvirtService().setEntity(ApplicationModeHelper.isModeSupported(ApplicationMode.VirtOnly));
    getEnableOvirtService().setIsAvailable(ApplicationModeHelper.getUiMode() != ApplicationMode.VirtOnly && ApplicationModeHelper.isModeSupported(ApplicationMode.VirtOnly));
    setRngHwrngSourceRequired(new EntityModel<>());
    getRngHwrngSourceRequired().setIsAvailable(ApplicationModeHelper.isModeSupported(ApplicationMode.VirtOnly));
    initImportCluster();
    getEnableGlusterService().getEntityChangedEvent().addListener((ev, sender, args) -> {
        refreshAdditionalClusterFeaturesList();
        if (!getAllowClusterWithVirtGlusterEnabled() && getEnableGlusterService().getEntity()) {
            getEnableOvirtService().setEntity(Boolean.FALSE);
        }
        if (!isEdit && getEnableGlusterService().getEntity() != null && getEnableGlusterService().getEntity()) {
            getIsImportGlusterConfiguration().setIsAvailable(true);
            getGlusterHostAddress().setIsAvailable(true);
            getGlusterHostFingerprint().setIsAvailable(true);
            getGlusterHostPassword().setIsAvailable(true);
        } else {
            getIsImportGlusterConfiguration().setIsAvailable(false);
            getIsImportGlusterConfiguration().setEntity(false);
            getGlusterHostAddress().setIsAvailable(false);
            getGlusterHostFingerprint().setIsAvailable(false);
            getGlusterHostPassword().setIsAvailable(false);
        }
        if (getEnableGlusterService().getEntity() != null && getEnableGlusterService().getEntity()) {
            getEnableTrustedService().setEntity(false);
            getEnableTrustedService().setIsChangeable(false);
        } else {
            if (getEnableOvirtService().getEntity() != null && getEnableOvirtService().getEntity()) {
                getEnableTrustedService().setIsChangeable(true);
            } else {
                getEnableTrustedService().setIsChangeable(false);
            }
        }
        getGlusterTunedProfile().setIsAvailable(getEnableGlusterService().getEntity());
        updateGlusterFencingPolicyAvailability();
        if (getEnableGlusterService().getEntity()) {
            initTunedProfiles();
        }
    });
    getEnableTrustedService().getEntityChangedEvent().addListener((ev, sender, args) -> {
        if (getEnableTrustedService().getEntity() != null && getEnableTrustedService().getEntity()) {
            getEnableGlusterService().setEntity(false);
            getEnableGlusterService().setIsChangeable(false);
        } else {
            getEnableGlusterService().setIsChangeable(true);
        }
    });
    getEnableGlusterService().setEntity(ApplicationModeHelper.getUiMode() == ApplicationMode.GlusterOnly);
    getEnableGlusterService().setIsAvailable(ApplicationModeHelper.getUiMode() != ApplicationMode.GlusterOnly && ApplicationModeHelper.isModeSupported(ApplicationMode.GlusterOnly));
    getGlusterTunedProfile().setIsAvailable(getEnableGlusterService().getEntity());
    setOptimizationNone(new EntityModel<>());
    setOptimizationForServer(new EntityModel<>());
    setOptimizationForDesktop(new EntityModel<>());
    setOptimizationCustom(new EntityModel<>());
    EntityModel<Boolean> tempVar = new EntityModel<>();
    tempVar.setEntity(false);
    setOptimizationNone_IsSelected(tempVar);
    getOptimizationNone_IsSelected().getEntityChangedEvent().addListener(this);
    EntityModel<Boolean> tempVar2 = new EntityModel<>();
    tempVar2.setEntity(false);
    setOptimizationForServer_IsSelected(tempVar2);
    getOptimizationForServer_IsSelected().getEntityChangedEvent().addListener(this);
    EntityModel<Boolean> tempVar3 = new EntityModel<>();
    tempVar3.setEntity(false);
    setOptimizationForDesktop_IsSelected(tempVar3);
    getOptimizationForDesktop_IsSelected().getEntityChangedEvent().addListener(this);
    EntityModel<Boolean> tempVar4 = new EntityModel<>();
    tempVar4.setEntity(false);
    tempVar4.setIsAvailable(false);
    setOptimizationCustom_IsSelected(tempVar4);
    getOptimizationCustom_IsSelected().getEntityChangedEvent().addListener(this);
    EntityModel<Boolean> tempVar5 = new EntityModel<>();
    tempVar5.setEntity(false);
    setMigrateOnErrorOption_YES(tempVar5);
    getMigrateOnErrorOption_YES().getEntityChangedEvent().addListener(this);
    EntityModel<Boolean> tempVar6 = new EntityModel<>();
    tempVar6.setEntity(false);
    setMigrateOnErrorOption_NO(tempVar6);
    getMigrateOnErrorOption_NO().getEntityChangedEvent().addListener(this);
    EntityModel<Boolean> tempVar7 = new EntityModel<>();
    tempVar7.setEntity(false);
    setMigrateOnErrorOption_HA_ONLY(tempVar7);
    getMigrateOnErrorOption_HA_ONLY().getEntityChangedEvent().addListener(this);
    // KSM feature
    setEnableKsm(new EntityModel<>());
    getEnableKsm().setEntity(false);
    getKsmPolicyForNumaSelection().setIsChangeable(false);
    getEnableKsm().getEntityChangedEvent().addListener((ev, sender, args) -> {
        if (getEnableKsm().getEntity() == null) {
            return;
        }
        if (getEnableKsm().getEntity()) {
            getKsmPolicyForNumaSelection().setIsChangeable(true);
        }
        if (!getEnableKsm().getEntity()) {
            getKsmPolicyForNumaSelection().setIsChangeable(false);
        }
    });
    setEnableBallooning(new EntityModel<>());
    getEnableBallooning().setEntity(false);
    // Optimization methods:
    // default value =100;
    setDefaultMemoryOvercommit(AsyncDataProvider.getInstance().getClusterDefaultMemoryOverCommit());
    setCountThreadsAsCores(new EntityModel<>(AsyncDataProvider.getInstance().getClusterDefaultCountThreadsAsCores()));
    setVersionSupportsCpuThreads(new EntityModel<>(true));
    setOptimizeForUtilization(new EntityModel<>());
    setOptimizeForSpeed(new EntityModel<>());
    getOptimizeForUtilization().setEntity(true);
    getOptimizeForSpeed().setEntity(false);
    getOptimizeForUtilization().getEntityChangedEvent().addListener(this);
    getOptimizeForSpeed().getEntityChangedEvent().addListener(this);
    setGuarantyResources(new EntityModel<>());
    setAllowOverbooking(new EntityModel<>());
    getGuarantyResources().setEntity(true);
    getAllowOverbooking().setEntity(false);
    getAllowOverbooking().getEntityChangedEvent().addListener(this);
    getGuarantyResources().getEntityChangedEvent().addListener(this);
    boolean overbookingSupported = AsyncDataProvider.getInstance().getScheudulingAllowOverbookingSupported();
    getAllowOverbooking().setIsAvailable(overbookingSupported);
    if (overbookingSupported) {
        getOptimizeForSpeed().getEntityChangedEvent().addListener((ev, sender, args) -> {
            Boolean entity = getOptimizeForSpeed().getEntity();
            if (entity) {
                getGuarantyResources().setEntity(true);
            }
            getAllowOverbooking().setIsChangeable(!entity);
        });
        getAllowOverbooking().getEntityChangedEvent().addListener((ev, sender, args) -> {
            Boolean entity = getAllowOverbooking().getEntity();
            if (entity) {
                getOptimizeForUtilization().setEntity(true);
            }
            getOptimizeForSpeed().setIsChangeable(!entity);
        });
    }
    setHostsWithBrokenConnectivityThreshold(new ListModel<>());
    getHostsWithBrokenConnectivityThreshold().setIsAvailable(true);
    getHostsWithBrokenConnectivityThreshold().getSelectedItemChangedEvent().addListener(this);
    initHostsWithBrokenConnectivityThreshold();
    AsyncDataProvider.getInstance().getClusterDesktopMemoryOverCommit(new AsyncQuery<>(result -> {
        setDesktopOverCommit(result);
        AsyncDataProvider.getInstance().getClusterServerMemoryOverCommit(new AsyncQuery<>(r -> {
            setServerOverCommit(r);
            // temp is used for conversion purposes
            EntityModel temp;
            temp = getOptimizationNone();
            temp.setEntity(getDefaultMemoryOvercommit());
            // res1, res2 is used for conversion purposes.
            boolean res1 = getDesktopOverCommit() != getDefaultMemoryOvercommit();
            boolean res2 = getServerOverCommit() != getDefaultMemoryOvercommit();
            temp = getOptimizationNone_IsSelected();
            setIsSelected(res1 && res2);
            temp.setEntity(getIsSelected());
            temp = getOptimizationForServer();
            temp.setEntity(getServerOverCommit());
            temp = getOptimizationForServer_IsSelected();
            temp.setEntity(getServerOverCommit() == getDefaultMemoryOvercommit());
            temp = getOptimizationForDesktop();
            temp.setEntity(getDesktopOverCommit());
            temp = getOptimizationForDesktop_IsSelected();
            temp.setEntity(getDesktopOverCommit() == getDefaultMemoryOvercommit());
            temp = getOptimizationCustom();
            temp.setIsAvailable(false);
            temp.setIsChangeable(false);
            if (getIsEdit()) {
                postInit();
            }
        }));
    }));
    setDataCenter(new ListModel<>());
    getDataCenter().getSelectedItemChangedEvent().addListener(this);
    getDataCenter().setIsAvailable(ApplicationModeHelper.getUiMode() != ApplicationMode.GlusterOnly);
    setArchitecture(new ListModel<>());
    getArchitecture().setIsAvailable(ApplicationModeHelper.isModeSupported(ApplicationMode.VirtOnly));
    setManagementNetwork(new ListModel<>());
    if (isEdit && !isClusterDetached()) {
        getManagementNetwork().setChangeProhibitionReason(ConstantsManager.getInstance().getConstants().prohibitManagementNetworkChangeInEditClusterInfoMessage());
        getManagementNetwork().setIsChangeable(false);
    }
    setCPU(new FilteredListModel<>());
    getCPU().setIsAvailable(ApplicationModeHelper.getUiMode() != ApplicationMode.GlusterOnly);
    getCPU().getSelectedItemChangedEvent().addListener(this);
    setVersion(new ListModel<>());
    getVersion().getSelectedItemChangedEvent().addListener(this);
    setMigrateOnErrorOption(MigrateOnErrorOptions.YES);
    setFirewallType(new ListModel<>());
    initFirewallType();
    setDefaultNetworkProvider(new ListModel<>());
    initDefaultNetworkProvider();
    setSwitchType(new ListModel<>());
    initSwitchType();
    getRngHwrngSourceRequired().setEntity(false);
    setValidTab(TabName.GENERAL_TAB, true);
    setMigrationTabAvailable(true);
    setClusterPolicy(new ListModel<>());
    setCustomPropertySheet(new KeyValueModel());
    getClusterPolicy().getSelectedItemChangedEvent().addListener(this);
    Frontend.getInstance().runQuery(QueryType.GetAllPolicyUnits, new QueryParametersBase(), new AsyncQuery<QueryReturnValue>(returnValue -> {
        ArrayList<PolicyUnit> policyUnits = returnValue.getReturnValue();
        policyUnitMap = new LinkedHashMap<>();
        for (PolicyUnit policyUnit : policyUnits) {
            policyUnitMap.put(policyUnit.getId(), policyUnit);
        }
        Frontend.getInstance().runQuery(QueryType.GetClusterPolicies, new QueryParametersBase(), new AsyncQuery<QueryReturnValue>(retVal -> {
            ArrayList<ClusterPolicy> list = retVal.getReturnValue();
            getClusterPolicy().setItems(list);
            ClusterPolicy defaultClusterPolicy = null;
            ClusterPolicy selectedClusterPolicy = null;
            for (ClusterPolicy clusterPolicy : list) {
                if (getIsEdit() && getEntity() != null && clusterPolicy.getId().equals(getEntity().getClusterPolicyId())) {
                    selectedClusterPolicy = clusterPolicy;
                }
                if (clusterPolicy.isDefaultPolicy()) {
                    defaultClusterPolicy = clusterPolicy;
                }
            }
            if (selectedClusterPolicy != null) {
                getClusterPolicy().setSelectedItem(selectedClusterPolicy);
            } else {
                getClusterPolicy().setSelectedItem(defaultClusterPolicy);
            }
            clusterPolicyChanged();
        }));
    }));
    setCustomMigrationNetworkBandwidth(new EntityModel<>());
    setMigrationBandwidthLimitType(new ListModel<>());
}
Also used : MacPoolModel(org.ovirt.engine.ui.uicommonweb.models.macpool.MacPoolModel) Arrays(java.util.Arrays) Provider(org.ovirt.engine.core.common.businessentities.Provider) Event(org.ovirt.engine.ui.uicompat.Event) ApplicationMode(org.ovirt.engine.core.common.mode.ApplicationMode) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) SwitchType(org.ovirt.engine.core.common.network.SwitchType) Map(java.util.Map) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) HasEntity(org.ovirt.engine.ui.uicommonweb.models.HasEntity) Version(org.ovirt.engine.core.compat.Version) EventArgs(org.ovirt.engine.ui.uicompat.EventArgs) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) SortedListModel(org.ovirt.engine.ui.uicommonweb.models.SortedListModel) ClusterPolicy(org.ovirt.engine.core.common.scheduling.ClusterPolicy) AdditionalFeature(org.ovirt.engine.core.common.businessentities.AdditionalFeature) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) Collection(java.util.Collection) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) Set(java.util.Set) MigrationBandwidthLimitType(org.ovirt.engine.core.common.businessentities.MigrationBandwidthLimitType) HasValidatedTabs(org.ovirt.engine.ui.uicommonweb.models.HasValidatedTabs) I18NNameValidation(org.ovirt.engine.ui.uicommonweb.validation.I18NNameValidation) StringHelper(org.ovirt.engine.core.compat.StringHelper) SerialNumberPolicyModel(org.ovirt.engine.ui.uicommonweb.models.vms.SerialNumberPolicyModel) Objects(java.util.Objects) ApplicationModeHelper(org.ovirt.engine.ui.uicommonweb.models.ApplicationModeHelper) List(java.util.List) MigrateOnErrorOptions(org.ovirt.engine.core.common.businessentities.MigrateOnErrorOptions) VmRngDevice(org.ovirt.engine.core.common.businessentities.VmRngDevice) ValidationCompleteEvent(org.ovirt.engine.ui.uicommonweb.models.ValidationCompleteEvent) KeyValueModel(org.ovirt.engine.ui.uicommonweb.models.vms.key_value.KeyValueModel) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) ProviderType(org.ovirt.engine.core.common.businessentities.ProviderType) FilteredListModel(org.ovirt.engine.ui.uicommonweb.models.FilteredListModel) LengthValidation(org.ovirt.engine.ui.uicommonweb.validation.LengthValidation) NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) QueryType(org.ovirt.engine.core.common.queries.QueryType) VdsStatic(org.ovirt.engine.core.common.businessentities.VdsStatic) ArchitectureType(org.ovirt.engine.core.common.businessentities.ArchitectureType) HostWithProtocolAndPortAddressValidation(org.ovirt.engine.ui.uicommonweb.validation.HostWithProtocolAndPortAddressValidation) Guid(org.ovirt.engine.core.compat.Guid) ServerCpu(org.ovirt.engine.core.common.businessentities.ServerCpu) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) AsyncCallback(org.ovirt.engine.ui.frontend.AsyncCallback) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap) NoMigrationPolicy(org.ovirt.engine.core.common.migration.NoMigrationPolicy) Frontend(org.ovirt.engine.ui.frontend.Frontend) NotNullIntegerValidation(org.ovirt.engine.ui.uicommonweb.validation.NotNullIntegerValidation) Network(org.ovirt.engine.core.common.businessentities.network.Network) MigrationPolicy(org.ovirt.engine.core.common.migration.MigrationPolicy) Pair(org.ovirt.engine.core.common.utils.Pair) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) Linq(org.ovirt.engine.ui.uicommonweb.Linq) IValidation(org.ovirt.engine.ui.uicommonweb.validation.IValidation) SerialNumberPolicy(org.ovirt.engine.core.common.businessentities.SerialNumberPolicy) ConfigValues(org.ovirt.engine.core.common.config.ConfigValues) SupportedAdditionalClusterFeature(org.ovirt.engine.core.common.businessentities.SupportedAdditionalClusterFeature) MacPool(org.ovirt.engine.core.common.businessentities.MacPool) TabName(org.ovirt.engine.ui.uicommonweb.models.TabName) PolicyUnit(org.ovirt.engine.core.common.scheduling.PolicyUnit) UIConstants(org.ovirt.engine.ui.uicompat.UIConstants) FirewallType(org.ovirt.engine.core.common.network.FirewallType) Comparator(java.util.Comparator) Collections(java.util.Collections) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) IdAndNameQueryParameters(org.ovirt.engine.core.common.queries.IdAndNameQueryParameters) SerialNumberPolicyModel(org.ovirt.engine.ui.uicommonweb.models.vms.SerialNumberPolicyModel) ArrayList(java.util.ArrayList) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) LinkedHashMap(java.util.LinkedHashMap) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) KeyValueModel(org.ovirt.engine.ui.uicommonweb.models.vms.key_value.KeyValueModel) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) List(java.util.List) ArrayList(java.util.ArrayList) PolicyUnit(org.ovirt.engine.core.common.scheduling.PolicyUnit) ClusterPolicy(org.ovirt.engine.core.common.scheduling.ClusterPolicy)

Example 2 with KeyValueModel

use of org.ovirt.engine.ui.uicommonweb.models.vms.key_value.KeyValueModel in project ovirt-engine by oVirt.

the class NewClusterPolicyModel method initCustomPropertySheet.

private void initCustomPropertySheet() {
    setCustomPropertySheet(new KeyValueModel());
    if (clusterPolicy.getParameterMap() != null) {
        getCustomProperties().putAll(clusterPolicy.getParameterMap());
    }
    getCustomPropertySheet().setIsChangeable(!clusterPolicy.isLocked());
    customPropertiesInitialized = true;
    refreshCustomProperties(null, false);
}
Also used : KeyValueModel(org.ovirt.engine.ui.uicommonweb.models.vms.key_value.KeyValueModel)

Example 3 with KeyValueModel

use of org.ovirt.engine.ui.uicommonweb.models.vms.key_value.KeyValueModel in project ovirt-engine by oVirt.

the class PoolListModel method displayHighPerformanceConfirmationPopup.

protected void displayHighPerformanceConfirmationPopup() {
    final PoolModel model = (PoolModel) getWindow();
    if (model == null || model.getProgress() != null) {
        return;
    }
    VmHighPerformanceConfigurationModel confirmModel = new VmHighPerformanceConfigurationModel();
    // Handle CPU Pinning topology
    final boolean isVmAssignedToSpecificHosts = !model.getIsAutoAssign().getEntity();
    final boolean isVmCpuPinningSet = model.getCpuPinning().getIsChangable() && model.getCpuPinning().getEntity() != null && !model.getCpuPinning().getEntity().isEmpty();
    confirmModel.addRecommendationForCpuPinning(isVmAssignedToSpecificHosts, isVmCpuPinningSet);
    // Handle Huge Pages
    KeyValueModel keyValue = model.getCustomPropertySheet();
    // $NON-NLS-1$
    final boolean isVmHugePagesSet = keyValue != null && keyValue.getUsedKeys().contains("hugepages");
    confirmModel.addRecommendationForHugePages(isVmHugePagesSet);
    // Handle KSM (Kernel Same Page Merging)
    confirmModel.addRecommendationForKsm(model.getSelectedCluster().isEnableKsm(), model.getSelectedCluster().getName());
    if (!confirmModel.getRecommendationsList().isEmpty()) {
        confirmModel.setTitle(ConstantsManager.getInstance().getConstants().configurationChangesForHighPerformancePoolTitle());
        confirmModel.setHelpTag(HelpTag.configuration_changes_for_high_performance_pool);
        // $NON-NLS-1$
        confirmModel.setHashName("configuration_changes_for_high_performance_pool");
        confirmModel.getCommands().add(// $NON-NLS-1$
        new UICommand("OnSave_Phase2", PoolListModel.this).setTitle(ConstantsManager.getInstance().getConstants().ok()).setIsDefault(true));
        confirmModel.getCommands().add(// $NON-NLS-1$
        UICommand.createCancelUiCommand("CancelConfirmation", PoolListModel.this));
        setConfirmWindow(null);
        setConfirmWindow(confirmModel);
    } else {
        savePoolPostValidation();
    }
}
Also used : VmHighPerformanceConfigurationModel(org.ovirt.engine.ui.uicommonweb.models.vms.VmHighPerformanceConfigurationModel) KeyValueModel(org.ovirt.engine.ui.uicommonweb.models.vms.key_value.KeyValueModel) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand)

Example 4 with KeyValueModel

use of org.ovirt.engine.ui.uicommonweb.models.vms.key_value.KeyValueModel in project ovirt-engine by oVirt.

the class HostSetupNetworksModel method onEdit.

public void onEdit(NetworkItemModel<?> item) {
    Model editPopup = null;
    BaseCommandTarget okTarget = null;
    if (item instanceof BondNetworkInterfaceModel) {
        /**
         ***************
         * Bond Dialog
         ****************
         */
        boolean doesBondHaveVmNetworkAttached = doesBondHaveVmNetworkAttached((NetworkInterfaceModel) item);
        BondNetworkInterfaceModel bondModel = (BondNetworkInterfaceModel) item;
        final CreateOrUpdateBond createOrUpdateBondParameter = bondModel.getCreateOrUpdateBond();
        editPopup = new SetupNetworksEditBondModel(createOrUpdateBondParameter, doesBondHaveVmNetworkAttached);
        final SetupNetworksBondModel bondDialogModel = (SetupNetworksBondModel) editPopup;
        // OK Target
        okTarget = new BaseCommandTarget() {

            @Override
            public void executeCommand(UICommand command) {
                if (!bondDialogModel.validate()) {
                    return;
                }
                sourceListModel.setConfirmWindow(null);
                setBondOptions(createOrUpdateBondParameter, bondDialogModel);
                redraw();
            }
        };
    } else if (item instanceof NetworkInterfaceModel) {
        /**
         *****************
         * VFs Config Dialog
         ******************
         */
        final VdsNetworkInterface entity = ((NetworkInterfaceModel) item).getOriginalIface();
        final HostNicVfsConfig hostNicVfsConfig = nicToVfsConfig.get(entity.getId());
        if (hostNicVfsConfig != null) {
            final VfsConfigModel vfsConfigPopupModel = new VfsConfigModel(hostNicVfsConfig, allNetworks, dcLabels);
            vfsConfigPopupModel.setTitle(ConstantsManager.getInstance().getMessages().editHostNicVfsConfigTitle(entity.getName()));
            editPopup = vfsConfigPopupModel;
            // OK Target
            okTarget = new BaseCommandTarget() {

                @Override
                public void executeCommand(UICommand uiCommand) {
                    if (!vfsConfigPopupModel.validate()) {
                        return;
                    }
                    sourceListModel.setConfirmWindow(null);
                    commitVfsConfigChanges(hostNicVfsConfig, vfsConfigPopupModel);
                    redraw();
                }
            };
        }
    } else if (item instanceof LogicalNetworkModel) {
        /**
         ***************
         * Network Dialog
         ****************
         */
        final LogicalNetworkModel logicalNetworkModel = (LogicalNetworkModel) item;
        final VdsNetworkInterface nic;
        if (logicalNetworkModel.isInSync()) {
            nic = logicalNetworkModel.hasVlan() ? logicalNetworkModel.getVlanDevice() : logicalNetworkModel.getAttachedToNic().getOriginalIface();
        } else {
            nic = logicalNetworkModel.getVlanDevice() != null ? logicalNetworkModel.getVlanDevice() : logicalNetworkModel.getAttachedToNic().getOriginalIface();
        }
        final NetworkAttachmentModel networkAttachmentModel;
        String version = getEntity().getClusterCompatibilityVersion().getValue();
        final Network network = logicalNetworkModel.getNetwork();
        final String logicalNetworkModelName = network.getName();
        final NetworkAttachment networkAttachment = logicalNetworkModel.getNetworkAttachment();
        HostNetworkQos networkQos = qosById.get(network.getQosId());
        DnsResolverConfiguration reportedDnsResolverConfiguration = getEntity().getReportedDnsResolverConfiguration();
        if (logicalNetworkModel.isManagement()) {
            networkAttachmentModel = new ManagementNetworkAttachmentModel(network, nic, networkAttachment, networkQos, reportedDnsResolverConfiguration);
        } else {
            networkAttachmentModel = new NetworkAttachmentModel(network, nic, networkAttachment, networkQos, reportedDnsResolverConfiguration);
            networkAttachmentModel.getIpv4Gateway().setIsAvailable(true);
            networkAttachmentModel.getIpv6Gateway().setIsAvailable(false);
        }
        networkAttachmentModel.getQosOverridden().setIsAvailable(true);
        networkAttachmentModel.getQosModel().setIsAvailable(true);
        KeyValueModel customPropertiesModel = networkAttachmentModel.getCustomPropertiesModel();
        customPropertiesModel.setIsAvailable(true);
        Map<String, String> validProperties = KeyValueModel.convertProperties((String) AsyncDataProvider.getInstance().getConfigValuePreConverted(ConfigValues.PreDefinedNetworkCustomProperties, version));
        // to backend and frontend (lvernia)
        if (!network.isVmNetwork()) {
            // $NON-NLS-1$
            validProperties.remove("bridge_opts");
        }
        validProperties.putAll(KeyValueModel.convertProperties((String) AsyncDataProvider.getInstance().getConfigValuePreConverted(ConfigValues.UserDefinedNetworkCustomProperties, version)));
        customPropertiesModel.setKeyValueMap(validProperties);
        customPropertiesModel.deserialize(KeyValueModel.convertProperties(networkAttachment.getProperties()));
        networkAttachmentModel.getIsToSync().setIsChangeable(!logicalNetworkModel.isInSync());
        networkAttachmentModel.getIsToSync().setEntity(shouldSyncNetwork(logicalNetworkModelName));
        networkAttachmentModel.getQosOverridden().setEntity(networkAttachment.isQosOverridden());
        editPopup = networkAttachmentModel;
        // OK Target
        okTarget = new BaseCommandTarget() {

            @Override
            public void executeCommand(UICommand command) {
                if (!networkAttachmentModel.validate()) {
                    return;
                }
                final FromNetworkAttachmentModel interfacePropertiesAccessor = new FromNetworkAttachmentModel(networkAttachmentModel);
                LogicalNetworkModelParametersHelper.populateIpv4Details(interfacePropertiesAccessor, networkAttachment.getIpConfiguration().getIpv4PrimaryAddress());
                LogicalNetworkModelParametersHelper.populateIpv6Details(interfacePropertiesAccessor, networkAttachment.getIpConfiguration().getIpv6PrimaryAddress());
                if (networkAttachmentModel.getQosModel().getIsAvailable()) {
                    if (networkAttachmentModel.getQosOverridden().getEntity()) {
                        HostNetworkQos overriddenQos = new HostNetworkQos();
                        networkAttachmentModel.getQosModel().flush(overriddenQos);
                        AnonymousHostNetworkQos hostNetworkQos = fromHostNetworkQos(overriddenQos);
                        networkAttachment.setHostNetworkQos(hostNetworkQos);
                    } else {
                        networkAttachment.setHostNetworkQos(null);
                    }
                }
                if (networkAttachmentModel.getIsToSync().getEntity()) {
                    hostSetupNetworksParametersData.getNetworksToSync().add(logicalNetworkModelName);
                } else {
                    hostSetupNetworksParametersData.getNetworksToSync().remove(logicalNetworkModelName);
                }
                boolean customPropertiesAvailable = networkAttachmentModel.getCustomPropertiesModel().getIsAvailable();
                Map<String, String> customProperties = customPropertiesAvailable ? KeyValueModel.convertProperties(networkAttachmentModel.getCustomPropertiesModel().serialize()) : null;
                networkAttachment.setProperties(customProperties);
                networkAttachment.setDnsResolverConfiguration(networkAttachmentModel.getDnsConfigurationModel().flush());
                sourceListModel.setConfirmWindow(null);
                redraw();
            }
        };
    }
    // ok command
    // $NON-NLS-1$
    UICommand okCommand = UICommand.createDefaultOkUiCommand("OK", okTarget);
    // cancel command
    UICommand cancelCommand = new UICommand("Cancel", new // $NON-NLS-1$
    BaseCommandTarget() {

        @Override
        public void executeCommand(UICommand command) {
            sourceListModel.setConfirmWindow(null);
        }
    });
    cancelCommand.setTitle(ConstantsManager.getInstance().getConstants().cancel());
    cancelCommand.setIsCancel(true);
    if (editPopup != null) {
        editPopup.getCommands().add(okCommand);
        editPopup.getCommands().add(cancelCommand);
    }
    sourceListModel.setConfirmWindow(editPopup);
}
Also used : AnonymousHostNetworkQos(org.ovirt.engine.core.common.businessentities.network.AnonymousHostNetworkQos) AnonymousHostNetworkQos.fromHostNetworkQos(org.ovirt.engine.core.common.businessentities.network.AnonymousHostNetworkQos.fromHostNetworkQos) HostNetworkQos(org.ovirt.engine.core.common.businessentities.network.HostNetworkQos) BondNetworkInterfaceModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.BondNetworkInterfaceModel) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment) FromNetworkAttachmentModel(org.ovirt.engine.ui.uicommonweb.models.hosts.InterfacePropertiesAccessor.FromNetworkAttachmentModel) BaseCommandTarget(org.ovirt.engine.ui.uicommonweb.BaseCommandTarget) Network(org.ovirt.engine.core.common.businessentities.network.Network) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) AnonymousHostNetworkQos(org.ovirt.engine.core.common.businessentities.network.AnonymousHostNetworkQos) HostNicVfsConfig(org.ovirt.engine.core.common.businessentities.network.HostNicVfsConfig) CreateOrUpdateBond(org.ovirt.engine.core.common.action.CreateOrUpdateBond) LogicalNetworkModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.LogicalNetworkModel) FromNetworkAttachmentModel(org.ovirt.engine.ui.uicommonweb.models.hosts.InterfacePropertiesAccessor.FromNetworkAttachmentModel) NetworkInterfaceModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkInterfaceModel) BondNetworkInterfaceModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.BondNetworkInterfaceModel) DataFromHostSetupNetworksModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.DataFromHostSetupNetworksModel) NetworkInterfaceModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkInterfaceModel) SearchableListModel(org.ovirt.engine.ui.uicommonweb.models.SearchableListModel) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) KeyValueModel(org.ovirt.engine.ui.uicommonweb.models.vms.key_value.KeyValueModel) LogicalNetworkModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.LogicalNetworkModel) NewNetworkLabelModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkLabelModel.NewNetworkLabelModel) FromNetworkAttachmentModel(org.ovirt.engine.ui.uicommonweb.models.hosts.InterfacePropertiesAccessor.FromNetworkAttachmentModel) Model(org.ovirt.engine.ui.uicommonweb.models.Model) BondNetworkInterfaceModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.BondNetworkInterfaceModel) NetworkItemModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkItemModel) NetworkLabelModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkLabelModel) KeyValueModel(org.ovirt.engine.ui.uicommonweb.models.vms.key_value.KeyValueModel) DnsResolverConfiguration(org.ovirt.engine.core.common.businessentities.network.DnsResolverConfiguration) Map(java.util.Map) HashMap(java.util.HashMap)

Example 5 with KeyValueModel

use of org.ovirt.engine.ui.uicommonweb.models.vms.key_value.KeyValueModel in project ovirt-engine by oVirt.

the class VmBaseListModel method displayHighPerformanceConfirmationPopup.

protected void displayHighPerformanceConfirmationPopup() {
    final UnitVmModel model = (UnitVmModel) getWindow();
    if (model == null || model.getProgress() != null) {
        return;
    }
    VmHighPerformanceConfigurationModel confirmModel = new VmHighPerformanceConfigurationModel();
    // Handle CPU Pinning topology
    final boolean isVmAssignedToSpecificHosts = !model.getIsAutoAssign().getEntity();
    final boolean isVmCpuPinningSet = model.getCpuPinning().getIsChangable() && model.getCpuPinning().getEntity() != null && !model.getCpuPinning().getEntity().isEmpty();
    confirmModel.addRecommendationForCpuPinning(isVmAssignedToSpecificHosts, isVmCpuPinningSet);
    // Handle NUMA
    final boolean isVmVirtNumaSet = model.getNumaEnabled().getEntity() && model.getNumaNodeCount().getEntity() > 0;
    final boolean isVmVirtNumaPinned = model.getVmNumaNodes() != null && !model.getVmNumaNodes().isEmpty() && model.getVmNumaNodes().stream().filter(x -> !x.getVdsNumaNodeList().isEmpty()).count() > 0;
    confirmModel.addRecommendationForVirtNumaSetAndPinned(isVmVirtNumaSet, isVmVirtNumaPinned);
    // Handle Huge Pages
    KeyValueModel keyValue = model.getCustomPropertySheet();
    // $NON-NLS-1$
    final boolean isVmHugePagesSet = keyValue != null && keyValue.getUsedKeys().contains("hugepages");
    confirmModel.addRecommendationForHugePages(isVmHugePagesSet);
    // Handle KSM (Kernel Same Page Merging)
    confirmModel.addRecommendationForKsm(model.getSelectedCluster().isEnableKsm(), model.getSelectedCluster().getName());
    // If there are recommendations to display and it is not a Pool VM then display the popup
    if (!confirmModel.getRecommendationsList().isEmpty() && !model.isVmAttachedToPool()) {
        confirmModel.setTitle(ConstantsManager.getInstance().getConstants().configurationChangesForHighPerformanceVmTitle());
        confirmModel.setHelpTag(HelpTag.configuration_changes_for_high_performance_vm);
        // $NON-NLS-1$
        confirmModel.setHashName("configuration_changes_for_high_performance_vm");
        confirmModel.getCommands().add(// $NON-NLS-1$
        new UICommand("SaveOrUpdateVM", VmBaseListModel.this).setTitle(ConstantsManager.getInstance().getConstants().ok()).setIsDefault(true));
        confirmModel.getCommands().add(// $NON-NLS-1$
        UICommand.createCancelUiCommand("CancelConfirmation", VmBaseListModel.this));
        setConfirmWindow(null);
        setConfirmWindow(confirmModel);
    } else {
        saveOrUpdateVM(model);
    }
}
Also used : ExportVmModel(org.ovirt.engine.ui.uicommonweb.models.vms.ExportVmModel) FullUnitToVmBaseBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.FullUnitToVmBaseBuilder) FrontendActionAsyncResult(org.ovirt.engine.ui.uicompat.FrontendActionAsyncResult) VmType(org.ovirt.engine.core.common.businessentities.VmType) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) AddVmParameters(org.ovirt.engine.core.common.action.AddVmParameters) ActionType(org.ovirt.engine.core.common.action.ActionType) VmWatchdogType(org.ovirt.engine.core.common.businessentities.VmWatchdogType) UnitVmModel(org.ovirt.engine.ui.uicommonweb.models.vms.UnitVmModel) Map(java.util.Map) VmInterfaceCreatingManager(org.ovirt.engine.ui.uicommonweb.models.vms.VmInterfaceCreatingManager) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) DisplayType(org.ovirt.engine.core.common.businessentities.DisplayType) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) StringHelper(org.ovirt.engine.core.compat.StringHelper) VmHighPerformanceConfigurationModel(org.ovirt.engine.ui.uicommonweb.models.vms.VmHighPerformanceConfigurationModel) List(java.util.List) KeyValueModel(org.ovirt.engine.ui.uicommonweb.models.vms.key_value.KeyValueModel) UnitToGraphicsDeviceParamsBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.UnitToGraphicsDeviceParamsBuilder) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) QueryType(org.ovirt.engine.core.common.queries.QueryType) GetAllFromExportDomainQueryParameters(org.ovirt.engine.core.common.queries.GetAllFromExportDomainQueryParameters) Guid(org.ovirt.engine.core.compat.Guid) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) StorageDomainStatus(org.ovirt.engine.core.common.businessentities.StorageDomainStatus) HasDiskWindow(org.ovirt.engine.ui.uicommonweb.models.vms.HasDiskWindow) ArrayList(java.util.ArrayList) AsyncCallback(org.ovirt.engine.ui.frontend.AsyncCallback) UnitVmModelNetworkAsyncCallback(org.ovirt.engine.ui.uicommonweb.models.vms.UnitVmModelNetworkAsyncCallback) Frontend(org.ovirt.engine.ui.frontend.Frontend) ExportOvaModel(org.ovirt.engine.ui.uicommonweb.models.vms.ExportOvaModel) BalloonEnabled(org.ovirt.engine.ui.uicommonweb.models.vms.BalloonEnabled) VmWatchdog(org.ovirt.engine.core.common.businessentities.VmWatchdog) Model(org.ovirt.engine.ui.uicommonweb.models.Model) Linq(org.ovirt.engine.ui.uicommonweb.Linq) BuilderExecutor(org.ovirt.engine.ui.uicommonweb.builders.BuilderExecutor) VmBasedWidgetSwitchModeCommand(org.ovirt.engine.ui.uicommonweb.models.vms.VmBasedWidgetSwitchModeCommand) IconUtils(org.ovirt.engine.ui.uicommonweb.IconUtils) VM(org.ovirt.engine.core.common.businessentities.VM) TabName(org.ovirt.engine.ui.uicommonweb.models.TabName) ListWithSimpleDetailsModel(org.ovirt.engine.ui.uicommonweb.models.ListWithSimpleDetailsModel) StorageDomainType(org.ovirt.engine.core.common.businessentities.StorageDomainType) VmManagementParametersBase(org.ovirt.engine.core.common.action.VmManagementParametersBase) VDS(org.ovirt.engine.core.common.businessentities.VDS) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) VmSpecificUnitToVmBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.VmSpecificUnitToVmBuilder) VmHighPerformanceConfigurationModel(org.ovirt.engine.ui.uicommonweb.models.vms.VmHighPerformanceConfigurationModel) KeyValueModel(org.ovirt.engine.ui.uicommonweb.models.vms.key_value.KeyValueModel) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) UnitVmModel(org.ovirt.engine.ui.uicommonweb.models.vms.UnitVmModel)

Aggregations

KeyValueModel (org.ovirt.engine.ui.uicommonweb.models.vms.key_value.KeyValueModel)5 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)4 Map (java.util.Map)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 List (java.util.List)2 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)2 Network (org.ovirt.engine.core.common.businessentities.network.Network)2 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)2 QueryType (org.ovirt.engine.core.common.queries.QueryType)2 Model (org.ovirt.engine.ui.uicommonweb.models.Model)2 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 Comparator (java.util.Comparator)1 HashSet (java.util.HashSet)1 LinkedHashMap (java.util.LinkedHashMap)1 Objects (java.util.Objects)1 Set (java.util.Set)1 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)1