Gilad Chaplik has uploaded a new change for review. Change subject: webadmin: add cluster policy in cluster view ......................................................................
webadmin: add cluster policy in cluster view Select cluster policy in new/edit cluster dialog. Change-Id: Id27916bf545eacbcb7ae7658bd89ddc1c6251dfa Signed-off-by: Gilad Chaplik <gchap...@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/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 4 files changed, 180 insertions(+), 5 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/76/16376/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 fff17ef..bfb2933 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 @@ -19,6 +19,7 @@ import org.ovirt.engine.core.common.queries.SearchParameters; import org.ovirt.engine.core.common.queries.VdcQueryReturnValue; import org.ovirt.engine.core.common.queries.VdcQueryType; +import org.ovirt.engine.core.common.scheduling.ClusterPolicy; import org.ovirt.engine.core.compat.Guid; import org.ovirt.engine.core.compat.StringHelper; import org.ovirt.engine.core.compat.Version; @@ -40,6 +41,7 @@ import org.ovirt.engine.ui.uicommonweb.models.gluster.GlusterFeaturesUtil; import org.ovirt.engine.ui.uicommonweb.models.hosts.HostDetailModel; import org.ovirt.engine.ui.uicommonweb.models.hosts.MultipleHostsModel; +import org.ovirt.engine.ui.uicommonweb.models.vms.key_value.KeyValueModel; import org.ovirt.engine.ui.uicompat.ConstantsManager; import org.ovirt.engine.ui.uicompat.FrontendActionAsyncResult; import org.ovirt.engine.ui.uicompat.FrontendMultipleActionAsyncResult; @@ -624,6 +626,8 @@ .toString())); } cluster.setlow_utilization(model.getClusterPolicyModel().getOverCommitLowLevel()); cluster.sethigh_utilization(model.getClusterPolicyModel().getOverCommitHighLevel()); + cluster.setClusterPolicyId(((ClusterPolicy) model.getClusterPolicy().getSelectedItem()).getId()); + cluster.setClusterPolicyProperties(KeyValueModel.convertProperties(model.getCustomPropertySheet().getEntity())); 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 5e36e28..d55f451 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 @@ -1,6 +1,9 @@ package org.ovirt.engine.ui.uicommonweb.models.clusters; import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; import org.ovirt.engine.core.common.businessentities.MigrateOnErrorOptions; import org.ovirt.engine.core.common.businessentities.ServerCpu; @@ -8,16 +11,24 @@ import org.ovirt.engine.core.common.businessentities.StorageType; import org.ovirt.engine.core.common.businessentities.VDSGroup; import org.ovirt.engine.core.common.mode.ApplicationMode; +import org.ovirt.engine.core.common.queries.VdcQueryParametersBase; +import org.ovirt.engine.core.common.queries.VdcQueryReturnValue; +import org.ovirt.engine.core.common.queries.VdcQueryType; +import org.ovirt.engine.core.common.scheduling.ClusterPolicy; +import org.ovirt.engine.core.common.scheduling.PolicyUnit; +import org.ovirt.engine.core.common.utils.Pair; import org.ovirt.engine.core.compat.Guid; import org.ovirt.engine.core.compat.StringHelper; import org.ovirt.engine.core.compat.Version; import org.ovirt.engine.ui.frontend.AsyncQuery; +import org.ovirt.engine.ui.frontend.Frontend; import org.ovirt.engine.ui.frontend.INewAsyncCallback; import org.ovirt.engine.ui.uicommonweb.Linq; import org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider; 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.vms.key_value.KeyValueModel; import org.ovirt.engine.ui.uicommonweb.validation.I18NNameValidation; import org.ovirt.engine.ui.uicommonweb.validation.IValidation; import org.ovirt.engine.ui.uicommonweb.validation.LengthValidation; @@ -30,6 +41,26 @@ public class ClusterModel extends EntityModel { + private Map<Guid, PolicyUnit> policyUnitMap; + private ListModel clusterPolicy; + + public ListModel getClusterPolicy() { + return clusterPolicy; + } + + public void setClusterPolicy(ListModel clusterPolicy) { + this.clusterPolicy = clusterPolicy; + } + + private KeyValueModel customPropertySheet; + + public KeyValueModel getCustomPropertySheet() { + return customPropertySheet; + } + + public void setCustomPropertySheet(KeyValueModel customPropertySheet) { + this.customPropertySheet = customPropertySheet; + } private int privateServerOverCommit; @@ -760,6 +791,57 @@ setIsGeneralTabValid(true); setIsResiliencePolicyTabAvailable(true); + + setClusterPolicy(new ListModel()); + setCustomPropertySheet(new KeyValueModel()); + getClusterPolicy().getSelectedItemChangedEvent().addListener(this); + Frontend.RunQuery(VdcQueryType.GetAllPolicyUnits, new VdcQueryParametersBase(), new AsyncQuery(this, + new INewAsyncCallback() { + + @Override + public void onSuccess(Object model, Object returnValue) { + ClusterModel clusterModel = (ClusterModel) model; + ArrayList<PolicyUnit> policyUnits = + (ArrayList<PolicyUnit>) ((VdcQueryReturnValue) returnValue).getReturnValue(); + policyUnitMap = new LinkedHashMap<Guid, PolicyUnit>(); + for (PolicyUnit policyUnit : policyUnits) { + policyUnitMap.put(policyUnit.getId(), policyUnit); + } + Frontend.RunQuery(VdcQueryType.GetClusterPolicies, + new VdcQueryParametersBase(), + new AsyncQuery(model, + new INewAsyncCallback() { + + @Override + public void onSuccess(Object model, Object returnValue) { + ClusterModel clusterModel = (ClusterModel) model; + ArrayList<ClusterPolicy> list = + (ArrayList<ClusterPolicy>) ((VdcQueryReturnValue) returnValue).getReturnValue(); + clusterModel.getClusterPolicy().setItems(list); + ClusterPolicy defaultClusterPolicy = null; + ClusterPolicy selectedClusterPolicy = null; + for (ClusterPolicy clusterPolicy : list) { + if (clusterModel.getIsEdit() && getEntity() != null + && clusterPolicy.getId() + .equals(getEntity().getClusterPolicyId())) { + selectedClusterPolicy = clusterPolicy; + } + if (clusterPolicy.isDefaultPolicy()) { + defaultClusterPolicy = clusterPolicy; + } + } + if (selectedClusterPolicy != null) { + clusterModel.getClusterPolicy() + .setSelectedItem(selectedClusterPolicy); + } else { + clusterModel.getClusterPolicy() + .setSelectedItem(defaultClusterPolicy); + } + + } + })); + } + })); } private void initImportCluster(boolean isEdit) @@ -887,6 +969,9 @@ else if (sender == getVersion()) { version_SelectedItemChanged(args); + } + else if (sender == getClusterPolicy()) { + clusterPolicyChanged(); } } else if (ev.matchesDefinition(EntityModel.EntityChangedEventDefinition)) @@ -1042,6 +1127,39 @@ AsyncDataProvider.getDataCenterVersions(_asyncQuery, selectedDataCenter.getId()); } + private void clusterPolicyChanged() { + ClusterPolicy clusterPolicy = (ClusterPolicy) getClusterPolicy().getSelectedItem(); + ArrayList<String> lines = new ArrayList<String>(); + Map<Guid, PolicyUnit> allPolicyUnits = new HashMap<Guid, PolicyUnit>(); + if (clusterPolicy.getFilters() != null) { + for (Guid policyUnitId : clusterPolicy.getFilters()) { + allPolicyUnits.put(policyUnitId, policyUnitMap.get(policyUnitId)); + } + } + if (clusterPolicy.getFunctions() != null) { + for (Pair<Guid, Integer> pair : clusterPolicy.getFunctions()) { + allPolicyUnits.put(pair.getFirst(), policyUnitMap.get(pair.getFirst())); + } + } + if (clusterPolicy.getBalance() != null) { + allPolicyUnits.put(clusterPolicy.getBalance(), policyUnitMap.get(clusterPolicy.getBalance())); + } + + for (PolicyUnit policyUnit : allPolicyUnits.values()) { + if (policyUnit.getParameterRegExMap() != null) { + for (Map.Entry<String, String> keyValue : policyUnit.getParameterRegExMap().entrySet()) { + lines.add(keyValue.getKey() + '=' + keyValue.getValue()); + } + } + } + getCustomPropertySheet().setKeyValueString(lines); + if (getIsEdit()) { + getCustomPropertySheet().setEntity(KeyValueModel.convertProperties(getEntity().getClusterPolicyProperties())); + } else { + getCustomPropertySheet().setEntity(KeyValueModel.convertProperties(clusterPolicy.getParameterMap())); + } + } + public boolean validate(boolean validateCpu) { return validate(true, validateCpu); @@ -1117,7 +1235,8 @@ && getGlusterHostPassword().getIsValid() && ((Boolean) getIsImportGlusterConfiguration().getEntity() ? (getGlusterHostAddress().getIsValid() && getGlusterHostPassword().getIsValid() - && isFingerprintVerified()) : true); + && isFingerprintVerified()) : true) + && getCustomPropertySheet().validate(); } } 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 e9d8f45..253310f 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,9 +1,10 @@ package org.ovirt.engine.ui.webadmin.section.main.view.popup.cluster; import org.ovirt.engine.core.common.businessentities.ServerCpu; -import org.ovirt.engine.core.common.businessentities.VdsSelectionAlgorithm; import org.ovirt.engine.core.common.businessentities.StoragePool; +import org.ovirt.engine.core.common.businessentities.VdsSelectionAlgorithm; import org.ovirt.engine.core.common.mode.ApplicationMode; +import org.ovirt.engine.core.common.scheduling.ClusterPolicy; import org.ovirt.engine.core.compat.Version; import org.ovirt.engine.ui.common.idhandler.ElementIdHandler; import org.ovirt.engine.ui.common.idhandler.WithElementId; @@ -20,6 +21,7 @@ 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.form.key_value.KeyValueWidget; 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; @@ -233,6 +235,10 @@ @WithElementId DialogTab clusterPolicyTab; + @UiField + @WithElementId + DialogTab newClusterPolicyTab; + @UiField(provided = true) Slider leftSlider; @@ -282,6 +288,15 @@ @UiField @Ignore Label minTimeLabel; + + @UiField(provided = true) + @Path(value = "clusterPolicy.selectedItem") + @WithElementId + ListModelListBoxEditor<Object> clusterPolicyEditor; + + @UiField + @Ignore + protected KeyValueWidget customPropertiesSheetEditor; private final Driver driver = GWT.create(Driver.class); @@ -360,6 +375,7 @@ migrateOnErrorOption_NOEditor.setLabel(constants.clusterPopupMigrateOnError_NoLabel()); clusterPolicyTab.setLabel(constants.clusterPopupClusterPolicyTabLabel()); + newClusterPolicyTab.setLabel(constants.clusterPopupClusterPolicyTabLabel()); policyRadioButton_none.setText(constants.clusterPolicyNoneLabel()); policyRadioButton_evenDist.setText(constants.clusterPolicyEvenDistLabel()); @@ -368,6 +384,7 @@ minServiceLevelLabel.setText(constants.clusterPolicyMinServiceLevelLabel()); forTimeLabel.setText(constants.clusterPolicyForTimeLabel()); minTimeLabel.setText(constants.clusterPolicyMinTimeLabel()); + clusterPolicyEditor.setLabel(constants.clusterPolicySelectPolicyLabel()); } private void initRadioButtonEditors() { @@ -406,6 +423,13 @@ } }); + clusterPolicyEditor = new ListModelListBoxEditor<Object>(new NullSafeRenderer<Object>() { + @Override + public String renderNullSafe(Object object) { + return ((ClusterPolicy) object).getName(); + } + }); + } private void initCheckBoxEditors() @@ -428,6 +452,7 @@ optimizationTab.setVisible(false); resiliencePolicyTab.setVisible(false); clusterPolicyTab.setVisible(false); + newClusterPolicyTab.setVisible(false); dataCenterPanel.addStyleName(style.generalTabTopDecoratorEmpty()); } } @@ -517,6 +542,14 @@ setSelectionAlgorithm(); } }); + + object.getCustomPropertySheet().getKeyValueLines().getItemsChangedEvent().addListener(new IEventListener() { + + @Override + public void eventRaised(Event ev, Object sender, EventArgs args) { + customPropertiesSheetEditor.edit(object.getCustomPropertySheet()); + } + }); } private void optimizationForServerFormatter(ClusterModel object) { 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 9e50cab..3c2d08f 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 @@ -3,10 +3,11 @@ <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:f="urn:import:org.ovirt.engine.ui.common.widget.form"> + xmlns:f="urn:import:org.ovirt.engine.ui.common.widget.form" + xmlns:k="urn:import:org.ovirt.engine.ui.common.widget.form.key_value"> <ui:with field='resources' type='org.ovirt.engine.ui.webadmin.ApplicationResources' /> - + <ui:with field='constants' type='org.ovirt.engine.ui.webadmin.ApplicationConstants' /> <ui:style type="org.ovirt.engine.ui.webadmin.section.main.view.popup.cluster.ClusterPopupView.WidgetStyle"> .generalTabTopDecorator { background-color: #D3D3D3; @@ -127,9 +128,14 @@ height: 20px; width: 8px; } + .labelStyle { + font-weight: bold; + margin-top: 10px; + margin-bottom: 5px; + } </ui:style> - <d:SimpleDialogPanel width="610px" height="560px"> + <d:SimpleDialogPanel width="620px" height="560px"> <d:content> <t:DialogTabPanel ui:field="tabsPanel" height="100%"> <t:tab> @@ -234,6 +240,19 @@ </t:content> </t:DialogTab> </t:tab> + <t:tab> + <t:DialogTab ui:field="newClusterPolicyTab"> + <t:content> + <g:FlowPanel> + <e:ListModelListBoxEditor ui:field="clusterPolicyEditor" /> + <g:Label addStyleNames="{style.labelStyle}" text="{constants.clusterPolicyPropertiesLabel}" /> + <g:FlowPanel> + <k:KeyValueWidget ui:field="customPropertiesSheetEditor" /> + </g:FlowPanel> + </g:FlowPanel> + </t:content> + </t:DialogTab> + </t:tab> </t:DialogTabPanel> </d:content> </d:SimpleDialogPanel> -- To view, visit http://gerrit.ovirt.org/16376 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id27916bf545eacbcb7ae7658bd89ddc1c6251dfa Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Gilad Chaplik <gchap...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches