ofri masad has uploaded a new change for review. Change subject: webadmin: Add cluster policy to edit cluster ......................................................................
webadmin: Add cluster policy to edit cluster Added the ability to set the cluster policy in the create/edit cluster popup view Change-Id: I195d9ec1c7901a31e6e656221964d82bc90c9695 Bug-Url: https://bugzilla.redhat.com/666790 Signed-off-by: Ofri Masad <oma...@redhat.com> --- M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterListModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterModel.java M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/cluster/ClusterPopupView.java M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/cluster/ClusterPopupView.ui.xml 5 files changed, 349 insertions(+), 5 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/73/10573/1 diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterListModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterListModel.java index c05b6c1..aa25c84 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterListModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterListModel.java @@ -324,6 +324,13 @@ clusterModel.getEnableOvirtService().setIsChangable(true); clusterModel.getEnableGlusterService().setEntity(cluster.supportsGlusterService()); clusterModel.getEnableGlusterService().setIsChangable(true); + clusterModel.setSelectionAlgorithm(cluster.getselection_algorithm()); + clusterModel.getOverCommitTime().setEntity(cluster.getcpu_over_commit_duration_minutes()); + clusterModel.setOverCommitLowLevel(cluster.getlow_utilization()); + clusterModel.setOverCommitHighLevel(cluster.gethigh_utilization()); + + clusterModel.SaveDefaultValues(); + AsyncDataProvider.GetAllowClusterWithVirtGlusterEnabled(new AsyncQuery(this, new INewAsyncCallback() { @Override @@ -572,6 +579,14 @@ cluster.setMigrateOnError(model.getMigrateOnErrorOption()); cluster.setVirtService((Boolean) model.getEnableOvirtService().getEntity()); cluster.setGlusterService((Boolean) model.getEnableGlusterService().getEntity()); + cluster.setselection_algorithm(model.getSelectionAlgorithm()); + if (model.getOverCommitTime().getIsAvailable()) + { + cluster.setcpu_over_commit_duration_minutes(Integer.parseInt(model.getOverCommitTime() + .getEntity() + .toString())); + } cluster.setlow_utilization(model.getOverCommitLowLevel()); + cluster.sethigh_utilization(model.getOverCommitHighLevel()); model.StartProgress(null); diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterModel.java index dc69e2a..e1ac41c 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterModel.java @@ -22,14 +22,13 @@ import org.ovirt.engine.ui.uicommonweb.models.ApplicationModeHelper; import org.ovirt.engine.ui.uicommonweb.models.EntityModel; import org.ovirt.engine.ui.uicommonweb.models.ListModel; -import org.ovirt.engine.ui.uicommonweb.models.Model; import org.ovirt.engine.ui.uicommonweb.validation.I18NNameValidation; import org.ovirt.engine.ui.uicommonweb.validation.IValidation; import org.ovirt.engine.ui.uicommonweb.validation.LengthValidation; import org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation; import org.ovirt.engine.ui.uicompat.ConstantsManager; -public class ClusterModel extends Model +public class ClusterModel extends ClusterPolicyModel { private int privateServerOverCommit; @@ -570,6 +569,7 @@ public ClusterModel() { + super(); } public void Init(final boolean isEdit) @@ -1091,7 +1091,7 @@ && getGlusterHostPassword().getIsValid() && ((Boolean) getIsImportGlusterConfiguration().getEntity() ? isFingerprintVerified() : true)); - return getName().getIsValid() && getDataCenter().getIsValid() && getCPU().getIsValid() + return super.Validate() && getName().getIsValid() && getDataCenter().getIsValid() && getCPU().getIsValid() && getVersion().getIsValid() && validService && getGlusterHostAddress().getIsValid() && getGlusterHostPassword().getIsValid() && ((Boolean) getIsImportGlusterConfiguration().getEntity() ? isFingerprintVerified() : true); diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java index 33fac0b..b550cfe 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java @@ -592,6 +592,9 @@ @DefaultStringValue("Resilience Policy") String clusterPopupResiliencePolicyTabLabel(); + @DefaultStringValue("Cluster Policy") + String clusterPopupClusterPolicyTabLabel(); + @DefaultStringValue("Migrate Virtual Machines") String clusterPopupMigrateOnError_YesLabel(); diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/cluster/ClusterPopupView.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/cluster/ClusterPopupView.java index e380549..2d34106 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/cluster/ClusterPopupView.java +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/cluster/ClusterPopupView.java @@ -1,6 +1,12 @@ package org.ovirt.engine.ui.webadmin.section.main.view.popup.cluster; +import com.google.gwt.event.logical.shared.ValueChangeEvent; +import com.google.gwt.event.logical.shared.ValueChangeHandler; +import com.google.gwt.user.client.ui.HorizontalPanel; +import com.google.gwt.user.client.ui.RadioButton; +import com.google.gwt.user.client.ui.SimplePanel; import org.ovirt.engine.core.common.businessentities.ServerCpu; +import org.ovirt.engine.core.common.businessentities.VdsSelectionAlgorithm; import org.ovirt.engine.core.common.businessentities.storage_pool; import org.ovirt.engine.core.common.mode.ApplicationMode; import org.ovirt.engine.core.compat.Event; @@ -20,9 +26,11 @@ import org.ovirt.engine.ui.common.widget.editor.EntityModelTextAreaLabelEditor; import org.ovirt.engine.ui.common.widget.editor.EntityModelTextBoxEditor; import org.ovirt.engine.ui.common.widget.editor.ListModelListBoxEditor; +import org.ovirt.engine.ui.common.widget.form.Slider; import org.ovirt.engine.ui.common.widget.renderer.NullSafeRenderer; import org.ovirt.engine.ui.uicommonweb.models.ApplicationModeHelper; import org.ovirt.engine.ui.uicommonweb.models.clusters.ClusterModel; +import org.ovirt.engine.ui.uicommonweb.models.clusters.ClusterPolicyModel; import org.ovirt.engine.ui.webadmin.ApplicationConstants; import org.ovirt.engine.ui.webadmin.ApplicationMessages; import org.ovirt.engine.ui.webadmin.ApplicationResources; @@ -40,7 +48,15 @@ import com.google.gwt.user.client.ui.VerticalPanel; import com.google.inject.Inject; -public class ClusterPopupView extends AbstractModelBoundPopupView<ClusterModel> implements ClusterPopupPresenterWidget.ViewDef { +public class ClusterPopupView extends AbstractModelBoundPopupView<ClusterModel> implements ClusterPopupPresenterWidget.ViewDef, Slider.SliderValueChange { + + private static final String RIGHT = "right"; //$NON-NLS-1$ + + private static final String LEFT = "left"; //$NON-NLS-1$ + + private static final String MAX_COLOR = "#4E9FDD"; //$NON-NLS-1$ + + private static final String MIN_COLOR = "#AFBF27"; //$NON-NLS-1$ interface Driver extends SimpleBeanEditorDriver<ClusterModel, ClusterPopupView> { Driver driver = GWT.create(Driver.class); @@ -210,6 +226,60 @@ @WithElementId EntityModelRadioButtonEditor migrateOnErrorOption_NOEditor; + @UiField + @WithElementId + DialogTab clusterPolicyTab; + + @UiField(provided = true) + Slider leftSlider; + + @UiField(provided = true) + Slider rightSlider; + + @UiField(provided = true) + @Ignore + Label maxServiceLevelLabel; + + @UiField(provided = true) + @Ignore + Label minServiceLevelLabel; + + @UiField(provided = true) + @Ignore + SimplePanel leftDummySlider; + + @UiField(provided = true) + @Ignore + SimplePanel rightDummySlider; + + @UiField(provided = true) + @Ignore + RadioButton policyRadioButton_none; + + @UiField(provided = true) + @Ignore + RadioButton policyRadioButton_evenDist; + + @UiField(provided = true) + @Ignore + RadioButton policyRadioButton_powerSave; + + @UiField(provided = true) + @Path(value = "overCommitTime.entity") + EntityModelTextBoxEditor overCommitTimeEditor; + + @UiField + @Ignore + HorizontalPanel timeHorizontalPanel; + + @UiField + @Ignore + Label forTimeLabel; + + @UiField + @Ignore + Label minTimeLabel; + private ApplicationMessages messages; @Inject @@ -220,8 +290,15 @@ initRadioButtonEditors(); initCheckBoxEditors(); initInfoIcons(resources, constants, templates); + + initSliders(); + initLabels(); + initRadioButtons(); + initDummyPanel(); + initTextBox(); initWidget(ViewUiBinder.uiBinder.createAndBindUi(this)); ViewIdHandler.idHandler.generateAndSetIds(this); + addStyles(); localize(constants); Driver.driver.initialize(this); @@ -240,6 +317,8 @@ optimizationCustomEditor.setContentWidgetStyleName(style.fullWidth()); countThreadsAsCoresEditor.setContentWidgetStyleName(style.fullWidth()); + + overCommitTimeEditor.addContentWidgetStyleName(style.timeTextBoxEditorWidget()); } private void localize(ApplicationConstants constants) { @@ -275,6 +354,15 @@ migrateOnErrorOption_HA_ONLYEditor.setLabel(constants.clusterPopupMigrateOnError_HaLabel()); migrateOnErrorOption_NOEditor.setLabel(constants.clusterPopupMigrateOnError_NoLabel()); + clusterPolicyTab.setLabel(constants.clusterPopupClusterPolicyTabLabel()); + + policyRadioButton_none.setText(constants.clusterPolicyNoneLabel()); + policyRadioButton_evenDist.setText(constants.clusterPolicyEvenDistLabel()); + policyRadioButton_powerSave.setText(constants.clusterPolicyPowSaveLabel()); + maxServiceLevelLabel.setText(constants.clusterPolicyMaxServiceLevelLabel()); + minServiceLevelLabel.setText(constants.clusterPolicyMinServiceLevelLabel()); + forTimeLabel.setText(constants.clusterPolicyForTimeLabel()); + minTimeLabel.setText(constants.clusterPolicyMinTimeLabel()); } private void initRadioButtonEditors() { @@ -334,6 +422,7 @@ { optimizationTab.setVisible(false); resiliencePolicyTab.setVisible(false); + clusterPolicyTab.setVisible(true); dataCenterPanel.addStyleName(style.generalTabTopDecoratorEmpty()); } } @@ -402,6 +491,23 @@ cpuThreadsPanel.setVisible((Boolean) object.getVersionSupportsCpuThreads().getEntity()); } }); + + object.getOverCommitTime().getEntityChangedEvent().addListener(new IEventListener() { + @Override + public void eventRaised(Event ev, Object sender, EventArgs args) { + setClusterPolicyModel(object); + if (getClusterPolicyModel().getSelectionAlgorithm().equals(VdsSelectionAlgorithm.PowerSave)) { + policyRadioButton_powerSave.setValue(true); + } else if (getClusterPolicyModel().getSelectionAlgorithm() + .equals(VdsSelectionAlgorithm.EvenlyDistribute)) { + policyRadioButton_evenDist.setValue(true); + } else { + policyRadioButton_none.setValue(true); + } + + setSelectionAlgorithm(); + } + }); } private void optimizationForServerFormatter(ClusterModel object) { @@ -454,5 +560,129 @@ String editorContentWidget(); String fullWidth(); + + String timeTextBoxEditorWidget(); + } + + private ClusterPolicyModel clusterPolicyModel; + + public ClusterPolicyModel getClusterPolicyModel() { + return clusterPolicyModel; + } + + public void setClusterPolicyModel(ClusterPolicyModel entity) { + this.clusterPolicyModel = entity; + } + + private void initTextBox() { + overCommitTimeEditor = new EntityModelTextBoxEditor(); + } + + private void initRadioButtons() { + policyRadioButton_none = new RadioButton("policyRadioButtonGroup", ""); //$NON-NLS-1$ //$NON-NLS-2$ + policyRadioButton_evenDist = new RadioButton("policyRadioButtonGroup", ""); //$NON-NLS-1$ //$NON-NLS-2$ + policyRadioButton_powerSave = new RadioButton("policyRadioButtonGroup", ""); //$NON-NLS-1$ //$NON-NLS-2$ + + policyRadioButton_none.addValueChangeHandler(new ValueChangeHandler<Boolean>() { + + @Override + public void onValueChange(ValueChangeEvent<Boolean> event) { + if (event.getValue()) { + getClusterPolicyModel().setSelectionAlgorithm(VdsSelectionAlgorithm.None); + } + setSelectionAlgorithm(); + } + }); + + policyRadioButton_evenDist.addValueChangeHandler(new ValueChangeHandler<Boolean>() { + + @Override + public void onValueChange(ValueChangeEvent<Boolean> event) { + if (event.getValue()) { + getClusterPolicyModel().setSelectionAlgorithm(VdsSelectionAlgorithm.EvenlyDistribute); + } + setSelectionAlgorithm(); + } + }); + + policyRadioButton_powerSave.addValueChangeHandler(new ValueChangeHandler<Boolean>() { + + @Override + public void onValueChange(ValueChangeEvent<Boolean> event) { + if (event.getValue()) { + getClusterPolicyModel().setSelectionAlgorithm(VdsSelectionAlgorithm.PowerSave); + } + setSelectionAlgorithm(); + } + }); + + } + + private void initDummyPanel() { + leftDummySlider = new SimplePanel(); + leftDummySlider.setVisible(false); + rightDummySlider = new SimplePanel(); + rightDummySlider.setVisible(false); + } + + private void initLabels() { + maxServiceLevelLabel = new Label(); + minServiceLevelLabel = new Label(); + } + + private void initSliders() { + leftSlider = new Slider(4, 10, 50, 20, MIN_COLOR); + leftSlider.setSliderValueChange(LEFT, this); + rightSlider = new Slider(4, 51, 90, 75, MAX_COLOR); + rightSlider.setSliderValueChange(RIGHT, this); + } + + private void setVisibility(boolean b) { + rightSlider.setVisible(b); + leftSlider.setVisible(b); + leftDummySlider.setVisible(false); + rightDummySlider.setVisible(false); + timeHorizontalPanel.setVisible(b); + } + + private void setSelectionAlgorithm() { + if (getClusterPolicyModel().getSelectionAlgorithm().equals(VdsSelectionAlgorithm.PowerSave)) { + setVisibility(true); + leftSlider.setValue((getClusterPolicyModel().getOverCommitLowLevel() < 10 ? 20 + : getClusterPolicyModel().getOverCommitLowLevel())); + if (getClusterPolicyModel().getOverCommitHighLevel() <= 50 + || getClusterPolicyModel().getOverCommitHighLevel() > 90) { + rightSlider.setValue(75); + } else { + rightSlider.setValue(getClusterPolicyModel().getOverCommitHighLevel()); + } + // timeTextBox.setText(getClusterPolicyModel().getOverCommitTime().getEntity() + ""); + } else if (getClusterPolicyModel().getSelectionAlgorithm() + .equals(VdsSelectionAlgorithm.EvenlyDistribute)) { + setVisibility(true); + leftSlider.setVisible(false); + leftDummySlider.setVisible(true); + if (getClusterPolicyModel().getOverCommitHighLevel() <= 50 + || getClusterPolicyModel().getOverCommitHighLevel() >= 90) { + rightSlider.setValue(75); + } else { + rightSlider.setValue(getClusterPolicyModel().getOverCommitHighLevel()); + } + // timeTextBox.setText(getClusterPolicyModel().getOverCommitTime().getEntity() + ""); + } else { // also for VdsSelectionAlgorithm.None + + setVisibility(false); + leftDummySlider.setVisible(true); + rightDummySlider.setVisible(true); + } + } + + @Override + public void onSliderValueChange(String name, int value) { + if (name.equals(RIGHT)) { + getClusterPolicyModel().setOverCommitHighLevel(value); + } else if (name.equals(LEFT)) { + getClusterPolicyModel().setOverCommitLowLevel(value); + } } } diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/cluster/ClusterPopupView.ui.xml b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/cluster/ClusterPopupView.ui.xml index 97fe671..9ed278f 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/cluster/ClusterPopupView.ui.xml +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/cluster/ClusterPopupView.ui.xml @@ -2,7 +2,8 @@ <!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent"> <ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder" xmlns:g="urn:import:com.google.gwt.user.client.ui" xmlns:d="urn:import:org.ovirt.engine.ui.common.widget.dialog" - xmlns:e="urn:import:org.ovirt.engine.ui.common.widget.editor" xmlns:t="urn:import:org.ovirt.engine.ui.common.widget.dialog.tab"> + xmlns:e="urn:import:org.ovirt.engine.ui.common.widget.editor" xmlns:t="urn:import:org.ovirt.engine.ui.common.widget.dialog.tab" + xmlns:f="urn:import:org.ovirt.engine.ui.common.widget.form"> <ui:with field='resources' type='org.ovirt.engine.ui.webadmin.ApplicationResources' /> @@ -72,6 +73,60 @@ .nestedSubsequentPanel { padding-top: 24px; } + + .button { + width: 100px; + margin: 10; + } + .transparent { + width: 400px; + height: 40px; + opacity: .8; + } + .geryPanel { + background-color: grey; + height: 20px; + width: 160px; + } + .minLabel { + height: 10px; + width: 10px; + margin: 3px; + background-color: #AFBF27; + } + .maxLabel { + height: 10px; + width: 10px; + margin: 3px; + background-color: #4E9FDD; + } + .marginPanel { + margin: 5px; + } + .topMarginPanel { + margin-top: 10px; + } + .minMaxPanel { + margin-top: 30px; + } + + .timeTextBoxEditorWidget { + width: 30px; + padding: 0px; + margin: 0px; + vertical-align: top; + height: 20px; + line-height: 20px; + } + .labelStyle { + margin-top: 3px; + margin-left: 5px; + } + .gerySplitPanel { + background-color: grey; + height: 20px; + width: 8px; + } </ui:style> <d:SimpleDialogPanel width="610px" height="560px"> @@ -138,6 +193,47 @@ </t:content> </t:DialogTab> </t:tab> + <t:tab> + <t:DialogTab ui:field="clusterPolicyTab"> + <t:content> + <g:VerticalPanel> + <g:FlowPanel width="300px"> + <g:HorizontalPanel addStyleNames="{style.marginPanel}"> + <g:RadioButton ui:field="policyRadioButton_none"/> + <g:RadioButton ui:field="policyRadioButton_evenDist"/> + <g:RadioButton ui:field="policyRadioButton_powerSave"/> + </g:HorizontalPanel> + <g:FlowPanel> + <g:HorizontalPanel addStyleNames="{style.marginPanel}"> + <g:SimplePanel ui:field="leftDummySlider" + addStyleNames="{style.geryPanel}" /> + <f:Slider ui:field="leftSlider" /> + <g:SimplePanel addStyleNames="{style.gerySplitPanel}"/> + <f:Slider ui:field="rightSlider" /> + <g:SimplePanel ui:field="rightDummySlider" + addStyleNames="{style.geryPanel}" /> + </g:HorizontalPanel> + </g:FlowPanel> + <g:HorizontalPanel ui:field="timeHorizontalPanel" width="70px" height="20px"> + <g:Label ui:field="forTimeLabel" addStyleNames="{style.labelStyle}"/> + <e:EntityModelTextBoxEditor ui:field="overCommitTimeEditor" width="40px" height="20px" addStyleNames="{style.timeTextBoxEditorWidget}"/> + <g:Label ui:field="minTimeLabel" addStyleNames="{style.labelStyle}"/> + </g:HorizontalPanel> + </g:FlowPanel> + <g:FlowPanel> + <g:HorizontalPanel addStyleNames="{style.minMaxPanel}" > + <g:SimplePanel addStyleNames="{style.maxLabel}"/> + <g:Label ui:field="maxServiceLevelLabel"/> + </g:HorizontalPanel> + <g:HorizontalPanel> + <g:SimplePanel addStyleNames="{style.minLabel}"/> + <g:Label ui:field="minServiceLevelLabel"/> + </g:HorizontalPanel> + </g:FlowPanel> + </g:VerticalPanel> + </t:content> + </t:DialogTab> + </t:tab> </t:DialogTabPanel> </d:content> </d:SimpleDialogPanel> -- To view, visit http://gerrit.ovirt.org/10573 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I195d9ec1c7901a31e6e656221964d82bc90c9695 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: ofri masad <oma...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches