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 <[email protected]>
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, 79 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/93/39293/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..68a3ac8
--- /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().getcompatibility_version()))
 {
+            
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 e509356..2cf6e44 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
@@ -41,4 +41,5 @@
     public static final String JOB_STATUS = "status";
     public static final String JOB_INFO = "info";
     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 70e32d2..6e83259 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
@@ -48,6 +48,7 @@
     VAR__TYPE__GLUSTER_SERVER,
     VAR__TYPE__GLUSTER_HOOK,
     VAR__TYPE__GLUSTER_SERVICE,
+    VAR__TYPE__GLUSTER_VOLUME_SNAPSHOT,
 
     // External Event
     VAR__TYPE__EXTERNAL_EVENT,
@@ -929,6 +930,8 @@
     ACTION_TYPE_FAILED_NO_SERVERS_FOR_CLUSTER(ErrorType.BAD_PARAMETERS),
     ACTION_TYPE_FAILED_VOLUME_OPERATION_IN_PROGRESS(ErrorType.CONFLICT),
     ACTION_TYPE_FAILED_GLUSTER_OPERATION_INPROGRESS(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),
 
     // OpenStack Glance
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 bbffa8b..50b8494 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
@@ -1034,6 +1034,7 @@
 VAR__TYPE__GLUSTER_SERVER=$type Gluster Server
 VAR__TYPE__GLUSTER_HOOK=$type Gluster Hook
 VAR__TYPE__GLUSTER_SERVICE=$type Service
+VAR__TYPE__GLUSTER_VOLUME_SNAPSHOT=$type Gluster Volume Snapshot
 VALIDATION.GLUSTER.VOLUME.ID.NOT_NULL=Volume ID is required.
 VALIDATION.GLUSTER.VOLUME.CLUSTER_ID.NOT_NULL=Cluster ID is required.
 VALIDATION.GLUSTER.VOLUME.NAME.NOT_NULL=Volume Name is required.
@@ -1134,6 +1135,8 @@
 ACTION_TYPE_FAILED_GLUSTER_VOLUME_CANNOT_STOP_REBALANCE_IN_PROGRESS= Cannot 
${action} ${type}. Rebalance is running on the volume ${volumeName} in cluster 
${vdsGroup}.
 ACTION_TYPE_FAILED_GLUSTER_VOLUME_CANNOT_STOP_REMOVE_BRICK_IN_PROGRESS= Cannot 
${action} ${type}. Remove brick operation is running on the volume 
${volumeName} in cluster ${vdsGroup}.
 ACTION_TYPE_FAILED_GLUSTER_OPERATION_INPROGRESS=Cannot ${action} ${type}. 
Gluster operation is in progress in cluster. Please try again.
+ACTION_TYPE_FAILED_VOLUME_SNAPSHOT_NOT_SUPPORTED=Cannot ${action} ${type}. 
Gluster volume snapshot is 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_OUT_OF_RANGE_VALUES=Cannot ${action} ${type}. Values 
are out of range.
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 b34e6aa..9bb5166 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
@@ -862,6 +862,9 @@
     @DefaultStringValue("$type CPU Profile")
     String VAR__TYPE__CPU_PROFILE();
 
+    @DefaultStringValue("$type Gluster Volume Snapshot")
+    String VAR__TYPE__GLUSTER_VOLUME_SNAPSHOT();
+
     @DefaultStringValue("$action run")
     String VAR__ACTION__RUN();
 
@@ -3066,6 +3069,12 @@
     @DefaultStringValue("Cannot ${action} ${type}. Gluster operation is in 
progress in cluster. Please try again.")
     String ACTION_TYPE_FAILED_GLUSTER_OPERATION_INPROGRESS();
 
+    @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();
 
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 65cf3f6..e3d18b7 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
@@ -313,6 +313,7 @@
 VAR__TYPE__GLUSTER_SERVER=$type Gluster Server
 VAR__TYPE__GLUSTER_HOOK=$type Gluster Hook
 VAR__TYPE__GLUSTER_SERVICE=$type Service
+VAR__TYPE__GLUSTER_VOLUME_SNAPSHOT=$type Gluster Volume Snapshot
 VAR__TYPE__NETWORK_QOS=$type Network QoS
 VAR__TYPE__QOS=$type QoS
 VAR__TYPE__SPM=$type SPM
@@ -1103,6 +1104,8 @@
 ACTION_TYPE_FAILED_GLUSTER_VOLUME_CANNOT_STOP_REBALANCE_IN_PROGRESS= Cannot 
${action} ${type}. Rebalance is running on the volume ${volumeName} in cluster 
${vdsGroup}.
 ACTION_TYPE_FAILED_GLUSTER_VOLUME_CANNOT_STOP_REMOVE_BRICK_IN_PROGRESS= Cannot 
${action} ${type}. Remove brick operation is running on the volume 
${volumeName} in cluster ${vdsGroup}.
 ACTION_TYPE_FAILED_GLUSTER_OPERATION_INPROGRESS=Cannot ${action} ${type}. 
Gluster operation is in progress in cluster. Please try again.
+ACTION_TYPE_FAILED_VOLUME_SNAPSHOT_NOT_SUPPORTED=Cannot ${action} ${type}. 
Gluster volume snapshot is 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_OUT_OF_RANGE_VALUES=Cannot ${action} ${type}. Values 
are out of range.


-- 
To view, visit https://gerrit.ovirt.org/39293
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ieb1dc93786ae8080e12d2ca62e501db953508d5f
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.5-gluster
Gerrit-Owner: Shubhendu Tripathi <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to