Shubhendu Tripathi has uploaded a new change for review. Change subject: gluster: Base BLL command for gluster volume snapshots ......................................................................
gluster: Base BLL command for gluster volume snapshots Base BLL command for gluster volume snapshot feature Signed-off-by: Shubhendu Tripathi <shtri...@redhat.com> Change-Id: Ieb1dc93786ae8080e12d2ca62e501db953508d5f --- A backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterSnapshotCommandBase.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/constants/gluster/GlusterConstants.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/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties 6 files changed, 74 insertions(+), 1 deletion(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/40/37940/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterSnapshotCommandBase.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterSnapshotCommandBase.java new file mode 100644 index 0000000..555f502 --- /dev/null +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterSnapshotCommandBase.java @@ -0,0 +1,60 @@ +package org.ovirt.engine.core.bll.gluster; + +import java.util.Collections; +import java.util.Map; + +import org.ovirt.engine.core.bll.LockMessagesMatchUtil; +import org.ovirt.engine.core.common.action.LockProperties; +import org.ovirt.engine.core.common.action.LockProperties.Scope; +import org.ovirt.engine.core.common.action.gluster.GlusterVolumeParameters; +import org.ovirt.engine.core.common.errors.VdcBllMessages; +import org.ovirt.engine.core.common.gluster.GlusterFeatureSupported; +import org.ovirt.engine.core.common.locks.LockingGroup; +import org.ovirt.engine.core.common.utils.Pair; +import org.ovirt.engine.core.dao.gluster.GlusterVolumeSnapshotDao; + +public abstract class GlusterSnapshotCommandBase<T extends GlusterVolumeParameters> extends GlusterVolumeCommandBase<T> { + public GlusterSnapshotCommandBase(T params) { + super(params); + setGlusterVolumeId(params.getVolumeId()); + } + + @Override + protected LockProperties applyLockProperties(LockProperties lockProperties) { + return lockProperties.withScope(Scope.Execution).withWait(false); + } + + @Override + protected void setActionMessageParameters() { + addCanDoActionMessage(VdcBllMessages.VAR__TYPE__GLUSTER_VOLUME_SNAPSHOT); + addCanDoActionMessageVariable("volumeName", getGlusterVolumeName()); + addCanDoActionMessageVariable("vdsGroup", getVdsGroupName()); + } + + @Override + protected boolean canDoAction() { + if (!super.canDoAction()) { + return false; + } + + if (!GlusterFeatureSupported.glusterSnapshot(getVdsGroup().getCompatibilityVersion())) { + failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_VOLUME_SNAPSHOT_NOT_SUPPORTED); + } + + return true; + } + + @Override + protected Map<String, Pair<String, String>> getExclusiveLocks() { + if (!isInternalExecution()) { + return Collections.singletonMap(getGlusterVolumeId().toString(), + LockMessagesMatchUtil.makeLockingPair(LockingGroup.GLUSTER_SNAPSHOT, + VdcBllMessages.ACTION_TYPE_FAILED_VOLUME_SNAPSHOT_LOCKED)); + } + return null; + } + + protected GlusterVolumeSnapshotDao getGlusterVolumeSnapshotDao() { + return getDbFacade().getGlusterVolumeSnapshotDao(); + } +} diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/constants/gluster/GlusterConstants.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/constants/gluster/GlusterConstants.java index ae767d0..56d513c 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/constants/gluster/GlusterConstants.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/constants/gluster/GlusterConstants.java @@ -42,4 +42,5 @@ public static final String JOB_INFO = "info"; public static final String NO_SERVER = "NO SERVER"; public static final String VOLUME_SNAPSHOT_MAX_HARD_LIMIT = "snap-max-hard-limit"; + public static final String VOLUME_SNAPSHOT_NAME = "snapname"; } 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 fe40f45..ebb5c17 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 @@ -54,6 +54,7 @@ VAR__TYPE__GLUSTER_HOOK, VAR__TYPE__GLUSTER_SERVICE, VAR__TYPE__GLUSTER_GEOREP_SESSION, + VAR__TYPE__GLUSTER_VOLUME_SNAPSHOT, // External Event VAR__TYPE__EXTERNAL_EVENT, @@ -966,6 +967,8 @@ ACTION_TYPE_FAILED_GEOREP_SESSION_ALREADY_STARTED(ErrorType.CONFLICT), ACTION_TYPE_FAILED_GEOREP_SESSION_ALREADY_PAUSED(ErrorType.CONFLICT), ACTION_TYPE_FAILED_GEOREP_SESSION_LOCKED(ErrorType.CONFLICT), + ACTION_TYPE_FAILED_VOLUME_SNAPSHOT_NOT_SUPPORTED(ErrorType.CONFLICT), + ACTION_TYPE_FAILED_REMOTE_CLUSTER_NOT_MAINTAINED_BY_ENGINE(ErrorType.CONFLICT), ACTION_TYPE_FAILED_VOLUME_SNAPSHOT_LOCKED(ErrorType.CONFLICT), ACTION_TYPE_FAILED_GEOREP_SESSION_STOPPED(ErrorType.CONFLICT), ACTION_TYPE_FAILED_GEOREP_SESSION_ALREADY_RESUMED(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 d6980fe..74447c9 100644 --- a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties +++ b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties @@ -1170,6 +1170,8 @@ ACTION_TYPE_FAILED_GEOREP_SESSION_ALREADY_STARTED=Cannot ${action} ${type}. Geo-replication session is already started. ACTION_TYPE_FAILED_GEOREP_SESSION_ALREADY_RESUMED=Cannot ${action} ${type}. Geo-replication session is resumed. ACTION_TYPE_FAILED_GEOREP_SESSION_ALREADY_PAUSED=Cannot ${action} ${type}. Geo-replication session is paused. +ACTION_TYPE_FAILED_VOLUME_SNAPSHOT_NOT_SUPPORTED=Cannot ${action} ${type}. Volume snapshot feature not supported. +ACTION_TYPE_FAILED_REMOTE_CLUSTER_NOT_MAINTAINED_BY_ENGINE=Cannot ${action} ${type}. Remote cluster is not maintained by engine. ACTION_TYPE_FAILED_TAG_ID_REQUIRED=Cannot ${action} ${type}. Tag ID is required. 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 df810da..69f0209 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 @@ -3146,6 +3146,12 @@ @DefaultStringValue("Cannot ${action} ${type}. Geo-replication session is paused.") String ACTION_TYPE_FAILED_GEOREP_SESSION_ALREADY_PAUSED(); + @DefaultStringValue("Cannot ${action} ${type}. Volume snapshot feature not supported.") + String ACTION_TYPE_FAILED_VOLUME_SNAPSHOT_NOT_SUPPORTED(); + + @DefaultStringValue("Cannot ${action} ${type}. Remote cluster is not maintained by engine.") + String ACTION_TYPE_FAILED_REMOTE_CLUSTER_NOT_MAINTAINED_BY_ENGINE(); + @DefaultStringValue("Cannot ${action} ${type}. All three values are needed in order to define QoS on each network directions.") String ACTION_TYPE_FAILED_NETWORK_QOS_MISSING_VALUES(); @@ -3565,5 +3571,4 @@ @DefaultStringValue("Cannot ${action} ${type}. Graphics device ID or VM/Template ID is null.") String ACTION_TYPE_REMOVE_GRAPHICS_DEV_INVALID_PARAMS(); - } 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 bc1b606..ead1a90 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 @@ -1134,6 +1134,8 @@ ACTION_TYPE_FAILED_GEOREP_SESSION_ALREADY_STARTED=Cannot ${action} ${type}. Geo-replication session is already started. ACTION_TYPE_FAILED_GEOREP_SESSION_RESUMED=Cannot ${action} ${type}. Geo-replication session is resumed. ACTION_TYPE_FAILED_GEOREP_SESSION_ALREADY_PAUSED=Cannot ${action} ${type}. Geo-replication session is paused. +ACTION_TYPE_FAILED_VOLUME_SNAPSHOT_NOT_SUPPORTED=Cannot ${action} ${type}. Volume snapshot feature not supported. +ACTION_TYPE_FAILED_REMOTE_CLUSTER_NOT_MAINTAINED_BY_ENGINE=Cannot ${action} ${type}. Remote cluster is not maintained by engine. ACTION_TYPE_FAILED_TAG_ID_REQUIRED=Cannot ${action} ${type}. Tag ID is required. ACTION_TYPE_FAILED_QOS_CPU_OUT_OF_RANGE_VALUES=Cannot ${action} ${type}. Values are out of range\n(Legal range is: 1-100). -- To view, visit http://gerrit.ovirt.org/37940 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ieb1dc93786ae8080e12d2ca62e501db953508d5f 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