Search in sources :

Example 1 with ClusterModel

use of org.ovirt.engine.ui.uicommonweb.models.clusters.ClusterModel in project ovirt-engine by oVirt.

the class ClusterPopupPresenterWidget method init.

@Override
public void init(final ClusterModel model) {
    super.init(model);
    model.getPropertyChangedEvent().addListener((ev, sender, args) -> {
        String propName = args.propertyName;
        if ("AllowClusterWithVirtGlusterEnabled".equals(propName)) {
            // $NON-NLS-1$
            getView().allowClusterWithVirtGlusterEnabled(model.getAllowClusterWithVirtGlusterEnabled());
        }
    });
    String spiceProxyInConfig = (String) AsyncDataProvider.getInstance().getConfigValuePreConverted(ConfigValues.SpiceProxyDefault);
    String spiceProxyMessage = StringHelper.isNullOrEmpty(spiceProxyInConfig) ? messages.noSpiceProxyDefined() : spiceProxyInConfig;
    getView().setSpiceProxyOverrideExplanation(messages.consoleOverrideSpiceProxyMessage(messages.consoleOverrideDefinedInGlobalConfig(), spiceProxyMessage));
    getModel().getVersion().getSelectedItemChangedEvent().addListener((ev, sender, args) -> {
        final Version selectedVersion = getModel().getVersion().getSelectedItem();
        if (selectedVersion == null) {
            return;
        }
        if (AsyncDataProvider.getInstance().isMigrationPoliciesSupported(selectedVersion)) {
            getView().getMigrationBandwidthLimitTypeEditor().setEnabled(true);
            updateCustomMigrationBandwidthLimitEnabledState(model, null);
        } else {
            final String supportedVersions = String.join(", ", // $NON-NLS-1$
            AsyncDataProvider.getInstance().getMigrationPoliciesSupportedVersions());
            final String message = messages.onlyAvailableInCompatibilityVersions(supportedVersions);
            getView().getMigrationBandwidthLimitTypeEditor().disable(message);
            getView().getMigrationBandwidthLimitTypeEditor().setEnabled(false);
            updateCustomMigrationBandwidthLimitEnabledState(model, message);
        }
    });
    getModel().getMigrationBandwidthLimitType().getSelectedItemChangedEvent().addListener((ev, sender, args) -> updateCustomMigrationBandwidthLimitEnabledState(model, null));
    model.getMacPoolModel().getEntityChangedEvent().addListener((ev, sender, args) -> getView().updateMacPool(model.getMacPoolModel()));
    final UICommand addMacPoolCommand = model.getAddMacPoolCommand();
    if (addMacPoolCommand == null) {
        getView().makeMacPoolButtonInvisible();
    } else {
        getView().getMacPoolButton().setCommand(addMacPoolCommand);
        registerHandler(getView().getMacPoolButton().addClickHandler(event -> getView().getMacPoolButton().getCommand().execute(model)));
    }
}
Also used : ClusterModel(org.ovirt.engine.ui.uicommonweb.models.clusters.ClusterModel) AbstractTabbedModelBoundPopupPresenterWidget(org.ovirt.engine.ui.common.presenter.AbstractTabbedModelBoundPopupPresenterWidget) MacPoolModel(org.ovirt.engine.ui.uicommonweb.models.macpool.MacPoolModel) EventBus(com.google.gwt.event.shared.EventBus) AssetProvider(org.ovirt.engine.ui.webadmin.gin.AssetProvider) HasUiCommandClickHandlers(org.ovirt.engine.ui.common.widget.HasUiCommandClickHandlers) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) Inject(com.google.inject.Inject) MigrationBandwidthLimitType(org.ovirt.engine.core.common.businessentities.MigrationBandwidthLimitType) ApplicationMessages(org.ovirt.engine.ui.webadmin.ApplicationMessages) ConfigValues(org.ovirt.engine.core.common.config.ConfigValues) StringHelper(org.ovirt.engine.core.compat.StringHelper) Optional(java.util.Optional) HasEnabledWithHints(org.ovirt.engine.ui.common.widget.HasEnabledWithHints) Version(org.ovirt.engine.core.compat.Version) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) Version(org.ovirt.engine.core.compat.Version) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand)

Example 2 with ClusterModel

use of org.ovirt.engine.ui.uicommonweb.models.clusters.ClusterModel in project ovirt-engine by oVirt.

the class DataCenterGuideModel method postOnAddCluster.

public void postOnAddCluster(ActionReturnValue returnValue) {
    ClusterModel model = (ClusterModel) getWindow();
    model.stopProgress();
    if (returnValue != null && returnValue.getSucceeded()) {
        cancel();
        postAction();
    }
}
Also used : ClusterModel(org.ovirt.engine.ui.uicommonweb.models.clusters.ClusterModel)

Example 3 with ClusterModel

use of org.ovirt.engine.ui.uicommonweb.models.clusters.ClusterModel in project ovirt-engine by oVirt.

the class DataCenterGuideModel method addCluster.

public void addCluster() {
    if (getWindow() != null) {
        return;
    }
    ClusterModel model = ClusterListModel.createNewClusterModel();
    setWindow(model);
    ArrayList<StoragePool> dataCenters = new ArrayList<>();
    dataCenters.add(getEntity());
    model.getDataCenter().setItems(dataCenters, getEntity());
    model.getDataCenter().setIsChangeable(false);
    // $NON-NLS-1$
    UICommand tempVar = UICommand.createDefaultOkUiCommand("OnAddCluster", this);
    model.getCommands().add(tempVar);
    // $NON-NLS-1$
    UICommand tempVar2 = UICommand.createCancelUiCommand("Cancel", this);
    model.getCommands().add(tempVar2);
}
Also used : ClusterModel(org.ovirt.engine.ui.uicommonweb.models.clusters.ClusterModel) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) ArrayList(java.util.ArrayList) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand)

Example 4 with ClusterModel

use of org.ovirt.engine.ui.uicommonweb.models.clusters.ClusterModel in project ovirt-engine by oVirt.

the class DataCenterGuideModel method onAddCluster.

public void onAddCluster() {
    ClusterModel model = (ClusterModel) getWindow();
    Cluster cluster = ClusterListModel.buildCluster(model, new Cluster());
    if (model.getProgress() != null) {
        return;
    }
    model.startProgress();
    Frontend.getInstance().runAction(ActionType.AddCluster, new ManagementNetworkOnClusterOperationParameters(cluster), result -> {
        DataCenterGuideModel localModel = (DataCenterGuideModel) result.getState();
        localModel.postOnAddCluster(result.getReturnValue());
    }, this);
}
Also used : ClusterModel(org.ovirt.engine.ui.uicommonweb.models.clusters.ClusterModel) ManagementNetworkOnClusterOperationParameters(org.ovirt.engine.core.common.action.ManagementNetworkOnClusterOperationParameters) Cluster(org.ovirt.engine.core.common.businessentities.Cluster)

Example 5 with ClusterModel

use of org.ovirt.engine.ui.uicommonweb.models.clusters.ClusterModel in project ovirt-engine by oVirt.

the class AddClusterRM method prepare2.

public void prepare2() {
    PreparingEnlistment enlistment = (PreparingEnlistment) context.enlistment;
    EnlistmentContext enlistmentContext = (EnlistmentContext) enlistment.getContext();
    HostListModel<?> model = enlistmentContext.getModel();
    ConfigureLocalStorageModel configureModel = (ConfigureLocalStorageModel) model.getWindow();
    Cluster candidate = configureModel.getCandidateCluster();
    ClusterModel clusterModel = configureModel.getCluster();
    String clusterName = clusterModel.getName().getEntity();
    if (candidate == null || !Objects.equals(candidate.getName(), clusterName)) {
        // Try to find existing cluster with the specified name.
        Cluster cluster = context.clusterFoundByName;
        if (cluster != null) {
            enlistmentContext.setClusterId(cluster.getId());
            context.enlistment = null;
            enlistment.prepared();
        } else {
            Version version = clusterModel.getVersion().getSelectedItem();
            cluster = new Cluster();
            cluster.setName(clusterName);
            cluster.setDescription(clusterModel.getDescription().getEntity());
            cluster.setStoragePoolId(enlistmentContext.getDataCenterId());
            cluster.setCpuName(clusterModel.getCPU().getSelectedItem().getCpuName());
            cluster.setMaxVdsMemoryOverCommit(clusterModel.getMemoryOverCommit());
            cluster.setCountThreadsAsCores(Boolean.TRUE.equals(clusterModel.getVersionSupportsCpuThreads().getEntity()) && Boolean.TRUE.equals(clusterModel.getCountThreadsAsCores().getEntity()));
            cluster.setTransparentHugepages(true);
            cluster.setCompatibilityVersion(version);
            cluster.setMigrateOnError(clusterModel.getMigrateOnErrorOption());
            ClusterOperationParameters parameters = new ManagementNetworkOnClusterOperationParameters(cluster);
            parameters.setCorrelationId(getCorrelationId());
            Frontend.getInstance().runAction(ActionType.AddCluster, parameters, result -> {
                ActionReturnValue returnValue = result.getReturnValue();
                context.addClusterReturnValue = returnValue;
                prepare3();
            });
        }
    } else {
        enlistmentContext.setClusterId(configureModel.getCluster().getClusterId());
        context.enlistment = null;
        enlistment.prepared();
    }
}
Also used : ClusterModel(org.ovirt.engine.ui.uicommonweb.models.clusters.ClusterModel) ManagementNetworkOnClusterOperationParameters(org.ovirt.engine.core.common.action.ManagementNetworkOnClusterOperationParameters) PreparingEnlistment(org.ovirt.engine.ui.uicompat.PreparingEnlistment) Version(org.ovirt.engine.core.compat.Version) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) ClusterOperationParameters(org.ovirt.engine.core.common.action.ClusterOperationParameters) ManagementNetworkOnClusterOperationParameters(org.ovirt.engine.core.common.action.ManagementNetworkOnClusterOperationParameters)

Aggregations

ClusterModel (org.ovirt.engine.ui.uicommonweb.models.clusters.ClusterModel)6 ManagementNetworkOnClusterOperationParameters (org.ovirt.engine.core.common.action.ManagementNetworkOnClusterOperationParameters)3 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)3 Version (org.ovirt.engine.core.compat.Version)3 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)2 ClusterOperationParameters (org.ovirt.engine.core.common.action.ClusterOperationParameters)2 StringHelper (org.ovirt.engine.core.compat.StringHelper)2 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)2 AsyncDataProvider (org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)2 PreparingEnlistment (org.ovirt.engine.ui.uicompat.PreparingEnlistment)2 EventBus (com.google.gwt.event.shared.EventBus)1 Inject (com.google.inject.Inject)1 ArrayList (java.util.ArrayList)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 ActionType (org.ovirt.engine.core.common.action.ActionType)1 MigrationBandwidthLimitType (org.ovirt.engine.core.common.businessentities.MigrationBandwidthLimitType)1 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)1 ConfigValues (org.ovirt.engine.core.common.config.ConfigValues)1 Guid (org.ovirt.engine.core.compat.Guid)1