Shubhendu Tripathi has uploaded a new change for review. Change subject: gluster: Additional validations for volume snapshot create/schedule ......................................................................
gluster: Additional validations for volume snapshot create/schedule Added additional validations while creation and scheduling of the gluster volume snapshots. Change-Id: I437344f106b9e998a8f9258ca836f91d39c7ad32 Signed-off-by: Shubhendu Tripathi <shtri...@redhat.com> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/ScheduleGlusterVolumeSnapshotCommandBase.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java M backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties M frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/GlusterVolumeSnapshotModel.java M frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java M frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties 7 files changed, 61 insertions(+), 6 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/68/38468/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/ScheduleGlusterVolumeSnapshotCommandBase.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/ScheduleGlusterVolumeSnapshotCommandBase.java index 928f83b..f8f42d0 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/ScheduleGlusterVolumeSnapshotCommandBase.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/ScheduleGlusterVolumeSnapshotCommandBase.java @@ -1,12 +1,14 @@ package org.ovirt.engine.core.bll.gluster; import java.sql.Time; +import java.util.Date; import org.ovirt.engine.core.bll.utils.GlusterUtil; import org.ovirt.engine.core.common.action.gluster.ScheduleGlusterVolumeSnapshotParameters; import org.ovirt.engine.core.common.businessentities.gluster.GlusterStatus; import org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity; import org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotSchedule; +import org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotScheduleRecurrence; import org.ovirt.engine.core.common.errors.VdcBllMessages; import org.ovirt.engine.core.dal.dbbroker.DbFacade; import org.ovirt.engine.core.dao.gluster.GlusterVolumeSnapshotScheduleDao; @@ -47,6 +49,22 @@ return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_GLUSTER_VOLUME_IS_NOT_THINLY_PROVISIONED); } + // Validate the scheduling dates (start and end by dates) + Date currentDate = new Date(); + if (schedule.getRecurrence() != GlusterVolumeSnapshotScheduleRecurrence.UNKNOWN) { + if (schedule.getStartDate() != null && schedule.getStartDate().compareTo(currentDate) < 0) { + return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_START_DATE_BEFORE_CURRENT_DATE); + } + if (schedule.getEndByDate() != null) { + if (schedule.getEndByDate().compareTo(currentDate) < 0) { + return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_END_BY_DATE_BEFORE_CURRENT_DATE); + } + if (schedule.getStartDate() != null && schedule.getEndByDate().compareTo(schedule.getStartDate()) <= 0) { + return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_END_BY_DATE_BEFORE_START_DATE); + } + } + } + return true; } diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java index b0726c8..9c44d0f 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java @@ -932,6 +932,9 @@ ACTION_TYPE_FAILED_GLUSTER_VOLUME_IS_NOT_THINLY_PROVISIONED(ErrorType.CONFLICT), ACTION_TYPE_FAILED_GLUSTER_VOLUME_SNAPSHOT_CONFIG_PARAMS_IS_EMPTY(ErrorType.BAD_PARAMETERS), ACTION_TYPE_FAILED_GLUSTER_VOLUME_SNAPSHOT_CONFIG_PARAM_VALUE_IS_EMPTY(ErrorType.BAD_PARAMETERS), + ACTION_TYPE_FAILED_START_DATE_BEFORE_CURRENT_DATE(ErrorType.BAD_PARAMETERS), + ACTION_TYPE_FAILED_END_BY_DATE_BEFORE_CURRENT_DATE(ErrorType.BAD_PARAMETERS), + ACTION_TYPE_FAILED_END_BY_DATE_BEFORE_START_DATE(ErrorType.BAD_PARAMETERS), ACTION_TYPE_FAILED_NOT_A_GLUSTER_VOLUME_BRICK(ErrorType.BAD_PARAMETERS), ACTION_TYPE_FAILED_GLUSTER_VOLUME_REMOVE_BRICKS_NOT_STARTED(ErrorType.CONFLICT), ACTION_TYPE_FAILED_GLUSTER_VOLUME_REMOVE_BRICKS_NOT_FINISHED(ErrorType.CONFLICT), diff --git a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties index 27d2f72..cc0005c 100644 --- a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties +++ b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties @@ -1111,6 +1111,9 @@ ACTION_TYPE_FAILED_GLUSTER_VOLUME_IS_NOT_THINLY_PROVISIONED="Cannot ${action} ${type}. Gluster volume is not thinly provisioned." ACTION_TYPE_FAILED_GLUSTER_VOLUME_SNAPSHOT_CONFIG_PARAMS_IS_EMPTY="Cannot ${action} ${type}. No gluster volume snapshot parameters for update." ACTION_TYPE_FAILED_GLUSTER_VOLUME_SNAPSHOT_CONFIG_PARAM_VALUE_IS_EMPTY="Cannot ${action} ${type}. The value of gluster volume snapshot parameter ${snapshotConfigParam} is empty." +ACTION_TYPE_FAILED_START_DATE_BEFORE_CURRENT_DATE="Cannot ${action} ${type}. The value of start date is before current date." +ACTION_TYPE_FAILED_END_BY_DATE_BEFORE_CURRENT_DATE="Cannot ${action} ${type}. The value of end date is before current date." +ACTION_TYPE_FAILED_END_BY_DATE_BEFORE_START_DATE="Cannot ${action} ${type}. The value of end date cannot be before start date." ACTION_TYPE_FAILED_CAN_NOT_REMOVE_ALL_BRICKS_FROM_VOLUME=Cannot ${action} ${type}. Cannot remove all the bricks from a Volume. ACTION_TYPE_FAILED_GLUSTER_VOLUME_SHOULD_BE_STARTED=Cannot ${action} ${type}. Gluster Volume should be started. ACTION_TYPE_FAILED_GLUSTER_VOLUME_NOT_DISTRIBUTED=Cannot ${action} ${type}. Gluster Volume is not distributed. diff --git a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java index 5e6f921..c41d7a4 100644 --- a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java +++ b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java @@ -2942,6 +2942,15 @@ @DefaultStringValue("Cannot ${action} ${type}. The value of gluster volume snapshot parameter ${snapshotConfigParam} is empty.") String ACTION_TYPE_FAILED_GLUSTER_VOLUME_SNAPSHOT_CONFIG_PARAM_VALUE_IS_EMPTY(); + @DefaultStringValue("Cannot ${action} ${type}. The value of start date is before current date.") + String ACTION_TYPE_FAILED_START_DATE_BEFORE_CURRENT_DATE(); + + @DefaultStringValue("Cannot ${action} ${type}. The value of end date is before current date.") + String ACTION_TYPE_FAILED_END_BY_DATE_BEFORE_CURRENT_DATE(); + + @DefaultStringValue("Cannot ${action} ${type}. The value of end date cannot be before start date.") + String ACTION_TYPE_FAILED_END_BY_DATE_BEFORE_START_DATE(); + @DefaultStringValue("Cannot ${action} ${type}. Cannot remove all the bricks from a Volume.") String ACTION_TYPE_FAILED_CAN_NOT_REMOVE_ALL_BRICKS_FROM_VOLUME(); 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 139b320..44db8b4 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 @@ -230,6 +230,7 @@ public boolean validate() { boolean validWeekDays = true; boolean validMonthDays = true; + boolean validStartDate = true; boolean validEndDate = true; getSnapshotName().validateEntity(new IValidation[] { new NotEmptyValidation(), new LengthValidation(128), new AsciiNameValidation() }); @@ -250,14 +251,23 @@ } } - if (getEndByOptions().getSelectedItem() == EndDateOptions.HasEndDate - && getEndDate().getEntity().compareTo(getStartAt().getEntity()) < 0) { - setMessage(ConstantsManager.getInstance().getConstants().endDateBeforeStartDate()); - validEndDate = false; + Date currentDate = new Date(); + if (getStartAt().getEntity().compareTo(currentDate) < 0) { + setMessage(ConstantsManager.getInstance().getConstants().startDateBeforeCurrentDate()); + validStartDate = false; + } + if (getEndByOptions().getSelectedItem() == EndDateOptions.HasEndDate) { + if (getEndDate().getEntity().compareTo(getStartAt().getEntity()) <= 0) { + setMessage(ConstantsManager.getInstance().getConstants().endDateBeforeStartDate()); + validEndDate = false; + } else if (getEndDate().getEntity().compareTo(currentDate) < 0) { + setMessage(ConstantsManager.getInstance().getConstants().endDateBeforeCurrentDate()); + validEndDate = false; + } } return getSnapshotName().getIsValid() && getDaysOfTheWeek().getIsValid() && getDaysOfMonth().getIsValid() - && validWeekDays && validMonthDays && validEndDate; + && validWeekDays && validMonthDays && validStartDate && validEndDate; } public enum GlusterVolumeSnapshotScheduleRecurrence { diff --git a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java index 05a18ba..72b614a 100644 --- a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java +++ b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java @@ -2604,6 +2604,15 @@ @DefaultStringValue("Last day of month cannot be selected with other month days") String lastDayMonthCanBeSelectedAlone(); - @DefaultStringValue("End by date cannot be before start date") + @DefaultStringValue("End by date cannot be equal to or before start date") String endDateBeforeStartDate(); + + @DefaultStringValue("Start date cannot be before today's date") + String startDateBeforeCurrentDate(); + + @DefaultStringValue("End date cannot be before today's date") + String endDateBeforeCurrentDate(); + + @DefaultStringValue("Last Day") + String lastDay(); } diff --git a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties index dbffaa4..ec4c151 100644 --- a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties +++ b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties @@ -1092,6 +1092,9 @@ ACTION_TYPE_FAILED_GLUSTER_VOLUME_IS_NOT_THINLY_PROVISIONED="Cannot ${action} ${type}. Gluster volume is not thinly provisioned." ACTION_TYPE_FAILED_GLUSTER_VOLUME_SNAPSHOT_CONFIG_PARAMS_IS_EMPTY="Cannot ${action} ${type}. No gluster volume snapshot parameters for update." ACTION_TYPE_FAILED_GLUSTER_VOLUME_SNAPSHOT_CONFIG_PARAM_VALUE_IS_EMPTY="Cannot ${action} ${type}. The value of gluster volume snapshot parameter ${snapshotConfigParam} is empty." +ACTION_TYPE_FAILED_START_DATE_BEFORE_CURRENT_DATE="Cannot ${action} ${type}. The value of start date is before current date." +ACTION_TYPE_FAILED_END_BY_DATE_BEFORE_CURRENT_DATE="Cannot ${action} ${type}. The value of end date is before current date." +ACTION_TYPE_FAILED_END_BY_DATE_BEFORE_START_DATE="Cannot ${action} ${type}. The value of end date cannot be before start date." ACTION_TYPE_FAILED_CAN_NOT_REMOVE_ALL_BRICKS_FROM_VOLUME=Cannot ${action} ${type}. Cannot remove all the bricks from a Volume. ACTION_TYPE_FAILED_GLUSTER_VOLUME_SHOULD_BE_STARTED=Cannot ${action} ${type}. Gluster Volume should be started. ACTION_TYPE_FAILED_GLUSTER_VOLUME_NOT_DISTRIBUTED=Cannot ${action} ${type}. Gluster Volume is not distributed. -- To view, visit https://gerrit.ovirt.org/38468 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I437344f106b9e998a8f9258ca836f91d39c7ad32 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Shubhendu Tripathi <shtri...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches