Ramesh N has uploaded a new change for review.

Change subject: gluster: enable new gluster features using new feature check
......................................................................

gluster: enable new gluster features using new feature check

  Enabling the new gluster features like snapshot managment,
geo replication, brick provisioning based on new feature
compatibility check. With this, above features will be
supported in 3.5 cluster as well.

Change-Id: I9074a500caa1b5a30cea19e9fa4420e12d3fa6a1
Signed-off-by: Ramesh Nachimuthu <rnach...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/CreateBrickCommand.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/CreateGlusterVolumeGeoRepSessionCommand.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterGeoRepSyncJob.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterSnapshotCommandBase.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterSnapshotSyncJob.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/StorageDeviceSyncJob.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/SyncStorageDevicesCommand.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/UpdateGlusterVolumeSnapshotConfigCommand.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/utils/GlusterUtil.java
M 
backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/CreateBrickCommandTest.java
M 
backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/CreateGlusterVolumeGeoRepSessionCommandTest.java
M 
backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/GlusterGeoRepSyncJobTest.java
M 
backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/GlusterSnapshotSyncJobTest.java
M 
backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/StorageDeviceSyncJobTest.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/gluster/GlusterFeatureSupported.java
15 files changed, 153 insertions(+), 50 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/15/41115/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/CreateBrickCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/CreateBrickCommand.java
index e52c5c7..2fbd2e6 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/CreateBrickCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/CreateBrickCommand.java
@@ -7,6 +7,7 @@
 import org.ovirt.engine.core.bll.LockMessagesMatchUtil;
 import org.ovirt.engine.core.bll.VdsCommand;
 import org.ovirt.engine.core.bll.VdsValidator;
+import org.ovirt.engine.core.bll.utils.GlusterUtil;
 import org.ovirt.engine.core.common.AuditLogType;
 import org.ovirt.engine.core.common.action.LockProperties;
 import org.ovirt.engine.core.common.action.LockProperties.Scope;
@@ -17,7 +18,6 @@
 import org.ovirt.engine.core.common.businessentities.gluster.StorageDevice;
 import org.ovirt.engine.core.common.constants.gluster.GlusterConstants;
 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.ObjectUtils;
 import org.ovirt.engine.core.common.utils.Pair;
@@ -49,7 +49,8 @@
     protected boolean canDoAction() {
         VDSGroup cluster = getVdsGroup();
         if (!cluster.supportsGlusterService()
-                || 
!GlusterFeatureSupported.glusterBrickProvisioning(cluster.getcompatibility_version()))
 {
+                || 
(!getGlusterUtil().isGlusterBrickProvisioningSupported(cluster.getcompatibility_version(),
+                        getVdsGroup().getId()))) {
             return 
failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_PROVISIONING_NOT_SUPPORTED_BY_CLUSTER);
         }
 
@@ -153,4 +154,8 @@
     public AuditLogType getAuditLogTypeValue() {
         return getSucceeded() ? AuditLogType.CREATE_GLUSTER_BRICK : 
AuditLogType.CREATE_GLUSTER_BRICK_FAILED;
     }
+
+    protected GlusterUtil getGlusterUtil() {
+        return GlusterUtil.getInstance();
+    }
 }
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/CreateGlusterVolumeGeoRepSessionCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/CreateGlusterVolumeGeoRepSessionCommand.java
index 03c60e0..503d196 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/CreateGlusterVolumeGeoRepSessionCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/CreateGlusterVolumeGeoRepSessionCommand.java
@@ -8,6 +8,7 @@
 import java.util.concurrent.Callable;
 
 import org.ovirt.engine.core.bll.context.CommandContext;
+import org.ovirt.engine.core.bll.utils.GlusterUtil;
 import org.ovirt.engine.core.common.AuditLogType;
 import org.ovirt.engine.core.common.action.VdcActionType;
 import 
org.ovirt.engine.core.common.action.gluster.GlusterVolumeGeoRepSessionParameters;
@@ -22,7 +23,6 @@
 import org.ovirt.engine.core.common.businessentities.gluster.ServiceType;
 import org.ovirt.engine.core.common.constants.gluster.GlusterConstants;
 import org.ovirt.engine.core.common.errors.VdcBllMessages;
-import org.ovirt.engine.core.common.gluster.GlusterFeatureSupported;
 import org.ovirt.engine.core.common.queries.IdQueryParameters;
 import org.ovirt.engine.core.common.queries.VdcQueryReturnValue;
 import org.ovirt.engine.core.common.queries.VdcQueryType;
@@ -48,7 +48,8 @@
 
     @Override
     protected boolean canDoAction() {
-        if 
(!GlusterFeatureSupported.glusterGeoReplication(getVdsGroup().getcompatibility_version()))
 {
+        if 
(!getGlusterUtil().isGlusterGeoReplicationSupported(getVdsGroup().getcompatibility_version(),
+                getVdsGroup().getId())) {
             return 
failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_GEO_REP_NOT_SUPPORTED);
         }
         slaveHost = getSlaveHost();
@@ -230,4 +231,8 @@
         }
         return remoteServers;
     }
+
+    protected GlusterUtil getGlusterUtil() {
+        return GlusterUtil.getInstance();
+    }
 }
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterGeoRepSyncJob.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterGeoRepSyncJob.java
index 9b381f3..8aa80b7 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterGeoRepSyncJob.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterGeoRepSyncJob.java
@@ -20,7 +20,6 @@
 import org.ovirt.engine.core.common.constants.gluster.GlusterConstants;
 import org.ovirt.engine.core.common.errors.VdcBLLException;
 import org.ovirt.engine.core.common.errors.VdcBllErrors;
-import org.ovirt.engine.core.common.gluster.GlusterFeatureSupported;
 import org.ovirt.engine.core.common.vdscommands.VDSCommandType;
 import org.ovirt.engine.core.common.vdscommands.VDSReturnValue;
 import 
org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeGeoRepSessionVDSParameters;
@@ -453,7 +452,8 @@
 
     private boolean supportsGlusterGeoRepFeature(VDSGroup cluster) {
         return cluster.supportsGlusterService()
-                && 
GlusterFeatureSupported.glusterGeoReplication(cluster.getcompatibility_version());
+                && 
getGlusterUtil().isGlusterGeoReplicationSupported(cluster.getcompatibility_version(),
+                        cluster.getId());
     }
 
 }
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
index 63fd611..fe9b425 100644
--- 
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
@@ -9,7 +9,6 @@
 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.compat.Guid;
@@ -41,7 +40,8 @@
             return false;
         }
 
-        if 
(!GlusterFeatureSupported.glusterSnapshot(getVdsGroup().getcompatibility_version()))
 {
+        if 
(!getGlusterUtil().isGlusterSnapshotSupported(getVdsGroup().getcompatibility_version(),
+                getVdsGroup().getId())) {
             return 
failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_VOLUME_SNAPSHOT_NOT_SUPPORTED);
         }
 
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterSnapshotSyncJob.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterSnapshotSyncJob.java
index 2e86cef..3bc12fc 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterSnapshotSyncJob.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterSnapshotSyncJob.java
@@ -13,7 +13,6 @@
 import 
org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotEntity;
 import org.ovirt.engine.core.common.errors.VdcBLLException;
 import org.ovirt.engine.core.common.errors.VdcBllErrors;
-import org.ovirt.engine.core.common.gluster.GlusterFeatureSupported;
 import org.ovirt.engine.core.common.vdscommands.VDSCommandType;
 import org.ovirt.engine.core.common.vdscommands.VDSReturnValue;
 import 
org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeSnapshotVDSParameters;
@@ -265,7 +264,7 @@
 
     private boolean supportsGlusterSnapshotFeature(VDSGroup cluster) {
         return cluster.supportsGlusterService()
-                && 
GlusterFeatureSupported.glusterSnapshot(cluster.getcompatibility_version());
+                && 
getGlusterUtil().isGlusterSnapshotSupported(cluster.getcompatibility_version(), 
cluster.getId());
     }
 
     protected GlusterVolumeDao getGlusterVolumeDao() {
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/StorageDeviceSyncJob.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/StorageDeviceSyncJob.java
index 57ae61e..8db7d8c 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/StorageDeviceSyncJob.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/StorageDeviceSyncJob.java
@@ -17,7 +17,6 @@
 import org.ovirt.engine.core.common.businessentities.VDS;
 import org.ovirt.engine.core.common.businessentities.VDSGroup;
 import org.ovirt.engine.core.common.businessentities.gluster.StorageDevice;
-import org.ovirt.engine.core.common.gluster.GlusterFeatureSupported;
 import org.ovirt.engine.core.common.utils.Pair;
 import org.ovirt.engine.core.common.vdscommands.VDSCommandType;
 import org.ovirt.engine.core.common.vdscommands.VDSReturnValue;
@@ -180,7 +179,8 @@
 
     private boolean supportsGlusterDiskProvisioning(VDSGroup cluster) {
         return cluster.supportsGlusterService()
-                && 
GlusterFeatureSupported.glusterBrickProvisioning(cluster.getcompatibility_version());
+                && 
getGlusterUtil().isGlusterBrickProvisioningSupported(cluster.getcompatibility_version(),
+                        cluster.getId());
     }
 
 }
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/SyncStorageDevicesCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/SyncStorageDevicesCommand.java
index da7a4d9..5628085 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/SyncStorageDevicesCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/SyncStorageDevicesCommand.java
@@ -4,12 +4,12 @@
 
 import org.ovirt.engine.core.bll.VdsCommand;
 import org.ovirt.engine.core.bll.VdsValidator;
+import org.ovirt.engine.core.bll.utils.GlusterUtil;
 import org.ovirt.engine.core.bll.utils.Injector;
 import org.ovirt.engine.core.common.AuditLogType;
 import org.ovirt.engine.core.common.action.VdsActionParameters;
 import org.ovirt.engine.core.common.businessentities.VDSGroup;
 import org.ovirt.engine.core.common.errors.VdcBllMessages;
-import org.ovirt.engine.core.common.gluster.GlusterFeatureSupported;
 
 public class SyncStorageDevicesCommand<T extends VdsActionParameters> extends 
VdsCommand<T> {
 
@@ -21,7 +21,8 @@
     protected boolean canDoAction() {
         VDSGroup cluster = getVdsGroup();
         if (!cluster.supportsGlusterService()
-                || 
!GlusterFeatureSupported.glusterBrickProvisioning(cluster.getcompatibility_version()))
 {
+                || 
(!getGlusterUtil().isGlusterBrickProvisioningSupported(cluster.getcompatibility_version(),
+                        getVdsGroup().getId()))) {
             return 
failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_PROVISIONING_NOT_SUPPORTED_BY_CLUSTER);
         }
 
@@ -53,4 +54,9 @@
         return getSucceeded() ? AuditLogType.SYNC_STORAGE_DEVICES_IN_HOST
                 : AuditLogType.SYNC_STORAGE_DEVICES_IN_HOST_FAILED;
     }
+
+    protected GlusterUtil getGlusterUtil() {
+        return GlusterUtil.getInstance();
+    }
+
 }
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/UpdateGlusterVolumeSnapshotConfigCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/UpdateGlusterVolumeSnapshotConfigCommand.java
index d68460b..36dc566 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/UpdateGlusterVolumeSnapshotConfigCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/UpdateGlusterVolumeSnapshotConfigCommand.java
@@ -8,13 +8,13 @@
 
 import org.apache.commons.lang.StringUtils;
 import org.ovirt.engine.core.bll.LockMessagesMatchUtil;
+import org.ovirt.engine.core.bll.utils.GlusterUtil;
 import org.ovirt.engine.core.common.AuditLogType;
 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.UpdateGlusterVolumeSnapshotConfigParameters;
 import 
org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotConfig;
 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.common.vdscommands.VDSCommandType;
@@ -56,7 +56,8 @@
             return false;
         }
 
-        if 
(!GlusterFeatureSupported.glusterSnapshot(getVdsGroup().getcompatibility_version()))
 {
+        if 
(!getGlusterUtil().isGlusterSnapshotSupported(getVdsGroup().getcompatibility_version(),
+                getVdsGroup().getId())) {
             
failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_VOLUME_SNAPSHOT_NOT_SUPPORTED);
         }
 
@@ -185,4 +186,8 @@
             return errorType == null ? 
AuditLogType.GLUSTER_VOLUME_SNAPSHOT_CONFIG_UPDATE_FAILED : errorType;
         }
     }
+
+    protected GlusterUtil getGlusterUtil() {
+        return GlusterUtil.getInstance();
+    }
 }
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/utils/GlusterUtil.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/utils/GlusterUtil.java
index eac2241..f6a166a 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/utils/GlusterUtil.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/utils/GlusterUtil.java
@@ -1,5 +1,7 @@
 package org.ovirt.engine.core.bll.utils;
 
+import static org.ovirt.engine.core.common.FeatureSupported.supportedInConfig;
+
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.net.InetAddress;
@@ -26,6 +28,7 @@
 import org.ovirt.engine.core.bll.interfaces.BackendInternal;
 import org.ovirt.engine.core.common.AuditLogType;
 import org.ovirt.engine.core.common.businessentities.AuditLog;
+import 
org.ovirt.engine.core.common.businessentities.SupportedAdditionalClusterFeature;
 import org.ovirt.engine.core.common.businessentities.VDS;
 import org.ovirt.engine.core.common.businessentities.gluster.GlusterServer;
 import org.ovirt.engine.core.common.businessentities.gluster.GlusterServerInfo;
@@ -43,9 +46,11 @@
 import org.ovirt.engine.core.common.queries.VdcQueryType;
 import org.ovirt.engine.core.common.utils.Pair;
 import org.ovirt.engine.core.compat.Guid;
+import org.ovirt.engine.core.compat.Version;
 import org.ovirt.engine.core.dal.dbbroker.DbFacade;
 import org.ovirt.engine.core.dal.dbbroker.auditloghandling.AlertDirector;
 import 
org.ovirt.engine.core.dal.dbbroker.auditloghandling.gluster.GlusterAuditLogUtil;
+import org.ovirt.engine.core.dao.ClusterFeatureDao;
 import org.ovirt.engine.core.dao.gluster.GlusterDBUtils;
 import org.ovirt.engine.core.utils.XmlUtils;
 import org.ovirt.engine.core.utils.lock.EngineLock;
@@ -66,6 +71,10 @@
     private static final String HOST_NAME = "hostname";
     private static final String STATE = "state";
     private static final int PEER_IN_CLUSTER = 3;
+
+    public static final String FEATURE_GLUSTER_GEO_REPLICATION = 
"GLUSTER_GEO_REPLICATION";
+    public static final String FEATURE_GLUSTER_SNAPSHOT = "GLUSTER_SNAPSHOT";
+    public static final String FEATURE_GLUSTER_BRICK_MANAGEMENT = 
"GLUSTER_BRICK_MANAGEMENT";
 
     private GlusterUtil() {
 
@@ -392,4 +401,72 @@
             return null;
         }
     }
+
+    /**
+     * Checks if the given features is supported as additional feature in the 
cluster
+     *
+     * @param clusterId
+     * @param featureName
+     * @return
+     */
+    private boolean isFeatureSupportedAsAdditionalFeature(Guid clusterId, 
String featureName) {
+        Set<SupportedAdditionalClusterFeature> addtionalFeaturesSupported =
+                
getClusterFeatureDao().getSupportedFeaturesByClusterId(clusterId);
+        for (SupportedAdditionalClusterFeature supportedFeature : 
addtionalFeaturesSupported) {
+            if (supportedFeature.getFeature().getName().equals(featureName)) {
+                return supportedFeature.isEnabled();
+            }
+        }
+        return false;
+    }
+
+    private ClusterFeatureDao getClusterFeatureDao() {
+        return DbFacade.getInstance().getClusterFeatureDao();
+    }
+
+    /**
+     *
+     * @param version
+     *            Compatibility version to check for.
+     * @return <code>true</code> if gluster geo-replication management feature 
is enabled, <code>false</code> if it's
+     *         not.
+     */
+    public boolean isGlusterGeoReplicationSupported(Version version, Guid 
clusterId) {
+        if(supportedInConfig(ConfigValues.GlusterGeoReplicationEnabled, 
version)){
+            return true;
+        }else if(clusterId != null){
+            return isFeatureSupportedAsAdditionalFeature(clusterId, 
FEATURE_GLUSTER_GEO_REPLICATION);
+        }
+        return false;
+    }
+
+    /**
+     * @param version
+     *            Compatibility version to check for.
+     * @return <code>true</code> if gluster snapshot management feature is 
enabled, <code>false</code> if it's not.
+     */
+    public boolean isGlusterSnapshotSupported(Version version, Guid clusterId) 
{
+        if (supportedInConfig(ConfigValues.GlusterVolumeSnapshotSupported, 
version)) {
+            return true;
+        } else if (clusterId != null) {
+            return isFeatureSupportedAsAdditionalFeature(clusterId, 
FEATURE_GLUSTER_SNAPSHOT);
+        }
+        return false;
+    }
+
+    /**
+     *
+     * @param version
+     *            Compatibility version to check for.
+     * @return <code>true</code> if disk provisioning feature is enabled, 
<code>false</code> if it's not.
+     */
+    public boolean isGlusterBrickProvisioningSupported(Version version, Guid 
clusterId) {
+        if (supportedInConfig(ConfigValues.GlusterBrickProvisioningEnabled, 
version)) {
+            return true;
+        } else if (clusterId != null) {
+            return isFeatureSupportedAsAdditionalFeature(clusterId, 
FEATURE_GLUSTER_BRICK_MANAGEMENT);
+        }
+        return false;
+    }
+
 }
diff --git 
a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/CreateBrickCommandTest.java
 
b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/CreateBrickCommandTest.java
index afcd327..b000e56 100644
--- 
a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/CreateBrickCommandTest.java
+++ 
b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/CreateBrickCommandTest.java
@@ -2,6 +2,8 @@
 
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.when;
@@ -15,6 +17,7 @@
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.runners.MockitoJUnitRunner;
+import org.ovirt.engine.core.bll.utils.GlusterUtil;
 import org.ovirt.engine.core.common.action.gluster.CreateBrickParameters;
 import org.ovirt.engine.core.common.businessentities.RaidType;
 import org.ovirt.engine.core.common.businessentities.VDS;
@@ -34,6 +37,9 @@
 
     @Mock
     private VDS vds;
+
+    @Mock
+    private GlusterUtil glusterUtil;
 
     @Mock
     private VDSGroup vdsGroup;
@@ -133,7 +139,11 @@
         doReturn(vds).when(command).getVds();
         doReturn(status).when(vds).getStatus();
         mockIsGlusterEnabled(true);
+        mockCompatibilityVersion(Version.v3_4);
         mockCompatibilityVersion(Version.v3_5);
+        doReturn(glusterUtil).when(command).getGlusterUtil();
+        when(glusterUtil.isGlusterBrickProvisioningSupported(eq(Version.v3_5), 
any(Guid.class))).thenReturn(true);
+        when(glusterUtil.isGlusterBrickProvisioningSupported(eq(Version.v3_4), 
any(Guid.class))).thenReturn(false);
     }
 
     private void mockIsGlusterEnabled(boolean glusterService) {
diff --git 
a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/CreateGlusterVolumeGeoRepSessionCommandTest.java
 
b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/CreateGlusterVolumeGeoRepSessionCommandTest.java
index 160be16..c6073d5 100644
--- 
a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/CreateGlusterVolumeGeoRepSessionCommandTest.java
+++ 
b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/CreateGlusterVolumeGeoRepSessionCommandTest.java
@@ -2,8 +2,10 @@
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
 import static org.ovirt.engine.core.utils.MockConfigRule.mockConfig;
 
 import org.junit.ClassRule;
@@ -11,6 +13,7 @@
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.runners.MockitoJUnitRunner;
+import org.ovirt.engine.core.bll.utils.GlusterUtil;
 import 
org.ovirt.engine.core.common.action.gluster.GlusterVolumeGeoRepSessionParameters;
 import org.ovirt.engine.core.common.businessentities.VDS;
 import org.ovirt.engine.core.common.businessentities.VDSGroup;
@@ -31,7 +34,7 @@
 public class CreateGlusterVolumeGeoRepSessionCommandTest {
     private static final Version NOT_SUPPORTED_VERSION = Version.v3_4;
 
-    private static final Object SUPPORTED_VERSION = Version.v3_5;
+    private static final Version SUPPORTED_VERSION = Version.v3_5;
 
     CreateGlusterVolumeGeoRepSessionCommand command;
 
@@ -59,6 +62,9 @@
 
     @Mock
     protected VDSGroup vdsGroup;
+
+    @Mock
+    private GlusterUtil glusterUtil;
 
     @Mock
     protected GlusterVolumeEntity volume;
@@ -93,6 +99,9 @@
         doReturn(geoRepDao).when(command).getGeoRepDao();
         doReturn(vds).when(command).getUpServer();
         doReturn(VDSStatus.Up).when(vds).getStatus();
+        doReturn(glusterUtil).when(command).getGlusterUtil();
+        
when(glusterUtil.isGlusterGeoReplicationSupported(eq(SUPPORTED_VERSION), 
any(Guid.class))).thenReturn(true);
+        
when(glusterUtil.isGlusterGeoReplicationSupported(eq(NOT_SUPPORTED_VERSION), 
any(Guid.class))).thenReturn(false);
     }
 
     @Test
diff --git 
a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/GlusterGeoRepSyncJobTest.java
 
b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/GlusterGeoRepSyncJobTest.java
index d1f94cc..a027cde 100644
--- 
a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/GlusterGeoRepSyncJobTest.java
+++ 
b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/GlusterGeoRepSyncJobTest.java
@@ -4,6 +4,7 @@
 import static org.mockito.Matchers.eq;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.when;
 import static org.ovirt.engine.core.utils.MockConfigRule.mockConfig;
 
 import java.util.ArrayList;
@@ -18,6 +19,7 @@
 import org.mockito.MockitoAnnotations;
 import org.mockito.runners.MockitoJUnitRunner;
 import org.ovirt.engine.core.bll.utils.ClusterUtils;
+import org.ovirt.engine.core.bll.utils.GlusterUtil;
 import org.ovirt.engine.core.common.businessentities.VDS;
 import org.ovirt.engine.core.common.businessentities.VDSGroup;
 import 
org.ovirt.engine.core.common.businessentities.gluster.GeoRepSessionStatus;
@@ -51,6 +53,9 @@
 
     @Mock
     private ClusterUtils clusterUtils;
+
+    @Mock
+    private GlusterUtil glusterUtil;
 
     @Mock
     private VdsGroupDAO clusterDao;
@@ -89,6 +94,9 @@
         doReturn(getVolume()).when(volumeDao).getByName(any(Guid.class), 
any(String.class));
         doReturn(getVolume()).when(volumeDao).getById(any(Guid.class));
         
doReturn(getServer()).when(clusterUtils).getRandomUpServer(any(Guid.class));
+        doReturn(glusterUtil).when(syncJob).getGlusterUtil();
+        when(glusterUtil.isGlusterGeoReplicationSupported(eq(Version.v3_5), 
any(Guid.class))).thenReturn(true);
+        when(glusterUtil.isGlusterGeoReplicationSupported(eq(Version.v3_4), 
any(Guid.class))).thenReturn(false);
         
doReturn(getMockLock()).when(syncJob).acquireGeoRepSessionLock(any(Guid.class));
         doReturn(getSessions(2, 
true)).when(geoRepDao).getGeoRepSessionsInCluster(CLUSTER_GUIDS[1]);
     }
diff --git 
a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/GlusterSnapshotSyncJobTest.java
 
b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/GlusterSnapshotSyncJobTest.java
index 3489c53c..fb26e54 100644
--- 
a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/GlusterSnapshotSyncJobTest.java
+++ 
b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/GlusterSnapshotSyncJobTest.java
@@ -6,6 +6,7 @@
 import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.when;
 import static org.ovirt.engine.core.utils.MockConfigRule.mockConfig;
 
 import java.util.ArrayList;
@@ -118,7 +119,8 @@
         doReturn(getVolume(CLUSTER_ID_1, VOLUME_ID_1, 
VOLUME_NAME_1)).when(volumeDao)
                 .getByName(argThat(validClusterId()), 
argThat(validVolumeName()));
         
doReturn(getServer()).when(clusterUtils).getRandomUpServer(any(Guid.class));
-
+        when(glusterUtil.isGlusterSnapshotSupported(eq(Version.v3_4), 
any(Guid.class))).thenReturn(false);
+        when(glusterUtil.isGlusterSnapshotSupported(eq(Version.v3_5), 
any(Guid.class))).thenReturn(true);
         
doReturn(engineLock).when(syncJob).acquireVolumeSnapshotLock(any(Guid.class));
         
doNothing().when(glusterUtil).alertVolumeSnapshotSoftLimitReached(any(GlusterVolumeEntity.class));
         
doNothing().when(glusterUtil).checkAndRemoveVolumeSnapshotSoftLimitAlert(any(GlusterVolumeEntity.class));
diff --git 
a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/StorageDeviceSyncJobTest.java
 
b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/StorageDeviceSyncJobTest.java
index 32e38b2..4b705e0 100644
--- 
a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/StorageDeviceSyncJobTest.java
+++ 
b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/StorageDeviceSyncJobTest.java
@@ -5,6 +5,7 @@
 import static org.mockito.Matchers.eq;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.when;
 import static org.ovirt.engine.core.utils.MockConfigRule.mockConfig;
 
 import java.util.ArrayList;
@@ -23,6 +24,7 @@
 import org.mockito.Spy;
 import org.mockito.runners.MockitoJUnitRunner;
 import org.ovirt.engine.core.bll.utils.ClusterUtils;
+import org.ovirt.engine.core.bll.utils.GlusterUtil;
 import org.ovirt.engine.core.common.businessentities.VDS;
 import org.ovirt.engine.core.common.businessentities.VDSGroup;
 import org.ovirt.engine.core.common.businessentities.gluster.StorageDevice;
@@ -59,6 +61,9 @@
     private ClusterUtils clusterUtils;
 
     @Mock
+    private GlusterUtil glusterUtil;
+
+    @Mock
     private VdsGroupDAO clusterDao;
 
     @Mock
@@ -69,6 +74,7 @@
 
     @Mock
     private GlusterAuditLogUtil logUtil;
+
     @ClassRule
     public static MockConfigRule mcr = new MockConfigRule(
             mockConfig(ConfigValues.GlusterBrickProvisioningEnabled, 
Version.v3_5.toString(), true),
@@ -85,9 +91,12 @@
         doReturn(storageDeviceDao).when(syncJob).getStorageDeviceDao();
         doReturn(clusterDao).when(syncJob).getClusterDao();
         doReturn(clusterUtils).when(syncJob).getClusterUtils();
+        doReturn(glusterUtil).when(syncJob).getGlusterUtil();
         doReturn(getClusters()).when(clusterDao).getAll();
         doReturn(vdsDao).when(syncJob).getVdsDao();
         
doReturn(getAllUpServers()).when(clusterUtils).getAllUpServers(CLUSTER_GUID_3_6);
+        when(glusterUtil.isGlusterBrickProvisioningSupported(eq(Version.v3_4), 
eq(CLUSTER_GUID_3_5))).thenReturn(false);
+        when(glusterUtil.isGlusterBrickProvisioningSupported(eq(Version.v3_5), 
eq(CLUSTER_GUID_3_6))).thenReturn(true);
         
doReturn(getStorageDevices(HOST_ID_WITH_NEW_DEVICES)).when(storageDeviceDao)
                 .getStorageDevicesInHost(HOST_ID_WITH_NEW_DEVICES);
         
doReturn(getStorageDevices(HOST_ID_WITH_DEVICES_CHANGED)).when(storageDeviceDao)
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/gluster/GlusterFeatureSupported.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/gluster/GlusterFeatureSupported.java
index be73278..7c1897d 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/gluster/GlusterFeatureSupported.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/gluster/GlusterFeatureSupported.java
@@ -81,38 +81,6 @@
         }
     }
 
-    /**
-    *
-    * @param version
-    *            Compatibility version to check for.
-    * @return <code>true</code> if gluster geo-replication management feature 
is enabled,
-    *         <code>false</code> if it's not.
-    */
-   public static boolean glusterGeoReplication(Version version) {
-       return supportedInConfig(ConfigValues.GlusterGeoReplicationEnabled, 
version);
-   }
-
-  /**
-   * @param version
-   *            Compatibility version to check for.
-   * @return <code>true</code> if gluster snapshot management feature is 
enabled,
-   *         <code>false</code> if it's not.
-   */
-  public static boolean glusterSnapshot(Version version) {
-      return supportedInConfig(ConfigValues.GlusterVolumeSnapshotSupported, 
version);
-  }
-
-   /**
-   *
-   * @param version
-   *            Compatibility version to check for.
-   * @return <code>true</code> if disk provisioning feature is enabled,
-   *         <code>false</code> if it's not.
-   */
-  public static boolean glusterBrickProvisioning(Version version) {
-        return supportedInConfig(ConfigValues.GlusterBrickProvisioningEnabled, 
version);
-  }
-
   /**
   *
   * @param version


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9074a500caa1b5a30cea19e9fa4420e12d3fa6a1
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.5-gluster
Gerrit-Owner: Ramesh N <rnach...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to