Ramesh N has uploaded a new change for review. Change subject: webadmin: add additional features support in cluster popup. ......................................................................
webadmin: add additional features support in cluster popup. Add support for addtional features in the cluster pop up. User can enable/disable some extra feature during cluster creation. Addtional features will be shown based on the cluster compatability version shown and services (gluster, virt) enabled. Change-Id: Ic13dda67f3e9a7d7134030c3923470291c3c5aec Signed-off-by: Ramesh Nachimuthu <[email protected]> --- M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java 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 6 files changed, 192 insertions(+), 4 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/27/41027/1 diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java index c92658b..1ff4106 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java @@ -26,6 +26,7 @@ import org.ovirt.engine.core.common.action.VmManagementParametersBase; import org.ovirt.engine.core.common.action.gluster.GlusterVolumeRemoveBricksQueriesParameters; import org.ovirt.engine.core.common.businessentities.ActionGroup; +import org.ovirt.engine.core.common.businessentities.AdditionalFeature; import org.ovirt.engine.core.common.businessentities.ArchitectureType; import org.ovirt.engine.core.common.businessentities.CertificateInfo; import org.ovirt.engine.core.common.businessentities.Disk; @@ -53,6 +54,7 @@ import org.ovirt.engine.core.common.businessentities.StoragePool; import org.ovirt.engine.core.common.businessentities.StorageServerConnections; import org.ovirt.engine.core.common.businessentities.StorageType; +import org.ovirt.engine.core.common.businessentities.SupportedAdditionalClusterFeature; import org.ovirt.engine.core.common.businessentities.Tags; import org.ovirt.engine.core.common.businessentities.TagsType; import org.ovirt.engine.core.common.businessentities.VDS; @@ -99,6 +101,7 @@ import org.ovirt.engine.core.common.queries.GetAllFromExportDomainQueryParameters; import org.ovirt.engine.core.common.queries.GetAllProvidersParameters; import org.ovirt.engine.core.common.queries.GetAllServerCpuListParameters; +import org.ovirt.engine.core.common.queries.GetClusterFeaturesByVersionAndCategoryParameters; import org.ovirt.engine.core.common.queries.GetConfigurationValueParameters; import org.ovirt.engine.core.common.queries.GetConnectionsByDataCenterAndStorageTypeParameters; import org.ovirt.engine.core.common.queries.GetDataCentersWithPermittedActionOnClustersParameters; @@ -4010,4 +4013,34 @@ Frontend.getInstance().runQuery(VdcQueryType.GetUnusedGlusterBricks, parameters, asyncQuery); } + public static void getClusterFeaturesByVersionAndCategory(AsyncQuery aQuery, + Version version, + ApplicationMode category) { + aQuery.converterCallback = new IAsyncConverter() { + @Override + public Object Convert(Object source, AsyncQuery _asyncQuery) + { + return source != null ? (Set<AdditionalFeature>) source + : new HashSet<AdditionalFeature>(); + } + }; + Frontend.getInstance().runQuery(VdcQueryType.GetClusterFeaturesByVersionAndCategory, + new GetClusterFeaturesByVersionAndCategoryParameters(version, category), + aQuery); + } + + public static void getClusterFeaturesByClusterId(AsyncQuery aQuery, Guid clusterId) { + aQuery.converterCallback = new IAsyncConverter() { + @Override + public Object Convert(Object source, AsyncQuery _asyncQuery) + { + return source != null ? (Set<SupportedAdditionalClusterFeature>) source + : new HashSet<SupportedAdditionalClusterFeature>(); + } + }; + Frontend.getInstance().runQuery(VdcQueryType.GetClusterFeaturesByClusterId, + new IdQueryParameters(clusterId), + aQuery); + } + } 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 fb7492d..43e641c 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 @@ -9,8 +9,10 @@ import org.ovirt.engine.core.common.action.VdcReturnValueBase; import org.ovirt.engine.core.common.action.VdsGroupOperationParameters; import org.ovirt.engine.core.common.action.VdsGroupParametersBase; +import org.ovirt.engine.core.common.businessentities.AdditionalFeature; import org.ovirt.engine.core.common.businessentities.ServerCpu; import org.ovirt.engine.core.common.businessentities.StoragePool; +import org.ovirt.engine.core.common.businessentities.SupportedAdditionalClusterFeature; import org.ovirt.engine.core.common.businessentities.VDS; import org.ovirt.engine.core.common.businessentities.VDSGroup; import org.ovirt.engine.core.common.businessentities.VDSStatus; @@ -61,7 +63,6 @@ @SuppressWarnings("unused") public class ClusterListModel extends ListWithDetailsAndReportsModel implements ISupportSystemTreeContext { - private UICommand privateNewCommand; @@ -731,6 +732,11 @@ cluster.setMigrateOnError(model.getMigrateOnErrorOption()); cluster.setVirtService(model.getEnableOvirtService().getEntity()); cluster.setGlusterService(model.getEnableGlusterService().getEntity()); + for (AdditionalFeature feature : model.getAdditionalClusterFeatures().getSelectedItem()) { + cluster.getAddtionalFeaturesSupported().add(new SupportedAdditionalClusterFeature(cluster.getId(), + true, + feature)); + } cluster.setTrustedService(model.getEnableTrustedService().getEntity()); cluster.setHaReservation(model.getEnableHaReservation().getEntity()); cluster.setOptionalReasonRequired(model.getEnableOptionalReason().getEntity()); 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 9c3d15d..6fa6e89 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 @@ -3,17 +3,21 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; +import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.Set; +import org.ovirt.engine.core.common.businessentities.AdditionalFeature; import org.ovirt.engine.core.common.businessentities.ArchitectureType; import org.ovirt.engine.core.common.businessentities.MigrateOnErrorOptions; import org.ovirt.engine.core.common.businessentities.SerialNumberPolicy; import org.ovirt.engine.core.common.businessentities.ServerCpu; import org.ovirt.engine.core.common.businessentities.StoragePool; +import org.ovirt.engine.core.common.businessentities.SupportedAdditionalClusterFeature; import org.ovirt.engine.core.common.businessentities.VDSGroup; import org.ovirt.engine.core.common.businessentities.VmRngDevice; import org.ovirt.engine.core.common.mode.ApplicationMode; @@ -308,6 +312,16 @@ public void setEnableGlusterService(EntityModel<Boolean> value) { this.privateEnableGlusterService = value; + } + + private ListModel<List<AdditionalFeature>> additionalClusterFeatures; + + public ListModel<List<AdditionalFeature>> getAdditionalClusterFeatures() { + return additionalClusterFeatures; + } + + public void setAdditionalClusterFeatures(ListModel<List<AdditionalFeature>> additionalClusterFeatures) { + this.additionalClusterFeatures = additionalClusterFeatures; } private EntityModel<Boolean> isImportGlusterConfiguration; @@ -862,7 +876,10 @@ setEnableOvirtService(new EntityModel<Boolean>()); setEnableGlusterService(new EntityModel<Boolean>()); - + setAdditionalClusterFeatures(new ListModel<List<AdditionalFeature>>()); + List<List<AdditionalFeature>> additionalFeatures = new ArrayList<List<AdditionalFeature>>(); + additionalFeatures.add(Collections.<AdditionalFeature> emptyList()); + getAdditionalClusterFeatures().setItems(additionalFeatures, null); setSpiceProxyEnabled(new EntityModel<Boolean>()); getSpiceProxyEnabled().setEntity(false); getSpiceProxyEnabled().getEntityChangedEvent().addListener(this); @@ -893,6 +910,7 @@ getEnableOvirtService().getEntityChangedEvent().addListener(new IEventListener() { @Override public void eventRaised(Event ev, Object sender, EventArgs args) { + refreshAdditionalClusterFeaturesList(); if (!getAllowClusterWithVirtGlusterEnabled() && getEnableOvirtService().getEntity()) { getEnableGlusterService().setEntity(Boolean.FALSE); } @@ -937,6 +955,7 @@ @Override public void eventRaised(Event ev, Object sender, EventArgs args) { + refreshAdditionalClusterFeaturesList(); if (!getAllowClusterWithVirtGlusterEnabled() && getEnableGlusterService().getEntity()) { getEnableOvirtService().setEntity(Boolean.FALSE); } @@ -946,7 +965,6 @@ && getEnableGlusterService().getEntity()) { getIsImportGlusterConfiguration().setIsAvailable(true); - getGlusterHostAddress().setIsAvailable(true); getGlusterHostFingerprint().setIsAvailable(true); getGlusterHostPassword().setIsAvailable(true); @@ -1509,6 +1527,77 @@ } updateMigrateOnError(); + refreshAdditionalClusterFeaturesList(); + } + + private void refreshAdditionalClusterFeaturesList() { + if (getVersion() == null || getVersion().getSelectedItem() == null) { + return; + } + Version version = getVersion().getSelectedItem(); + + ApplicationMode category = null; + if (getEnableGlusterService().getEntity() && getEnableOvirtService().getEntity()) { + category = ApplicationMode.AllModes; + } else if (getEnableGlusterService().getEntity()) { + category = ApplicationMode.GlusterOnly; + } else if (getEnableOvirtService().getEntity()) { + category = ApplicationMode.VirtOnly; + } + + AsyncQuery asyncQuery = new AsyncQuery(); + asyncQuery.setModel(this); + // Get all the addtional features avaivalble for the cluster + asyncQuery.asyncCallback = new INewAsyncCallback() { + @Override + public void onSuccess(Object model, Object result) { + ClusterModel.this.stopProgress(); + final Set<AdditionalFeature> features = (Set<AdditionalFeature>) result; + // Get the additional features which are already enabled for cluster. Applicable only in case of edit + // cluster + if (getIsEdit() && !features.isEmpty()) { + AsyncQuery asyncQuery = new AsyncQuery(); + asyncQuery.setModel(this); + asyncQuery.asyncCallback = new INewAsyncCallback() { + @Override + public void onSuccess(Object model, Object returnValue) { + ClusterModel.this.stopProgress(); + Set<SupportedAdditionalClusterFeature> clusterFeatures = + (Set<SupportedAdditionalClusterFeature>) returnValue; + Set<AdditionalFeature> featuresEnabled = new HashSet<>(); + for (SupportedAdditionalClusterFeature feature : clusterFeatures) { + if (feature.isEnabled()) { + featuresEnabled.add(feature.getFeature()); + } + } + updateAddtionClusterFeatureList(features, featuresEnabled); + } + }; + ClusterModel.this.startProgress(null); + AsyncDataProvider.getClusterFeaturesByClusterId(asyncQuery, getEntity().getId()); + } else { + updateAddtionClusterFeatureList(features, + Collections.<AdditionalFeature> emptySet()); + } + } + }; + this.startProgress(null); + AsyncDataProvider.getClusterFeaturesByVersionAndCategory(asyncQuery, version, category); + } + + private void updateAddtionClusterFeatureList(Set<AdditionalFeature> featuresAvailable, + Set<AdditionalFeature> featuresEnabled) { + List<AdditionalFeature> features = new ArrayList<>(); + List<AdditionalFeature> selectedFeatures = new ArrayList<>(); + for (AdditionalFeature feature : featuresAvailable) { + features.add(feature); + if (featuresEnabled.contains(feature)) { + selectedFeatures.add(feature); + } + } + List<List<AdditionalFeature>> clusterFeatureList = new ArrayList<>(); + clusterFeatureList.add(features); + getAdditionalClusterFeatures().setItems(clusterFeatureList, selectedFeatures); } private void updateMigrateOnError() { 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 1350020..10fb221 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 @@ -4163,4 +4163,8 @@ @DefaultStringValue("Volume snapshots are scheduled.") String glusterVolumeSnapshotsScheduledToolTip(); + + @DefaultStringValue("Additional features supported in the Cluster") + String addtionalClusterFeaturesTitle(); + } 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 5ba1a3b..0599730 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,5 +1,8 @@ package org.ovirt.engine.ui.webadmin.section.main.view.popup.cluster; +import java.util.List; + +import org.ovirt.engine.core.common.businessentities.AdditionalFeature; import org.ovirt.engine.core.common.businessentities.ArchitectureType; import org.ovirt.engine.core.common.businessentities.ServerCpu; import org.ovirt.engine.core.common.businessentities.StoragePool; @@ -12,10 +15,12 @@ import org.ovirt.engine.ui.common.widget.Align; import org.ovirt.engine.ui.common.widget.EntityModelWidgetWithInfo; import org.ovirt.engine.ui.common.widget.VisibilityRenderer; +import org.ovirt.engine.ui.common.widget.dialog.AdvancedParametersExpander; import org.ovirt.engine.ui.common.widget.dialog.InfoIcon; import org.ovirt.engine.ui.common.widget.dialog.SimpleDialogPanel; import org.ovirt.engine.ui.common.widget.dialog.tab.DialogTab; import org.ovirt.engine.ui.common.widget.dialog.tab.DialogTabPanel; +import org.ovirt.engine.ui.common.widget.editor.ListModelCheckBoxGroup; import org.ovirt.engine.ui.common.widget.editor.ListModelListBoxEditor; import org.ovirt.engine.ui.common.widget.editor.generic.EntityModelCheckBoxEditor; import org.ovirt.engine.ui.common.widget.editor.generic.EntityModelCheckBoxOnlyEditor; @@ -45,6 +50,7 @@ import com.google.gwt.event.shared.EventBus; import com.google.gwt.resources.client.CssResource; import com.google.gwt.safehtml.shared.SafeHtmlUtils; +import com.google.gwt.text.shared.AbstractRenderer; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.user.client.ui.FlowPanel; @@ -193,6 +199,19 @@ @Path(value = "glusterTunedProfile.selectedItem") @WithElementId ListModelListBoxEditor<String> glusterTunedProfileEditor; + + @UiField(provided = true) + @Path(value = "additionalClusterFeatures.selectedItem") + @WithElementId + ListModelCheckBoxGroup<AdditionalFeature> additionalFeaturesEditor; + + @UiField + @Ignore + AdvancedParametersExpander additionalFeaturesExpander; + + @UiField + @Ignore + FlowPanel additionalFeaturesExpanderContent; @UiField @WithElementId @@ -409,12 +428,15 @@ initWidget(ViewUiBinder.uiBinder.createAndBindUi(this)); ViewIdHandler.idHandler.generateAndSetIds(this); + initAdditionalFeaturesExpander(); addStyles(); localize(constants); driver.initialize(this); applyModeCustomizations(); setVisibilities(); + + additionalFeaturesEditor.clearAllSelections(); } private void setVisibilities() { @@ -431,6 +453,7 @@ enableTrustedServiceEditor.setContentWidgetStyleName(style.fullWidth()); enableHaReservationEditor.setContentWidgetStyleName(style.fullWidth()); enableOptionalReasonEditor.setContentWidgetStyleName(style.fullWidth()); + additionalFeaturesExpanderContent.setStyleName(style.additionalFeaturesExpanderContent()); } private void localize(ApplicationConstants constants) { @@ -448,12 +471,13 @@ enableOvirtServiceOptionEditor.setLabel(constants.clusterEnableOvirtServiceLabel()); enableGlusterServiceOptionEditor.setLabel(constants.clusterEnableGlusterServiceLabel()); glusterTunedProfileEditor.setLabel(constants.glusterTunedProfileLabel()); - importGlusterConfigurationEditor.setLabel(constants.clusterImportGlusterConfigurationLabel()); importGlusterExplanationLabel.setText(constants.clusterImportGlusterConfigurationExplanationLabel()); glusterHostAddressEditor.setLabel(constants.hostPopupHostAddressLabel()); glusterHostFingerprintEditor.setLabel(constants.hostPopupHostFingerprintLabel()); glusterHostPasswordEditor.setLabel(constants.hostPopupPasswordLabel()); + additionalFeaturesExpander.setTitleWhenCollapsed(constants.addtionalClusterFeaturesTitle()); + additionalFeaturesExpander.setTitleWhenExpended(constants.addtionalClusterFeaturesTitle()); rngLabel.setText(constants.requiredRngSources()); rngRandomSourceRequired.setLabel(constants.rngSourceRandom()); @@ -596,6 +620,13 @@ skipFencingIfConnectivityBrokenCheckBox = new EntityModelCheckBoxEditor(Align.RIGHT); skipFencingIfConnectivityBrokenCheckBox.getContentWidgetContainer().setWidth("420px"); //$NON-NLS-1$ + + additionalFeaturesEditor = new ListModelCheckBoxGroup<>(new AbstractRenderer<AdditionalFeature>() { + @Override + public String render(AdditionalFeature feature) { + return feature.getDescription(); + } + }); } private void initInfoIcons(ApplicationResources resources, ApplicationConstants constants, ApplicationTemplates templates) { @@ -735,6 +766,17 @@ } } }); + + object.getAdditionalClusterFeatures().getItemsChangedEvent().addListener(new IEventListener() { + + @Override + public void eventRaised(Event ev, Object sender, EventArgs args) { + List<List<AdditionalFeature>> items = (List<List<AdditionalFeature>>) object.getAdditionalClusterFeatures().getItems(); + // Hide the fields if there is no feature to show + additionalFeaturesExpander.setVisible(!items.get(0).isEmpty()); + additionalFeaturesExpanderContent.setVisible(!items.get(0).isEmpty()); + } + }); } private void optimizationForServerFormatter(ClusterModel object) { @@ -792,6 +834,11 @@ String timeTextBoxEditorWidget(); String optimizationTabPanel(); + + String additionalFeaturesExpanderContent(); } + private void initAdditionalFeaturesExpander() { + additionalFeaturesExpander.initWithContent(additionalFeaturesExpanderContent.getElement()); + } } 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 73c96fb..535e382 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 @@ -152,6 +152,11 @@ display: inline; } + .additionalFeaturesExpanderContent { + margin-left: 15px; + display: none; + } + </ui:style> <d:SimpleDialogPanel width="800px" height="560px"> @@ -191,6 +196,10 @@ <ge:EntityModelCheckBoxEditor ui:field="rngHwrngSourceRequired" /> </g:FlowPanel> <e:ListModelListBoxEditor ui:field="glusterTunedProfileEditor" /> + <d:AdvancedParametersExpander ui:field="additionalFeaturesExpander"/> + <g:FlowPanel ui:field="additionalFeaturesExpanderContent"> + <e:ListModelCheckBoxGroup ui:field="additionalFeaturesEditor" /> + </g:FlowPanel> </g:FlowPanel> </t:content> </t:DialogTab> -- To view, visit https://gerrit.ovirt.org/41027 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic13dda67f3e9a7d7134030c3923470291c3c5aec Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: ovirt-engine-3.5-gluster Gerrit-Owner: Ramesh N <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
