anmolbabu 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, 49 insertions(+), 10 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/14/40114/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 0cf784b..7515916 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 @@ -11,6 +11,7 @@ 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; @@ -51,6 +52,26 @@ 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(); + Date convertedStartDate = convertDate(schedule.getStartDate(), schedule.getTimeZone()); + Date convertedEndByDate = convertDate(schedule.getEndByDate(), schedule.getTimeZone()); + + if (schedule.getRecurrence() != null + && schedule.getRecurrence() != GlusterVolumeSnapshotScheduleRecurrence.UNKNOWN) { + if (convertedStartDate != null && convertedStartDate.compareTo(currentDate) < 0) { + return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_START_DATE_BEFORE_CURRENT_DATE); + } + if (schedule.getEndByDate() != null) { + if (convertedEndByDate.compareTo(currentDate) < 0) { + return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_END_BY_DATE_BEFORE_CURRENT_DATE); + } + if (convertedStartDate != null && convertedEndByDate.compareTo(convertedStartDate) <= 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 bd756b5..e99307f 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 @@ -902,6 +902,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 714f570..4c8bd22 100644 --- a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties +++ b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties @@ -1081,9 +1081,12 @@ VMPAYLOAD_CDROM_WITH_CLOUD_INIT=Payload cdrom deivce cannot be used with Cloud-Init via cdrom device. ACTION_TYPE_FAILED_GLUSTER_VOLUME_IS_UP=Cannot ${action} ${type}. Gluster volume ${volumeName} is up. ACTION_TYPE_FAILED_GLUSTER_VOLUME_IS_DOWN=Cannot ${action} ${type}. Gluster Volume is down. -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_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 3716a8f..b2b7a58 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 @@ -2886,6 +2886,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 8f5ebf0..a99643d 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 @@ -241,9 +241,9 @@ } if (getEndByOptions().getSelectedItem() == EndDateOptions.HasEndDate - && getEndDate().getEntity().compareTo(getStartAt().getEntity()) < 0) { - setMessage(ConstantsManager.getInstance().getConstants().endDateBeforeStartDate()); - validEndDate = false; + && getEndDate().getEntity().compareTo(getStartAt().getEntity()) <= 0) { + setMessage(ConstantsManager.getInstance().getConstants().endDateBeforeStartDate()); + validEndDate = false; } return getSnapshotName().getIsValid() && getDaysOfTheWeek().getIsValid() && getDaysOfMonth().getIsValid() 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 2b1dade..e757e50 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 @@ -2591,7 +2591,7 @@ @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("Unable to fetch gluster volume snapshot schedule") 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 7fdc96f..fdf6fc8 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 @@ -1065,9 +1065,12 @@ ACTION_TYPE_FAILED_GLUSTER_VOLUME_ALREADY_STOPPED=Cannot ${action} ${type}. Gluster Volume ${volumeName} already stopped. ACTION_TYPE_FAILED_GLUSTER_VOLUME_IS_UP=Cannot ${action} ${type}. Gluster Volume ${volumeName} is up. ACTION_TYPE_FAILED_GLUSTER_VOLUME_IS_DOWN=Cannot ${action} ${type}. Gluster Volume is down. -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_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/40114 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I437344f106b9e998a8f9258ca836f91d39c7ad32 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: ovirt-engine-3.5-gluster Gerrit-Owner: anmolbabu <anb...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches