Kanagaraj M has uploaded a new change for review. Change subject: webadmin:[WIP] Adding Gluster start Geo-Replication feature ......................................................................
webadmin:[WIP] Adding Gluster start Geo-Replication feature Change-Id: Ia72ee637c519234221616ca93f002e28ff05ba81 Signed-off-by: Kanagaraj M <kmayi...@redhat.com> --- 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/gluster/georep/GeoReplicationListModel.java A frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/georep/GeoReplicationModel.java M frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/Constants.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/gin/PresenterModule.java M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/uicommon/GeoReplicationModule.java A frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/presenter/popup/gluster/GeoReplicationPopupPresenterWidget.java A frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/GeoReplicationPopupView.java A frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/GeoReplicationPopupView.ui.xml M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/MainTabGeoReplicationView.java 11 files changed, 658 insertions(+), 4 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/29/9529/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 9012d08..03b3a19 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 @@ -95,6 +95,7 @@ import org.ovirt.engine.core.common.queries.gluster.GlusterParameters; import org.ovirt.engine.core.common.queries.gluster.GlusterServersQueryParameters; import org.ovirt.engine.core.common.queries.gluster.GlusterVolumeAdvancedDetailsParameters; +import org.ovirt.engine.core.common.queries.gluster.PasswordlessSshQueryParameters; import org.ovirt.engine.core.compat.Guid; import org.ovirt.engine.core.compat.KeyValuePairCompat; import org.ovirt.engine.core.compat.NGuid; @@ -1117,6 +1118,24 @@ aQuery); } + public static void GetPasswordlessSshStatus(AsyncQuery aQuery, + Guid originHostId, + String remoteHost, + String remoteHostFingerprint, + String remoteHostUser) { + aQuery.converterCallback = new IAsyncConverter() { + @Override + public Object Convert(Object source, AsyncQuery _asyncQuery) + { + return source != null ? source : Boolean.FALSE; + } + }; + Frontend.RunQuery(VdcQueryType.GetPasswordlessSshStatus, new PasswordlessSshQueryParameters(originHostId, + remoteHost, + remoteHostFingerprint, + remoteHostUser), aQuery); + } + public static void GetRpmVersionViaPublic(AsyncQuery aQuery) { aQuery.converterCallback = new IAsyncConverter() { @Override diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/georep/GeoReplicationListModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/georep/GeoReplicationListModel.java index 363a12f..0df5ed5 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/georep/GeoReplicationListModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/georep/GeoReplicationListModel.java @@ -1,10 +1,26 @@ package org.ovirt.engine.ui.uicommonweb.models.gluster.georep; +import java.util.List; + +import org.ovirt.engine.core.common.businessentities.VDS; +import org.ovirt.engine.core.common.businessentities.VDSGroup; +import org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity; import org.ovirt.engine.core.common.mode.ApplicationMode; +import org.ovirt.engine.ui.frontend.AsyncQuery; +import org.ovirt.engine.ui.frontend.INewAsyncCallback; +import org.ovirt.engine.ui.uicommonweb.UICommand; +import org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider; +import org.ovirt.engine.ui.uicommonweb.models.ISupportSystemTreeContext; import org.ovirt.engine.ui.uicommonweb.models.ListWithDetailsModel; +import org.ovirt.engine.ui.uicommonweb.models.SystemTreeItemModel; +import org.ovirt.engine.ui.uicommonweb.models.SystemTreeItemType; import org.ovirt.engine.ui.uicompat.ConstantsManager; -public class GeoReplicationListModel extends ListWithDetailsModel { +public class GeoReplicationListModel extends ListWithDetailsModel implements ISupportSystemTreeContext { + + private SystemTreeItemModel systemTreeSelectedItem; + + private UICommand startGeoReplicationCommand; public GeoReplicationListModel() { setTitle(ConstantsManager.getInstance().getConstants().geoReplicationTitle()); @@ -13,13 +29,97 @@ setSearchString(getDefaultSearchString()); setAvailableInModes(ApplicationMode.GlusterOnly); + setStartGeoReplicationCommand(new UICommand("StartGeoRep", this)); //$NON-NLS-1$ + getSearchNextPageCommand().setIsAvailable(true); getSearchPreviousPageCommand().setIsAvailable(true); + } + + public UICommand getStartGeoReplicationCommand() + { + return startGeoReplicationCommand; + } + + public void setStartGeoReplicationCommand(UICommand value) + { + startGeoReplicationCommand = value; + } + + @Override + public SystemTreeItemModel getSystemTreeSelectedItem() { + return systemTreeSelectedItem; + } + + @Override + public void setSystemTreeSelectedItem(SystemTreeItemModel value) { + this.systemTreeSelectedItem = value; + } + + public void startGeoReplication() { + if (getWindow() != null) { + return; + } + + if(getSystemTreeSelectedItem().getType() != SystemTreeItemType.Cluster_Gluster) { + return; + } + + final VDSGroup cluster = (VDSGroup) getSystemTreeSelectedItem().getEntity(); + + final GeoReplicationModel geoRepModel = new GeoReplicationModel(); + geoRepModel.setTitle(ConstantsManager.getInstance().getConstants().startGeoReplicationTitle()); + setWindow(geoRepModel); + geoRepModel.StartProgress(null); + + AsyncDataProvider.GetVolumeList(new AsyncQuery(this, new INewAsyncCallback() { + @Override + public void OnSuccess(Object model, Object returnValue) { + geoRepModel.getVolumeList().setItems((List<GlusterVolumeEntity>) returnValue); + AsyncDataProvider.GetHostListByCluster(new AsyncQuery(this, new INewAsyncCallback() { + @Override + public void OnSuccess(Object model, Object returnValue) { + geoRepModel.getOriginHostList().setItems((List<VDS>) returnValue); + geoRepModel.StopProgress(); + } + }), cluster.getname()); + } + }), cluster.getname()); + + UICommand command = new UICommand("onStartGeoRep", this); //$NON-NLS-1$ + command.setTitle(ConstantsManager.getInstance().getConstants().ok()); + command.setIsDefault(true); + geoRepModel.getCommands().add(command); + + command = new UICommand("Cancel", this); //$NON-NLS-1$ + command.setTitle(ConstantsManager.getInstance().getConstants().cancel()); + command.setIsCancel(true); + geoRepModel.getCommands().add(command); + } + + public void onStartGeoReplication() { + + } + + public void cancel() { + setWindow(null); + } + + @Override + public void ExecuteCommand(UICommand command) { + super.ExecuteCommand(command); + if (command.equals(getStartGeoReplicationCommand())) { + startGeoReplication(); + } + else if (command.getName().equals("Cancel")) { //$NON-NLS-1$ + cancel(); + } + else if (command.getName().equals("onStartGeoRep")) { //$NON-NLS-1$ + onStartGeoReplication(); + } } @Override protected String getListName() { return "GeoReplicationListModel"; //$NON-NLS-1$ } - } diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/georep/GeoReplicationModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/georep/GeoReplicationModel.java new file mode 100644 index 0000000..6124f71 --- /dev/null +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/georep/GeoReplicationModel.java @@ -0,0 +1,215 @@ +package org.ovirt.engine.ui.uicommonweb.models.gluster.georep; + +import org.ovirt.engine.core.common.businessentities.VDS; +import org.ovirt.engine.core.compat.Event; +import org.ovirt.engine.core.compat.EventArgs; +import org.ovirt.engine.core.compat.Guid; +import org.ovirt.engine.core.compat.IEventListener; +import org.ovirt.engine.ui.frontend.AsyncQuery; +import org.ovirt.engine.ui.frontend.INewAsyncCallback; +import org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider; +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.IValidation; +import org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation; +import org.ovirt.engine.ui.uicompat.ConstantsManager; + +public class GeoReplicationModel extends Model { + private ListModel volumeList; + private ListModel originHostList; + private EntityModel remoteHost; + private EntityModel sshFingerprint; + private EntityModel remoteHostUser; + private EntityModel remotePath; + + private EntityModel useDefaultConfig; + private EntityModel configSshCommand; + private EntityModel configGSyncCommand; + + public GeoReplicationModel() { + setVolumeList(new ListModel()); + setOriginHostList(new ListModel()); + setRemoteHost(new EntityModel()); + setSshFingerprint(new EntityModel()); + setRemoteHostUser(new EntityModel()); + setRemotePath(new EntityModel()); + setUseDefaultConfig(new EntityModel()); + setConfigSshCommand(new EntityModel()); + setConfigGSyncCommand(new EntityModel()); + + initEventHandlers(); + getUseDefaultConfig().setEntity(Boolean.TRUE); + } + + public ListModel getVolumeList() { + return volumeList; + } + + public void setVolumeList(ListModel volumeList) { + this.volumeList = volumeList; + } + + public EntityModel getRemoteHost() { + return remoteHost; + } + + public void setRemoteHost(EntityModel remoteHost) { + this.remoteHost = remoteHost; + } + + public EntityModel getSshFingerprint() { + return sshFingerprint; + } + + public void setSshFingerprint(EntityModel sshFingerprint) { + this.sshFingerprint = sshFingerprint; + } + + public EntityModel getRemoteHostUser() { + return remoteHostUser; + } + + public void setRemoteHostUser(EntityModel remoteHostUser) { + this.remoteHostUser = remoteHostUser; + } + + public EntityModel getRemotePath() { + return remotePath; + } + + public void setRemotePath(EntityModel remotePath) { + this.remotePath = remotePath; + } + + public EntityModel getUseDefaultConfig() { + return useDefaultConfig; + } + + public void setUseDefaultConfig(EntityModel useDefaultConfig) { + this.useDefaultConfig = useDefaultConfig; + } + + public EntityModel getConfigSshCommand() { + return configSshCommand; + } + + public void setConfigSshCommand(EntityModel configSshCommand) { + this.configSshCommand = configSshCommand; + } + + public EntityModel getConfigGSyncCommand() { + return configGSyncCommand; + } + + public void setConfigGSyncCommand(EntityModel configGSyncCommand) { + this.configGSyncCommand = configGSyncCommand; + } + + public ListModel getOriginHostList() { + return originHostList; + } + + public void setOriginHostList(ListModel originHostList) { + this.originHostList = originHostList; + } + + public void initEventHandlers() { + getOriginHostList().getSelectedItemChangedEvent().addListener(new IEventListener() { + @Override + public void eventRaised(Event ev, Object sender, EventArgs args) { + updateSshFingerprint(); + verifyPasswordlessSSH(); + } + }); + + getRemoteHost().getEntityChangedEvent().addListener(new IEventListener() { + @Override + public void eventRaised(Event ev, Object sender, EventArgs args) { + updateSshFingerprint(); + verifyPasswordlessSSH(); + } + }); + + getRemoteHostUser().getEntityChangedEvent().addListener(new IEventListener() { + @Override + public void eventRaised(Event ev, Object sender, EventArgs args) { + verifyPasswordlessSSH(); + } + }); + + getUseDefaultConfig().getEntityChangedEvent().addListener(new IEventListener() { + @Override + public void eventRaised(Event ev, Object sender, EventArgs args) { + boolean value = (Boolean) getUseDefaultConfig().getEntity(); + getConfigSshCommand().setIsChangable(!value); + getConfigGSyncCommand().setIsChangable(!value); + } + }); + } + + public void updateSshFingerprint() { + if (getRemoteHost().getEntity() == null) { + return; + } + + String hostAddress = (String) getRemoteHost().getEntity(); + if (hostAddress.trim().length() == 0) { + return; + } + + AsyncDataProvider.GetHostFingerprint(new AsyncQuery(this, new INewAsyncCallback() { + + @Override + public void OnSuccess(Object model, Object returnValue) { + String fingerprint = (String) returnValue; + if (fingerprint != null && fingerprint.length() > 0) { + getSshFingerprint().setEntity(fingerprint); + } + else { + getSshFingerprint().setEntity(ConstantsManager.getInstance() + .getConstants() + .errorLoadingFingerprint()); + } + } + }), hostAddress); + getSshFingerprint().setEntity(ConstantsManager.getInstance().getConstants().loadingFingerprint()); + } + + public void verifyPasswordlessSSH() { + if (getOriginHostList().getSelectedItem() == null || getRemoteHost().getEntity() == null + || getRemoteHostUser().getEntity() == null) { + return; + } + + Guid originHostId = ((VDS) getOriginHostList().getSelectedItem()).getId(); + String remoteHostAddress = (String) getRemoteHost().getEntity(); + AsyncDataProvider.GetPasswordlessSshStatus(new AsyncQuery(this, new INewAsyncCallback() { + @Override + public void OnSuccess(Object model, Object returnValue) { + if ((Boolean) returnValue) { + setMessage(ConstantsManager.getInstance().getConstants().passwordlessSshVerificationSuccessful()); + } + else { + setMessage(ConstantsManager.getInstance().getConstants().passwordlessSshVerificationFailed()); + } + } + }), + originHostId, + remoteHostAddress, + (String) getSshFingerprint().getEntity(), + (String) getRemoteHostUser().getEntity()); + setMessage(ConstantsManager.getInstance().getConstants().verifyingPasswordlessSsh()); + } + + public boolean validate() { + getVolumeList().ValidateEntity(new IValidation[] { new NotEmptyValidation() }); + getRemoteHost().ValidateEntity(new IValidation[] { new NotEmptyValidation() }); + getRemotePath().ValidateEntity(new IValidation[] { new NotEmptyValidation() }); + getRemoteHostUser().ValidateEntity(new IValidation[] { new NotEmptyValidation() }); + getOriginHostList().ValidateEntity(new IValidation[] { new NotEmptyValidation() }); + + return getVolumeList().getIsValid() && getRemoteHost().getIsValid() && getRemotePath().getIsValid() + && getRemoteHostUser().getIsValid() && getOriginHostList().getIsValid(); + } +} diff --git a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/Constants.java b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/Constants.java index 35c61af..5ffa436 100644 --- a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/Constants.java +++ b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/Constants.java @@ -186,6 +186,9 @@ @DefaultStringValue("Create Volume") String createVolumeTitle(); + @DefaultStringValue("Start Geo-Replication") + String startGeoReplicationTitle(); + @DefaultStringValue("Parameters") String parameterTitle(); @@ -1587,4 +1590,14 @@ @DefaultStringValue("Management") String mgmgtNetworkRole(); + + // Geo-Replication + @DefaultStringValue("Verifying Passwordless SSH...") + String verifyingPasswordlessSsh(); + + @DefaultStringValue("Verified Passwordless SSH Successfully") + String passwordlessSshVerificationSuccessful(); + + @DefaultStringValue("Passwordless SSH communication failed") + String passwordlessSshVerificationFailed(); } 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 cffefa0..5edfe86 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 @@ -2126,6 +2126,37 @@ @DefaultStringValue("Optimize for Virt Store") String optimizeForVirtStore(); + // Geo Replication + @DefaultStringValue("New") + String newGeoReplication(); + + @DefaultStringValue("Volume") + String volumeGeoReplication(); + + @DefaultStringValue("Remote Host") + String remoteHostGeoReplication(); + + @DefaultStringValue("SSH Fingerprint") + String sshFingerprintGeoReplication(); + + @DefaultStringValue("Remote Host's User") + String remoteHostUserGeoReplication(); + + @DefaultStringValue("Remote Volume/Path") + String remotePathGeoReplication(); + + @DefaultStringValue("Use Default") + String useDefaultConfigGeoReplication(); + + @DefaultStringValue("SSH Command") + String sshCommandGeoReplication(); + + @DefaultStringValue("Gsync Command") + String gsyncCommandGeoReplication(); + + @DefaultStringValue("Start Geo-Replication from Host") + String startHostGeoReplication(); + // Inteface editor @DefaultStringValue("Address:") String addressInterfaceEditor(); diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/PresenterModule.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/PresenterModule.java index ce7c984..489b99f 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/PresenterModule.java +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/PresenterModule.java @@ -33,6 +33,7 @@ import org.ovirt.engine.ui.webadmin.section.main.presenter.popup.datacenter.RecoveryStoragePopupPresenterWidget; import org.ovirt.engine.ui.webadmin.section.main.presenter.popup.gluster.AddBrickPopupPresenterWidget; import org.ovirt.engine.ui.webadmin.section.main.presenter.popup.gluster.BrickAdvancedDetailsPopupPresenterWidget; +import org.ovirt.engine.ui.webadmin.section.main.presenter.popup.gluster.GeoReplicationPopupPresenterWidget; import org.ovirt.engine.ui.webadmin.section.main.presenter.popup.gluster.ReplaceBrickPopupPresenterWidget; import org.ovirt.engine.ui.webadmin.section.main.presenter.popup.gluster.VolumeParameterPopupPresenterWidget; import org.ovirt.engine.ui.webadmin.section.main.presenter.popup.gluster.VolumePopupPresenterWidget; @@ -211,6 +212,7 @@ import org.ovirt.engine.ui.webadmin.section.main.view.popup.datacenter.RecoveryStorageConfirmationPopupView; import org.ovirt.engine.ui.webadmin.section.main.view.popup.gluster.AddBrickPopupView; import org.ovirt.engine.ui.webadmin.section.main.view.popup.gluster.BrickAdvancedDetailsPopupView; +import org.ovirt.engine.ui.webadmin.section.main.view.popup.gluster.GeoReplicationPopupView; import org.ovirt.engine.ui.webadmin.section.main.view.popup.gluster.ReplaceBrickPopupView; import org.ovirt.engine.ui.webadmin.section.main.view.popup.gluster.VolumeParameterPopupView; import org.ovirt.engine.ui.webadmin.section.main.view.popup.gluster.VolumePopupView; @@ -1115,6 +1117,11 @@ VolumeParameterPopupPresenterWidget.ViewDef.class, VolumeParameterPopupView.class); + // Geo Replication + bindPresenterWidget(GeoReplicationPopupPresenterWidget.class, + GeoReplicationPopupPresenterWidget.ViewDef.class, + GeoReplicationPopupView.class); + // Network bindPresenterWidget(NewNetworkPopupPresenterWidget.class, NewNetworkPopupPresenterWidget.ViewDef.class, diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/uicommon/GeoReplicationModule.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/uicommon/GeoReplicationModule.java index 369fe9f..401eaf7 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/uicommon/GeoReplicationModule.java +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/uicommon/GeoReplicationModule.java @@ -9,8 +9,10 @@ import org.ovirt.engine.ui.uicommonweb.models.Model; import org.ovirt.engine.ui.uicommonweb.models.gluster.georep.GeoReplicationListModel; import org.ovirt.engine.ui.webadmin.gin.ClientGinjector; +import org.ovirt.engine.ui.webadmin.section.main.presenter.popup.gluster.GeoReplicationPopupPresenterWidget; import com.google.gwt.inject.client.AbstractGinModule; +import com.google.inject.Provider; import com.google.inject.Provides; import com.google.inject.Singleton; @@ -20,13 +22,18 @@ @Provides @Singleton - public MainModelProvider<GlusterVolumeEntity, GeoReplicationListModel> getGeoReplicationListProvider(ClientGinjector ginjector) { + public MainModelProvider<GlusterVolumeEntity, GeoReplicationListModel> getGeoReplicationListProvider(ClientGinjector ginjector, + final Provider<GeoReplicationPopupPresenterWidget> popupProvider) { return new MainTabModelProvider<GlusterVolumeEntity, GeoReplicationListModel>(ginjector, GeoReplicationListModel.class) { @Override public AbstractModelBoundPopupPresenterWidget<? extends Model, ?> getModelPopup(GeoReplicationListModel source, UICommand lastExecutedCommand, Model windowModel) { - return super.getModelPopup(source, lastExecutedCommand, windowModel); + if (lastExecutedCommand == getModel().getStartGeoReplicationCommand()) { + return popupProvider.get(); + } else { + return super.getModelPopup(source, lastExecutedCommand, windowModel); + } } @Override diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/presenter/popup/gluster/GeoReplicationPopupPresenterWidget.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/presenter/popup/gluster/GeoReplicationPopupPresenterWidget.java new file mode 100644 index 0000000..5011248 --- /dev/null +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/presenter/popup/gluster/GeoReplicationPopupPresenterWidget.java @@ -0,0 +1,17 @@ +package org.ovirt.engine.ui.webadmin.section.main.presenter.popup.gluster; + +import org.ovirt.engine.ui.common.presenter.AbstractModelBoundPopupPresenterWidget; +import org.ovirt.engine.ui.uicommonweb.models.gluster.georep.GeoReplicationModel; + +import com.google.gwt.event.shared.EventBus; +import com.google.inject.Inject; + +public class GeoReplicationPopupPresenterWidget extends AbstractModelBoundPopupPresenterWidget<GeoReplicationModel, GeoReplicationPopupPresenterWidget.ViewDef> { + public interface ViewDef extends AbstractModelBoundPopupPresenterWidget.ViewDef<GeoReplicationModel> { + } + + @Inject + public GeoReplicationPopupPresenterWidget(EventBus eventBus, ViewDef view) { + super(eventBus, view); + } +} diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/GeoReplicationPopupView.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/GeoReplicationPopupView.java new file mode 100644 index 0000000..79f03df --- /dev/null +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/GeoReplicationPopupView.java @@ -0,0 +1,180 @@ +package org.ovirt.engine.ui.webadmin.section.main.view.popup.gluster; + +import org.ovirt.engine.core.common.businessentities.VDS; +import org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity; +import org.ovirt.engine.ui.common.idhandler.ElementIdHandler; +import org.ovirt.engine.ui.common.idhandler.WithElementId; +import org.ovirt.engine.ui.common.view.popup.AbstractModelBoundPopupView; +import org.ovirt.engine.ui.common.widget.Align; +import org.ovirt.engine.ui.common.widget.dialog.AdvancedParametersExpander; +import org.ovirt.engine.ui.common.widget.dialog.SimpleDialogPanel; +import org.ovirt.engine.ui.common.widget.editor.EntityModelCheckBoxEditor; +import org.ovirt.engine.ui.common.widget.editor.EntityModelLabelEditor; +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.renderer.NullSafeRenderer; +import org.ovirt.engine.ui.uicommonweb.models.gluster.georep.GeoReplicationModel; +import org.ovirt.engine.ui.webadmin.ApplicationConstants; +import org.ovirt.engine.ui.webadmin.ApplicationResources; +import org.ovirt.engine.ui.webadmin.section.main.presenter.popup.gluster.GeoReplicationPopupPresenterWidget; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.editor.client.SimpleBeanEditorDriver; +import com.google.gwt.event.shared.EventBus; +import com.google.gwt.resources.client.CssResource; +import com.google.gwt.uibinder.client.UiBinder; +import com.google.gwt.uibinder.client.UiField; +import com.google.gwt.user.client.ui.Label; +import com.google.gwt.user.client.ui.VerticalPanel; +import com.google.inject.Inject; + +public class GeoReplicationPopupView extends AbstractModelBoundPopupView<GeoReplicationModel> implements GeoReplicationPopupPresenterWidget.ViewDef { + + interface Driver extends SimpleBeanEditorDriver<GeoReplicationModel, GeoReplicationPopupView> { + Driver driver = GWT.create(Driver.class); + } + + interface ViewUiBinder extends UiBinder<SimpleDialogPanel, GeoReplicationPopupView> { + ViewUiBinder uiBinder = GWT.create(ViewUiBinder.class); + } + + interface ViewIdHandler extends ElementIdHandler<GeoReplicationPopupView> { + ViewIdHandler idHandler = GWT.create(ViewIdHandler.class); + } + + @UiField + WidgetStyle style; + + @UiField(provided = true) + @Path(value = "volumeList.selectedItem") + @WithElementId + ListModelListBoxEditor<Object> volumeEditor; + + @UiField + @Path(value = "remoteHost.entity") + @WithElementId + EntityModelTextBoxEditor remoteHostEditor; + + @UiField + @Path(value = "sshFingerprint.entity") + @WithElementId + EntityModelLabelEditor sshFingerprintEditor; + + @UiField + @Path(value = "remoteHostUser.entity") + @WithElementId + EntityModelTextBoxEditor remoteHostUserEditor; + + @UiField + @Path(value = "remotePath.entity") + @WithElementId + EntityModelTextBoxEditor remotePathEditor; + + @UiField + @Ignore + AdvancedParametersExpander configExpander; + + @UiField + @Ignore + VerticalPanel configPanel; + + @UiField(provided = true) + @Path(value = "useDefaultConfig.entity") + @WithElementId + EntityModelCheckBoxEditor useDefaultConfigEditor; + + @UiField + @Path(value = "configSshCommand.entity") + @WithElementId + EntityModelTextBoxEditor sshCommandEditor; + + @UiField + @Path(value = "configGSyncCommand.entity") + @WithElementId + EntityModelTextBoxEditor gsyncCommandEditor; + + @UiField(provided = true) + @Path(value = "originHostList.selectedItem") + @WithElementId + ListModelListBoxEditor<Object> originHostEditor; + + @UiField + @Ignore + Label messageLabel; + + @Inject + public GeoReplicationPopupView(EventBus eventBus, ApplicationResources resources, ApplicationConstants constants) { + super(eventBus, resources); + initEditors(); + initWidget(ViewUiBinder.uiBinder.createAndBindUi(this)); + initExpander(); + ViewIdHandler.idHandler.generateAndSetIds(this); + addStyles(); + localize(constants); + Driver.driver.initialize(this); + } + + private void initEditors() { + volumeEditor = new ListModelListBoxEditor<Object>(new NullSafeRenderer<Object>() { + @Override + public String renderNullSafe(Object object) { + return ((GlusterVolumeEntity) object).getName(); + } + }); + originHostEditor = new ListModelListBoxEditor<Object>(new NullSafeRenderer<Object>() { + @Override + public String renderNullSafe(Object object) { + return ((VDS) object).getvds_name(); + } + }); + useDefaultConfigEditor = new EntityModelCheckBoxEditor(Align.RIGHT); + } + + private void initExpander() { + configExpander.initWithContent(configPanel.getElement()); + } + + private void addStyles() { + sshFingerprintEditor.setContentWidgetStyleName(style.bigEditorContentWidget()); + sshCommandEditor.setContentWidgetStyleName(style.bigEditorContentWidget()); + gsyncCommandEditor.setContentWidgetStyleName(style.bigEditorContentWidget()); + configPanel.getElement().setClassName(style.expanderContent()); + } + + private void localize(ApplicationConstants constants) { + volumeEditor.setLabel(constants.volumeGeoReplication()); + remoteHostEditor.setLabel(constants.remoteHostGeoReplication()); + sshFingerprintEditor.setLabel(constants.sshFingerprintGeoReplication()); + remoteHostUserEditor.setLabel(constants.remoteHostUserGeoReplication()); + remotePathEditor.setLabel(constants.remotePathGeoReplication()); + + useDefaultConfigEditor.setLabel(constants.useDefaultConfigGeoReplication()); + sshCommandEditor.setLabel(constants.sshCommandGeoReplication()); + gsyncCommandEditor.setLabel(constants.gsyncCommandGeoReplication()); + + originHostEditor.setLabel(constants.startHostGeoReplication()); + } + + @Override + public void edit(GeoReplicationModel object) { + Driver.driver.edit(object); + } + + @Override + public void setMessage(String message) { + super.setMessage(message); + messageLabel.setText(message); + } + + @Override + public GeoReplicationModel flush() { + return Driver.driver.flush(); + } + + interface WidgetStyle extends CssResource { + + String bigEditorContentWidget(); + + String expanderContent(); + } +} diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/GeoReplicationPopupView.ui.xml b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/GeoReplicationPopupView.ui.xml new file mode 100644 index 0000000..177305c --- /dev/null +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/GeoReplicationPopupView.ui.xml @@ -0,0 +1,53 @@ +<?xml version="1.0" encoding="UTF-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:w="urn:import:org.ovirt.engine.ui.common.widget"> + + <ui:style src='../../../../../defines.css' type="org.ovirt.engine.ui.webadmin.section.main.view.popup.gluster.GeoReplicationPopupView.WidgetStyle"> + .smallTextEditor { + padding-right: 150px; + } + + .bigEditorContentWidget { + float: right; + padding-right: 5px; + width: 380px; + } + + .expanderContent { + margin-left: 15px; + display: none; + } + + .messageLabel { + color: #FF0000; + left: 10px; + padding-left: 5px; + } + </ui:style> + + <d:SimpleDialogPanel width="650px" height="500px"> + <d:content> + <g:VerticalPanel> + <e:ListModelListBoxEditor addStyleNames="{style.smallTextEditor}" ui:field="volumeEditor" /> + <e:ListModelListBoxEditor addStyleNames="{style.smallTextEditor}" ui:field="originHostEditor" /> + <e:EntityModelTextBoxEditor addStyleNames="{style.smallTextEditor}" ui:field="remoteHostEditor" /> + <e:EntityModelLabelEditor ui:field="sshFingerprintEditor" /> + <e:EntityModelTextBoxEditor addStyleNames="{style.smallTextEditor}" ui:field="remoteHostUserEditor" /> + <e:EntityModelTextBoxEditor addStyleNames="{style.smallTextEditor}" ui:field="remotePathEditor" /> + <d:AdvancedParametersExpander ui:field="configExpander"/> + <g:FlowPanel height="100px"> + <g:VerticalPanel ui:field="configPanel"> + <e:EntityModelCheckBoxEditor ui:field="useDefaultConfigEditor"/> + <e:EntityModelTextBoxEditor ui:field="sshCommandEditor" /> + <e:EntityModelTextBoxEditor ui:field="gsyncCommandEditor" /> + </g:VerticalPanel> + </g:FlowPanel> + <g:Label ui:field="messageLabel" addStyleNames="{style.messageLabel}" /> + </g:VerticalPanel> + </d:content> + </d:SimpleDialogPanel> +</ui:UiBinder> \ No newline at end of file diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/MainTabGeoReplicationView.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/MainTabGeoReplicationView.java index 4f3d182..cdc2af5 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/MainTabGeoReplicationView.java +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/MainTabGeoReplicationView.java @@ -3,10 +3,12 @@ import org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity; import org.ovirt.engine.ui.common.idhandler.ElementIdHandler; import org.ovirt.engine.ui.common.uicommon.model.MainModelProvider; +import org.ovirt.engine.ui.uicommonweb.UICommand; import org.ovirt.engine.ui.uicommonweb.models.gluster.georep.GeoReplicationListModel; import org.ovirt.engine.ui.webadmin.ApplicationConstants; import org.ovirt.engine.ui.webadmin.section.main.presenter.tab.MainTabGeoReplicationPresenter; import org.ovirt.engine.ui.webadmin.section.main.view.AbstractMainTabWithDetailsTableView; +import org.ovirt.engine.ui.webadmin.widget.action.WebAdminButtonDefinition; import com.google.gwt.core.client.GWT; import com.google.inject.Inject; @@ -22,6 +24,16 @@ ApplicationConstants constants) { super(modelProvider); ViewIdHandler.idHandler.generateAndSetIds(this); + initTable(constants); initWidget(getTable()); } + + private void initTable(ApplicationConstants constants) { + getTable().addActionButton(new WebAdminButtonDefinition<GlusterVolumeEntity>(constants.newGeoReplication()) { + @Override + protected UICommand resolveCommand() { + return getMainModel().getStartGeoReplicationCommand(); + } + }); + } } -- To view, visit http://gerrit.ovirt.org/9529 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ia72ee637c519234221616ca93f002e28ff05ba81 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Kanagaraj M <kmayi...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches