Shubhendu Tripathi has uploaded a new change for review. Change subject: webadmin: Allow to ignore geo-relication while volume snapshot creation ......................................................................
webadmin: Allow to ignore geo-relication while volume snapshot creation Introduced a mechanism to help users to ignore geo-replication and go ahead with volume snapshot creation (if remote cluster is not maintained by the engine). Change-Id: Ic68228760b577c0da7474d1daf17ce19eae047dc Signed-off-by: Shubhendu Tripathi <[email protected]> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/CreateGlusterVolumeSnapshotCommand.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/gluster/CreateGlusterVolumeSnapshotParameters.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/GlusterVolumeSnapshotListModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/GlusterVolumeSnapshotModel.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/gluster/GlusterVolumeSnapshotCreatePopupView.java M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/GlusterVolumeSnapshotCreatePopupView.ui.xml 7 files changed, 96 insertions(+), 12 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/69/38469/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/CreateGlusterVolumeSnapshotCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/CreateGlusterVolumeSnapshotCommand.java index b8ea42c..e6c7fe5 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/CreateGlusterVolumeSnapshotCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/CreateGlusterVolumeSnapshotCommand.java @@ -31,12 +31,14 @@ private GlusterVolumeSnapshotEntity snapshot; private boolean force; + private boolean ignoreGeoRep; private List<GlusterGeoRepSession> georepSessions; public CreateGlusterVolumeSnapshotCommand(CreateGlusterVolumeSnapshotParameters params) { super(params); this.snapshot = params.getSnapshot(); this.force = params.getForce(); + this.ignoreGeoRep = params.getIgnoreGeoRep(); this.georepSessions = new ArrayList<>(); if (this.snapshot != null) { @@ -190,12 +192,14 @@ return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_SNAPSHOT_ALREADY_EXISTS); } + if (!ignoreGeoRep) { georepSessions = getDbFacade().getGlusterGeoRepDao().getGeoRepSessions(volume.getId()); - for (GlusterGeoRepSession session : georepSessions) { - if (session.getSlaveNodeUuid() == null || session.getSlaveVolumeId() == null) { - // Slave cluster is not maintained by engine, so cannot pause geo-rep session and create snapshot for - // the volume - return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_REMOTE_CLUSTER_NOT_MAINTAINED_BY_ENGINE); + for (GlusterGeoRepSession session : georepSessions) { + if (session.getSlaveNodeUuid() == null || session.getSlaveVolumeId() == null) { + // Slave cluster is not maintained by engine, so cannot pause geo-rep session and create snapshot + // for the volume + return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_REMOTE_CLUSTER_NOT_MAINTAINED_BY_ENGINE); + } } } diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/gluster/CreateGlusterVolumeSnapshotParameters.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/gluster/CreateGlusterVolumeSnapshotParameters.java index 6f050f9..cf94334 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/gluster/CreateGlusterVolumeSnapshotParameters.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/gluster/CreateGlusterVolumeSnapshotParameters.java @@ -9,6 +9,8 @@ private boolean force; + private boolean ignoreGeoRep; + public CreateGlusterVolumeSnapshotParameters() { } @@ -22,6 +24,14 @@ super(snapshot.getVolumeId()); this.snapshot = snapshot; this.force = force; + } + + public CreateGlusterVolumeSnapshotParameters(GlusterVolumeSnapshotEntity snapshot, + boolean force, boolean ignoreGeoRep) { + super(snapshot.getVolumeId()); + this.snapshot = snapshot; + this.force = force; + this.ignoreGeoRep = ignoreGeoRep; } public GlusterVolumeSnapshotEntity getSnapshot() { @@ -39,4 +49,12 @@ public void setForce(boolean force) { this.force = force; } + + public boolean getIgnoreGeoRep() { + return this.ignoreGeoRep; + } + + public void setIgnoreGeoRep(boolean ignoreGeoRep) { + this.ignoreGeoRep = ignoreGeoRep; + } } diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/GlusterVolumeSnapshotListModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/GlusterVolumeSnapshotListModel.java index 26efcd9..2c579da 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/GlusterVolumeSnapshotListModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/GlusterVolumeSnapshotListModel.java @@ -281,7 +281,7 @@ snapshot.setDescription(snapshotModel.getDescription().getEntity()); CreateGlusterVolumeSnapshotParameters parameter = - new CreateGlusterVolumeSnapshotParameters(snapshot, true); + new CreateGlusterVolumeSnapshotParameters(snapshot, true, snapshotModel.getIgnoreGeoRep().getEntity()); snapshotModel.startProgress(null); Frontend.getInstance().runAction(VdcActionType.CreateGlusterVolumeSnapshot, @@ -291,11 +291,22 @@ public void executed(FrontendActionAsyncResult result) { GlusterVolumeSnapshotListModel localModel = (GlusterVolumeSnapshotListModel) result.getState(); - localModel.stopProgress(); - localModel.postOnCreateSnapshot(result.getReturnValue(), snapshot, snapshotModel); + + if (!result.getReturnValue().getCanDoAction()){ + for (String entry : result.getReturnValue().getCanDoActionMessages()) { + if (entry.contains("Remote cluster is not maintained by engine")) {//$NON-NLS-1$ + snapshotModel.setIgnoreGeoRepChkBoxVisible(true); + break; + } + } + snapshotModel.stopProgress(); + } else { + localModel.stopProgress(); + localModel.postOnCreateSnapshot(result.getReturnValue(), snapshot, snapshotModel); + } } }, - this); + this, snapshotModel.getIgnoreGeoRep().getEntity()); } public void postOnScheduleSnapshot(VdcReturnValueBase returnValue, diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/GlusterVolumeSnapshotModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/GlusterVolumeSnapshotModel.java index 44db8b4..a81692c 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/GlusterVolumeSnapshotModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/GlusterVolumeSnapshotModel.java @@ -16,6 +16,7 @@ import org.ovirt.engine.ui.uicommonweb.validation.LengthValidation; import org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation; import org.ovirt.engine.ui.uicompat.ConstantsManager; +import org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs; import org.ovirt.engine.ui.uicompat.UIConstants; public class GlusterVolumeSnapshotModel extends Model { @@ -33,11 +34,13 @@ private EntityModel<Date> endDate; private boolean generalTabVisible; private boolean scheduleTabVisible; + private boolean ignoreGeoRepChkBoxVisible; private ListModel<String> timeZones; private EntityModel<Date> startAt; private EntityModel<Date> executionTime; private ListModel<String> daysOfWeek; private ListModel<String> daysOfMonth; + private EntityModel<Boolean> ignoreGeoRep; public GlusterVolumeSnapshotModel(List<GlusterVolumeSnapshotScheduleRecurrence> recurrenceOptions, boolean generalTabVisible, @@ -46,6 +49,7 @@ setAvailabilities(); setGeneralTabVisible(generalTabVisible); setScheduleTabVisible(scheduleTabVisible); + ignoreGeoRepChkBoxVisible = false; } private void init(List<GlusterVolumeSnapshotScheduleRecurrence> recurrenceOptions) { @@ -63,6 +67,7 @@ setStartAt(new EntityModel<Date>(new Date())); setEndDate(new EntityModel<Date>(new Date())); setExecutionTime(new EntityModel<Date>(new Date())); + setIgnoreGeoRep(new EntityModel<Boolean>(false)); initIntervals(); initTimeZones(); @@ -74,7 +79,6 @@ values.add(day.toString().substring(0, 3)); } daysOfWeek.setItems(values); -// daysOfWeek.setSelectedItem(null); } private void initIntervals() { @@ -187,6 +191,15 @@ this.scheduleTabVisible = scheduleTabVisible; } + public boolean isIgnoreGeoRepChkBoxVisible() { + return this.ignoreGeoRepChkBoxVisible; + } + + public void setIgnoreGeoRepChkBoxVisible(boolean visible) { + this.ignoreGeoRepChkBoxVisible = visible; + onPropertyChanged(new PropertyChangedEventArgs("ignoreGeoRepChkBox"));//$NON-NLS-1$ + } + public ListModel<String> getTimeZones() { return timeZones; } @@ -227,6 +240,14 @@ this.daysOfMonth = daysOfMonth; } + public EntityModel<Boolean> getIgnoreGeoRep() { + return ignoreGeoRep; + } + + public void setIgnoreGeoRep(EntityModel<Boolean> value) { + this.ignoreGeoRep = value; + } + public boolean validate() { boolean validWeekDays = true; boolean validMonthDays = true; @@ -252,11 +273,13 @@ } Date currentDate = new Date(); - if (getStartAt().getEntity().compareTo(currentDate) < 0) { + if (getRecurrence().getSelectedItem() != GlusterVolumeSnapshotScheduleRecurrence.None + && getStartAt().getEntity().compareTo(currentDate) < 0) { setMessage(ConstantsManager.getInstance().getConstants().startDateBeforeCurrentDate()); validStartDate = false; } - if (getEndByOptions().getSelectedItem() == EndDateOptions.HasEndDate) { + if (getRecurrence().getSelectedItem() != GlusterVolumeSnapshotScheduleRecurrence.None + && getEndByOptions().getSelectedItem() == EndDateOptions.HasEndDate) { if (getEndDate().getEntity().compareTo(getStartAt().getEntity()) <= 0) { setMessage(ConstantsManager.getInstance().getConstants().endDateBeforeStartDate()); validEndDate = false; 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 a6cbb5d..2b11535 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 @@ -4118,4 +4118,7 @@ @DefaultStringValue("Frequent creation of snapshots would overload the gluster cluster") String criticalSnapshotIntervalNote(); + + @DefaultStringValue("Remote cluster is not maintained by engine. Ignore geo replication?") + String remoteClusterNotMaintainedByEngine(); } diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/GlusterVolumeSnapshotCreatePopupView.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/GlusterVolumeSnapshotCreatePopupView.java index 98f6134..229bc2b 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/GlusterVolumeSnapshotCreatePopupView.java +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/GlusterVolumeSnapshotCreatePopupView.java @@ -3,6 +3,7 @@ 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.InfoIcon; import org.ovirt.engine.ui.common.widget.dialog.SimpleDialogPanel; import org.ovirt.engine.ui.common.widget.dialog.tab.DialogTab; @@ -11,6 +12,7 @@ import org.ovirt.engine.ui.common.widget.editor.ListModelDaysOfMonthSelectorEditor; import org.ovirt.engine.ui.common.widget.editor.ListModelListBoxEditor; import org.ovirt.engine.ui.common.widget.editor.ListModelRadioGroupEditor; +import org.ovirt.engine.ui.common.widget.editor.generic.EntityModelCheckBoxEditor; import org.ovirt.engine.ui.common.widget.editor.generic.StringEntityModelLabelEditor; import org.ovirt.engine.ui.common.widget.editor.generic.StringEntityModelTextBoxEditor; import org.ovirt.engine.ui.uicommonweb.models.ListModel; @@ -140,6 +142,11 @@ @WithElementId TextArea errorMsgLabel; + @UiField(provided = true) + @Path(value = "ignoreGeoRep.entity") + @WithElementId + EntityModelCheckBoxEditor ignoreGeoRepEditor; + private final ApplicationConstants constants; private final Driver driver = GWT.create(Driver.class); @@ -153,6 +160,7 @@ initEditors(constants, resources, templates); initWidget(ViewUiBinder.uiBinder.createAndBindUi(this)); ViewIdHandler.idHandler.generateAndSetIds(this); + addStyles(); localize(); driver.initialize(this); startAtEditor.asDateBox().setMinuteSteps(1); @@ -170,6 +178,11 @@ endDate = new EntityModelDateTimeBoxEditor(); executionTimeEditor = new EntityModelDateTimeBoxEditor(); executionTimeEditor.asDateBox().setDateRequired(false); + ignoreGeoRepEditor = new EntityModelCheckBoxEditor(Align.RIGHT); + } + + private void addStyles() { + daysOfWeekEditor.addContentWidgetStyleName(style.ignoreGeoRepEditor()); } private void localize() { @@ -192,6 +205,7 @@ startAtEditor.setLabel(constants.startAtLabel()); endDate.setLabel(constants.endByDateLabel()); executionTimeEditor.setLabel(constants.executionTimeLabel()); + ignoreGeoRepEditor.setLabel(constants.remoteClusterNotMaintainedByEngine()); criticalIntervalLabel.setText(constants.criticalSnapshotIntervalNote()); criticalIntervalLabel.setVisible(false); @@ -201,6 +215,7 @@ @Override public void edit(final GlusterVolumeSnapshotModel object) { driver.edit(object); + ignoreGeoRepEditor.setVisible(false); object.getInterval().getSelectedItemChangedEvent() .addListener(new IEventListener<EventArgs>() { @@ -258,6 +273,9 @@ errorMsgLabel.setText(model.getMessage()); errorMsgLabel.setVisible(true); } + if ("ignoreGeoRepChkBox".equals(args.propertyName)) { //$NON-NLS-1$ + ignoreGeoRepEditor.setVisible(model.isIgnoreGeoRepChkBoxVisible()); + } } }); @@ -306,5 +324,7 @@ interface WidgetStyle extends CssResource { String editorContentWidget(); + + String ignoreGeoRepEditor(); } } diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/GlusterVolumeSnapshotCreatePopupView.ui.xml b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/GlusterVolumeSnapshotCreatePopupView.ui.xml index e295d04..bca4e56 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/GlusterVolumeSnapshotCreatePopupView.ui.xml +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/GlusterVolumeSnapshotCreatePopupView.ui.xml @@ -52,6 +52,10 @@ padding-bottom: 10px; } + .ignoreGeoRepEditor{ + width: 470px; + } + </ui:style> <d:SimpleDialogPanel width="700px" height="450px"> @@ -73,6 +77,7 @@ </g:HorizontalPanel> <ge:StringEntityModelTextBoxEditor ui:field="snapshotDescriptionEditor" /> + <ge:EntityModelCheckBoxEditor ui:field="ignoreGeoRepEditor" addStyleNames="{style.ignoreGeoRepEditor}" /> </g:FlowPanel> </t:content> </t:DialogTab> -- To view, visit https://gerrit.ovirt.org/38469 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic68228760b577c0da7474d1daf17ce19eae047dc Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Shubhendu Tripathi <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
