anmolbabu has uploaded a new change for review.

Change subject: engine, webadmin: Check volume emptyness for geo-rep
......................................................................

engine, webadmin: Check volume emptyness for geo-rep

This patch adds VDS command to check emptyness
of gluster volume.
And also adds a predicate in the GlusterGeoRepUtil
to check the same while filtering the volumes
list to get list of volumes eligible for geo-rep
session create.
This patch also adds a UIMessage entry corresponding
to the new volume emptyness criteria.
Change-Id: Ia86df17975069d4fe7c1740bf609597fde7b08ac
Signed-off-by: Anmol Babu <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/utils/GlusterGeoRepUtil.java
M 
backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/GetGlusterGeoReplicationEligibleVolumesQueryTest.java
M 
backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/GetNonEligibilityReasonsOfVolumeForGeoRepSessionQueryTest.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/GlusterGeoRepNonEligibilityReason.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllErrors.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/VDSCommandType.java
M backend/manager/modules/dal/src/main/resources/bundles/VdsmErrors.properties
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/AbstractGlusterBrokerCommand.java
A 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/CheckEmptyGlusterVolumeVDSCommand.java
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/jsonrpc/JsonRpcVdsServer.java
A 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/BooleanReturnForXmlRpc.java
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/IVdsServer.java
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsServerConnector.java
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsServerWrapper.java
M 
frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/VdsmErrors.java
M 
frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIMessages.java
16 files changed, 158 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/91/40591/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/utils/GlusterGeoRepUtil.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/utils/GlusterGeoRepUtil.java
index 8b80097..7aef299 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/utils/GlusterGeoRepUtil.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/utils/GlusterGeoRepUtil.java
@@ -7,10 +7,15 @@
 
 import javax.inject.Singleton;
 
+import org.ovirt.engine.core.bll.Backend;
+import org.ovirt.engine.core.common.businessentities.VDS;
 import 
org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepNonEligibilityReason;
 import 
org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession;
 import org.ovirt.engine.core.common.businessentities.gluster.GlusterStatus;
 import 
org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity;
+import org.ovirt.engine.core.common.vdscommands.VDSCommandType;
+import org.ovirt.engine.core.common.vdscommands.VDSReturnValue;
+import 
org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeVDSParameters;
 import org.ovirt.engine.core.compat.Guid;
 import org.ovirt.engine.core.compat.Version;
 import org.ovirt.engine.core.dal.dbbroker.DbFacade;
@@ -85,6 +90,29 @@
             }
         });
 
+        
eligibilityPredicates.put(GlusterGeoRepNonEligibilityReason.NO_UP_SLAVE_SERVER,
+                new Predicate<GlusterVolumeEntity>() {
+                    @Override
+                    public boolean eval(GlusterVolumeEntity slaveVolume) {
+                        Guid slaveUpserverId = 
getUpServerId(slaveVolume.getClusterId());
+                        if (slaveUpserverId == null) {
+                            return false;
+                        }
+                        return true;
+                    }
+                });
+
+        
eligibilityPredicates.put(GlusterGeoRepNonEligibilityReason.SLAVE_VOLUME_TO_BE_EMPTY,
+                new Predicate<GlusterVolumeEntity>() {
+                    @Override
+                    public boolean eval(GlusterVolumeEntity slaveVolume) {
+                        Guid slaveUpserverId = 
getUpServerId(slaveVolume.getClusterId());
+                        if(slaveUpserverId == null) {
+                            return false;
+                        }
+                        return checkEmptyGlusterVolume(slaveUpserverId, 
slaveVolume.getName());
+                    }
+                });
 
         return eligibilityPredicates;
     }
@@ -98,6 +126,23 @@
         return sessionSlavesIds;
     }
 
+    public boolean checkEmptyGlusterVolume(Guid slaveUpserverId, String 
slaveVolumeName) {
+        VDSReturnValue returnValue =
+                Backend.getInstance()
+                        .getResourceManager()
+                        .RunVdsCommand(VDSCommandType.CheckEmptyGlusterVolume,
+                                new 
GlusterVolumeVDSParameters(slaveUpserverId, slaveVolumeName));
+        if (!returnValue.getSucceeded()) {
+            return false;
+        }
+        return (boolean) returnValue.getReturnValue();
+    }
+
+    public Guid getUpServerId(Guid clusterId) {
+        VDS randomUpServer = 
ClusterUtils.getInstance().getRandomUpServer(clusterId);
+        return randomUpServer == null ? null : randomUpServer.getId();
+    }
+
     public VdsGroupDAO getVdsGroupDao() {
         return DbFacade.getInstance().getVdsGroupDao();
     }
diff --git 
a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/GetGlusterGeoReplicationEligibleVolumesQueryTest.java
 
b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/GetGlusterGeoReplicationEligibleVolumesQueryTest.java
index 09d1fd2..15f91c6 100644
--- 
a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/GetGlusterGeoReplicationEligibleVolumesQueryTest.java
+++ 
b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/GetGlusterGeoReplicationEligibleVolumesQueryTest.java
@@ -57,7 +57,7 @@
     private List<GlusterVolumeEntity> getVolumesByClusterId() {
         List<GlusterVolumeEntity> volumeInCluster = new 
ArrayList<GlusterVolumeEntity>();
 
-        
volumeInCluster.add(baseTest.getGlusterVolume(baseTest.getSLAVE_VOLUME_1_ID(), 
baseTest.getSLAVE_CLUSTER_ID(), GlusterStatus.UP, new 
GlusterVolumeSizeInfo(10000L, 4000L, 6000L)));
+        
volumeInCluster.add(baseTest.getGlusterVolume(baseTest.getSLAVE_VOLUME_1_ID(), 
baseTest.getSLAVE_CLUSTER_ID(), GlusterStatus.UP, new 
GlusterVolumeSizeInfo(10000L, 10000L, 0L)));
         
volumeInCluster.add(baseTest.getGlusterVolume(baseTest.getSLAVE_VOLUME_2_ID(), 
baseTest.getSLAVE_CLUSTER_ID(), GlusterStatus.DOWN, new 
GlusterVolumeSizeInfo(4000L, 0L, 0L)));
         
volumeInCluster.add(baseTest.getGlusterVolume(baseTest.getSLAVE_VOLUME_3_ID(), 
baseTest.getMASTER_CLUSTER_ID(), GlusterStatus.UP, new 
GlusterVolumeSizeInfo(10000L, 4000L, 6000L)));
         
volumeInCluster.add(baseTest.getGlusterVolume(baseTest.getSLAVE_VOLUME_4_ID(), 
baseTest.getSLAVE_CLUSTER_ID(), GlusterStatus.UP, null));
@@ -76,7 +76,7 @@
     }
 
     private List<GlusterVolumeEntity> getExpectedVolumes() {
-        return 
Collections.singletonList(baseTest.getGlusterVolume(baseTest.getSLAVE_VOLUME_1_ID(),
 baseTest.getSLAVE_CLUSTER_ID(), GlusterStatus.UP, new 
GlusterVolumeSizeInfo(10000L, 4000L, 6000L)));
+        return 
Collections.singletonList(baseTest.getGlusterVolume(baseTest.getSLAVE_VOLUME_1_ID(),
 baseTest.getSLAVE_CLUSTER_ID(), GlusterStatus.UP, new 
GlusterVolumeSizeInfo(10000L, 10000L, 0L)));
     }
 
     private boolean checkEquals(List<GlusterVolumeEntity> actual, 
List<GlusterVolumeEntity> expected) {
diff --git 
a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/GetNonEligibilityReasonsOfVolumeForGeoRepSessionQueryTest.java
 
b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/GetNonEligibilityReasonsOfVolumeForGeoRepSessionQueryTest.java
index d95ab5b..64f2c0b 100644
--- 
a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/GetNonEligibilityReasonsOfVolumeForGeoRepSessionQueryTest.java
+++ 
b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/GetNonEligibilityReasonsOfVolumeForGeoRepSessionQueryTest.java
@@ -6,6 +6,8 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import static org.mockito.Matchers.any;
+
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -16,8 +18,10 @@
 import org.ovirt.engine.core.bll.utils.GlusterGeoRepUtil;
 import 
org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepNonEligibilityReason;
 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.GlusterVolumeSizeInfo;
 import 
org.ovirt.engine.core.common.queries.gluster.GlusterVolumeGeoRepEligibilityParameters;
+import org.ovirt.engine.core.compat.Guid;
 import org.ovirt.engine.core.dao.VdsGroupDAO;
 import org.ovirt.engine.core.dao.gluster.GlusterGeoRepDao;
 
@@ -53,6 +57,7 @@
         
nonEligibilityreasons.add(GlusterGeoRepNonEligibilityReason.SLAVE_VOLUME_SHOULD_BE_UP);
         
nonEligibilityreasons.add(GlusterGeoRepNonEligibilityReason.SLAVE_VOLUME_SIZE_SHOULD_BE_GREATER_THAN_MASTER_VOLUME_SIZE);
         
nonEligibilityreasons.add(GlusterGeoRepNonEligibilityReason.SLAVE_VOLUME_SHOULD_NOT_BE_SLAVE_OF_ANOTHER_GEO_REP_SESSION);
+        
nonEligibilityreasons.add(GlusterGeoRepNonEligibilityReason.SLAVE_VOLUME_TO_BE_EMPTY);
 
         return nonEligibilityreasons;
     }
@@ -71,33 +76,48 @@
         
nonEligibilityreasons.add(GlusterGeoRepNonEligibilityReason.SLAVE_VOLUME_SIZE_TO_BE_AVAILABLE);
         
nonEligibilityreasons.add(GlusterGeoRepNonEligibilityReason.MASTER_VOLUME_SIZE_TO_BE_AVAILABLE);
         
nonEligibilityreasons.add(GlusterGeoRepNonEligibilityReason.SLAVE_VOLUME_SIZE_SHOULD_BE_GREATER_THAN_MASTER_VOLUME_SIZE);
+        
nonEligibilityreasons.add(GlusterGeoRepNonEligibilityReason.NO_UP_SLAVE_SERVER);
+        
nonEligibilityreasons.add(GlusterGeoRepNonEligibilityReason.SLAVE_VOLUME_TO_BE_EMPTY);
 
         return nonEligibilityreasons;
     }
 
     @Test
     public void testExecuteQueryCommnadOnVolume1() {
-        List<GlusterGeoRepNonEligibilityReason> actualNonEligibilityReasons = 
getQuery().getNonEligibilityReasons(baseTest.getGlusterVolume(baseTest.getMASTER_VOLUME_ID(),
 baseTest.getMASTER_CLUSTER_ID(), GlusterStatus.UP, new 
GlusterVolumeSizeInfo(10000L, 4000L, 6000L)), 
baseTest.getGlusterVolume(baseTest.getSLAVE_VOLUME_1_ID(), 
baseTest.getSLAVE_CLUSTER_ID(), GlusterStatus.UP, new 
GlusterVolumeSizeInfo(10000L, 4000L, 6000L)));
+        GlusterVolumeEntity slaveVolume = 
baseTest.getGlusterVolume(baseTest.getSLAVE_VOLUME_1_ID(), 
baseTest.getSLAVE_CLUSTER_ID(), GlusterStatus.UP, new 
GlusterVolumeSizeInfo(10000L, 4000L, 6000L));
+        Guid slaveUpServerId = Guid.newGuid();
+        
doReturn(slaveUpServerId).when(geoRepUtil).getUpServerId(any(Guid.class));
+        
doReturn(true).when(geoRepUtil).checkEmptyGlusterVolume(slaveUpServerId, 
slaveVolume.getName());
+        List<GlusterGeoRepNonEligibilityReason> actualNonEligibilityReasons = 
getQuery().getNonEligibilityReasons(baseTest.getGlusterVolume(baseTest.getMASTER_VOLUME_ID(),
 baseTest.getMASTER_CLUSTER_ID(), GlusterStatus.UP, new 
GlusterVolumeSizeInfo(10000L, 4000L, 6000L)), slaveVolume);
         assertTrue(actualNonEligibilityReasons.size() == 
getNonEligibilityReasonsForSlaveVolume1().size());
         
assertTrue(getNonEligibilityReasonsForSlaveVolume1().equals(actualNonEligibilityReasons));
     }
 
     @Test
     public void testExecuteQueryCommnadOnVolume2() {
-        List<GlusterGeoRepNonEligibilityReason> actual = 
getQuery().getNonEligibilityReasons(baseTest.getGlusterVolume(baseTest.getMASTER_VOLUME_ID(),
 baseTest.getMASTER_CLUSTER_ID(), GlusterStatus.UP, new 
GlusterVolumeSizeInfo(10000L, 4000L, 6000L)), 
baseTest.getGlusterVolume(baseTest.getSLAVE_VOLUME_2_ID(), 
baseTest.getSLAVE_CLUSTER_ID(), GlusterStatus.DOWN, new 
GlusterVolumeSizeInfo(4000L, 0L, 0L)));
+        GlusterVolumeEntity slaveVolume = 
baseTest.getGlusterVolume(baseTest.getSLAVE_VOLUME_2_ID(), 
baseTest.getSLAVE_CLUSTER_ID(), GlusterStatus.DOWN, new 
GlusterVolumeSizeInfo(4000L, 0L, 0L));
+        Guid slaveUpServerID = Guid.newGuid();
+        
doReturn(slaveUpServerID).when(geoRepUtil).getUpServerId(any(Guid.class));
+        
doReturn(false).when(geoRepUtil).checkEmptyGlusterVolume(slaveUpServerID, 
slaveVolume.getName());
+        List<GlusterGeoRepNonEligibilityReason> actual = 
getQuery().getNonEligibilityReasons(baseTest.getGlusterVolume(baseTest.getMASTER_VOLUME_ID(),
 baseTest.getMASTER_CLUSTER_ID(), GlusterStatus.UP, new 
GlusterVolumeSizeInfo(10000L, 4000L, 6000L)), slaveVolume);
         assertTrue(actual.size() == 
getNonEligibilityReasonsForSlaveVolume2().size());
         
assertTrue(getNonEligibilityReasonsForSlaveVolume2().containsAll(actual));
     }
 
     @Test
     public void testExecuteQueryCommnadOnVolume3() {
-        List<GlusterGeoRepNonEligibilityReason> actual = 
getQuery().getNonEligibilityReasons(baseTest.getGlusterVolume(baseTest.getMASTER_VOLUME_ID(),
 baseTest.getMASTER_CLUSTER_ID(), GlusterStatus.UP, new 
GlusterVolumeSizeInfo(10000L, 4000L, 6000L)), 
baseTest.getGlusterVolume(baseTest.getSLAVE_VOLUME_3_ID(), 
baseTest.getMASTER_CLUSTER_ID(), GlusterStatus.UP, new 
GlusterVolumeSizeInfo(10000L, 4000L, 6000L)));
+        GlusterVolumeEntity slaveVolume = 
baseTest.getGlusterVolume(baseTest.getSLAVE_VOLUME_3_ID(), 
baseTest.getMASTER_CLUSTER_ID(), GlusterStatus.UP, new 
GlusterVolumeSizeInfo(10000L, 4000L, 6000L));
+        Guid slaveUpServerId = Guid.newGuid();
+        
doReturn(slaveUpServerId).when(geoRepUtil).getUpServerId(any(Guid.class));
+        
doReturn(true).when(geoRepUtil).checkEmptyGlusterVolume(slaveUpServerId, 
slaveVolume.getName());
+        List<GlusterGeoRepNonEligibilityReason> actual = 
getQuery().getNonEligibilityReasons(baseTest.getGlusterVolume(baseTest.getMASTER_VOLUME_ID(),
 baseTest.getMASTER_CLUSTER_ID(), GlusterStatus.UP, new 
GlusterVolumeSizeInfo(10000L, 4000L, 6000L)), slaveVolume);
         assertTrue(actual.size() == 
getNonEligibilityReasonsForSlaveVolume3().size());
         
assertTrue(getNonEligibilityReasonsForSlaveVolume3().containsAll(actual));
     }
 
     @Test
     public void testExecuteQueryCommnadOnVolume4() {
+        doReturn(null).when(geoRepUtil).getUpServerId(any(Guid.class));
         List<GlusterGeoRepNonEligibilityReason> actual = 
getQuery().getNonEligibilityReasons(baseTest.getGlusterVolume(baseTest.getMASTER_VOLUME_ID(),
 baseTest.getMASTER_CLUSTER_ID(), GlusterStatus.UP, null), 
baseTest.getGlusterVolume(baseTest.getSLAVE_VOLUME_4_ID(), 
baseTest.getSLAVE_CLUSTER_ID(), GlusterStatus.UP, null));
         assertTrue(actual.size() == 
getNonEligibilityReasonsForSlaveVolume4().size());
         
assertTrue(getNonEligibilityReasonsForSlaveVolume4().containsAll(actual));
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/GlusterGeoRepNonEligibilityReason.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/GlusterGeoRepNonEligibilityReason.java
index b9de0b9..e3744d1 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/GlusterGeoRepNonEligibilityReason.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/GlusterGeoRepNonEligibilityReason.java
@@ -7,5 +7,7 @@
         SLAVE_VOLUME_SHOULD_NOT_BE_SLAVE_OF_ANOTHER_GEO_REP_SESSION,
         SLAVE_VOLUME_SHOULD_BE_UP,
         SLAVE_VOLUME_SIZE_TO_BE_AVAILABLE,
+        SLAVE_VOLUME_TO_BE_EMPTY,
+        NO_UP_SLAVE_SERVER,
         MASTER_VOLUME_SIZE_TO_BE_AVAILABLE;
 }
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllErrors.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllErrors.java
index 8f4c333..3a005c6 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllErrors.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllErrors.java
@@ -424,6 +424,7 @@
     GlfsStatvfsException(4571),
     GlfsInitException(4572),
     GlfsFiniException(4573),
+    GlusterVolumeEmptyCheckFailed(4574),
     GlusterGeoRepSessionDeleteFailedException(4594),
     GlusterVolumeGeoRepStatusDetailFailed(4600),
     GlusterVolumeGeoRepSyncFailed(4601),
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/VDSCommandType.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/VDSCommandType.java
index e71ff8f..370e0d4 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/VDSCommandType.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/VDSCommandType.java
@@ -135,6 +135,7 @@
     StartRebalanceGlusterVolume("org.ovirt.engine.core.vdsbroker.gluster"),
     StopRebalanceGlusterVolume("org.ovirt.engine.core.vdsbroker.gluster"),
     SetupGlusterGeoRepMountBroker("org.ovirt.engine.core.vdsbroker.gluster"),
+    CheckEmptyGlusterVolume("org.ovirt.engine.core.vdsbroker.gluster"),
     GetGlusterHostsPubKey("org.ovirt.engine.core.vdsbroker.gluster"),
     UpdateGlusterGeoRepKeys("org.ovirt.engine.core.vdsbroker.gluster"),
     
CreateGlusterVolumeGeoRepSession("org.ovirt.engine.core.vdsbroker.gluster"),
diff --git 
a/backend/manager/modules/dal/src/main/resources/bundles/VdsmErrors.properties 
b/backend/manager/modules/dal/src/main/resources/bundles/VdsmErrors.properties
index 0bced23..171cd2d 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/VdsmErrors.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/VdsmErrors.properties
@@ -337,6 +337,7 @@
 GlusterVolumeSetOptionFailed=Gluster Volume Set Option Failed
 GlusterVolumeRebalanceStartFailed=Gluster Volume Rebalance Start Failed
 GlusterVolumeRebalanceStopFailed=Gluster Volume Rebalance Stop Failed
+GlusterVolumeEmptyCheckFailed=Failed to check if gluster volume is empty
 GlusterVolumeGeoRepSessionStartFailed=Failed to start geo-replication session 
for volume
 GlusterVolumeGeoRepSessionResumeFailed=Volume Geo-Replication Resume Failed
 GlusterGeoRepException=Gluster Geo-Replication Exception
diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/AbstractGlusterBrokerCommand.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/AbstractGlusterBrokerCommand.java
index 3635ab8..bcf3cd7 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/AbstractGlusterBrokerCommand.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/AbstractGlusterBrokerCommand.java
@@ -63,6 +63,7 @@
         case GlusterVolumeRebalanceStopFailed:
         case GlusterVolumeStatusAllFailedException:
         case GlusterVolumeRebalanceStatusFailedException:
+        case GlusterVolumeEmptyCheckFailed:
         case GlusterGeoRepPublicKeyFileCreateFailed:
         case GlusterGeoRepPublicKeyFileReadError:
         case GlusterGeoRepUserNotFound:
diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/CheckEmptyGlusterVolumeVDSCommand.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/CheckEmptyGlusterVolumeVDSCommand.java
new file mode 100644
index 0000000..6d76d79
--- /dev/null
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/CheckEmptyGlusterVolumeVDSCommand.java
@@ -0,0 +1,28 @@
+package org.ovirt.engine.core.vdsbroker.gluster;
+
+import 
org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeVDSParameters;
+import org.ovirt.engine.core.vdsbroker.vdsbroker.BooleanReturnForXmlRpc;
+import org.ovirt.engine.core.vdsbroker.vdsbroker.StatusForXmlRpc;
+
+public class CheckEmptyGlusterVolumeVDSCommand<P extends 
GlusterVolumeVDSParameters> extends AbstractGlusterBrokerCommand<P> {
+
+    private BooleanReturnForXmlRpc returnValue;
+
+    public CheckEmptyGlusterVolumeVDSCommand(P parameters) {
+        super(parameters);
+    }
+
+    @Override
+    protected StatusForXmlRpc getReturnStatus() {
+        return returnValue.mStatus;
+    }
+
+    @Override
+    protected void executeVdsBrokerCommand() {
+        String volumeName = getParameters().getVolumeName();
+        returnValue = getBroker().glusterVolumeEmptyCheck(volumeName);
+        proceedProxyReturnValue();
+        setReturnValue(returnValue.isVolumeEmpty());
+    }
+
+}
diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/jsonrpc/JsonRpcVdsServer.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/jsonrpc/JsonRpcVdsServer.java
index 0cba62c..841bc0f 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/jsonrpc/JsonRpcVdsServer.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/jsonrpc/JsonRpcVdsServer.java
@@ -37,6 +37,7 @@
 import org.ovirt.engine.core.vdsbroker.irsbroker.OneUuidReturnForXmlRpc;
 import 
org.ovirt.engine.core.vdsbroker.irsbroker.StoragePoolInfoReturnForXmlRpc;
 import org.ovirt.engine.core.vdsbroker.vdsbroker.AlignmentScanReturnForXmlRpc;
+import org.ovirt.engine.core.vdsbroker.vdsbroker.BooleanReturnForXmlRpc;
 import 
org.ovirt.engine.core.vdsbroker.vdsbroker.DevicesVisibilityMapReturnForXmlRpc;
 import org.ovirt.engine.core.vdsbroker.vdsbroker.FenceStatusReturnForXmlRpc;
 import org.ovirt.engine.core.vdsbroker.vdsbroker.IQNListReturnForXmlRpc;
@@ -1185,6 +1186,13 @@
     }
 
     @Override
+    public BooleanReturnForXmlRpc glusterVolumeEmptyCheck(String volumeName) {
+        JsonRpcRequest request = new 
RequestBuilder("GlusterVolume.volumeEmptyCheck").withParameter("volumeName", 
volumeName).build();
+        Map<String, Object> response = new FutureMap(this.client, request);
+        return new BooleanReturnForXmlRpc(response, "volumeEmptyCheck");
+    }
+
+    @Override
     public GlusterHostsPubKeyReturnForXmlRpc glusterGeoRepKeysGet() {
         JsonRpcRequest request = new 
RequestBuilder("GlusterVolume.geoRepKeysGet").build();
         Map<String, Object> response = new FutureMap(this.client, request);
diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/BooleanReturnForXmlRpc.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/BooleanReturnForXmlRpc.java
new file mode 100644
index 0000000..f853c78
--- /dev/null
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/BooleanReturnForXmlRpc.java
@@ -0,0 +1,25 @@
+package org.ovirt.engine.core.vdsbroker.vdsbroker;
+
+import java.util.Map;
+
+import org.ovirt.engine.core.vdsbroker.irsbroker.StatusReturnForXmlRpc;
+
+public class BooleanReturnForXmlRpc extends StatusReturnForXmlRpc {
+
+    private static final String INFO = "info";
+    private boolean isEmpty;
+
+    public BooleanReturnForXmlRpc(Map<String, Object> innerMap, String 
flagName) {
+        super(innerMap);
+        if (innerMap.containsKey(INFO)) {
+            innerMap = (Map<String, Object>) innerMap.get(INFO);
+        }
+        if (innerMap.containsKey(flagName)) {
+            isEmpty = (boolean) innerMap.get(flagName);
+        }
+    }
+
+    public boolean isVolumeEmpty() {
+        return isEmpty;
+    }
+}
diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/IVdsServer.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/IVdsServer.java
index c012329..66544d4 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/IVdsServer.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/IVdsServer.java
@@ -317,6 +317,8 @@
 
     GlusterVolumeTaskReturnForXmlRpc glusterVolumeRebalanceStatus(String 
volumeName);
 
+    BooleanReturnForXmlRpc glusterVolumeEmptyCheck(String volumeName);
+
     GlusterHostsPubKeyReturnForXmlRpc glusterGeoRepKeysGet();
 
     StatusOnlyReturnForXmlRpc glusterGeoRepKeysUpdate(List<String> 
geoRepPubKeys, String userName);
diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsServerConnector.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsServerConnector.java
index 91eb739..aa4d50f 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsServerConnector.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsServerConnector.java
@@ -290,6 +290,8 @@
 
     public Map<String, Object> glusterVolumeRebalanceStatus(String volumeName);
 
+    public Map<String, Object> glusterVolumeEmptyCheck(String volumeName);
+
     public Map<String, Object> glusterGeoRepKeysGet();
 
     public Map<String, Object> glusterGeoRepKeysUpdate(String userName, 
List<String> geoRepPubKeys);
diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsServerWrapper.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsServerWrapper.java
index a4ab037..3a527fe 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsServerWrapper.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsServerWrapper.java
@@ -1111,6 +1111,17 @@
     }
 
     @Override
+    public BooleanReturnForXmlRpc glusterVolumeEmptyCheck(String volumeName) {
+        try {
+            Map<String, Object> xmlRpcReturnValue = 
vdsServer.glusterVolumeEmptyCheck(volumeName);
+            BooleanReturnForXmlRpc wrapper = new 
BooleanReturnForXmlRpc(xmlRpcReturnValue, "volumeEmptyCheck");
+            return wrapper;
+        } catch (UndeclaredThrowableException ute) {
+            throw new XmlRpcRunTimeException(ute);
+        }
+    }
+
+    @Override
     public GlusterHostsPubKeyReturnForXmlRpc glusterGeoRepKeysGet() {
         try {
             Map<String, Object> xmlRpcReturnValue = 
vdsServer.glusterGeoRepKeysGet();
diff --git 
a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/VdsmErrors.java
 
b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/VdsmErrors.java
index f440d0a..d0c4e56 100644
--- 
a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/VdsmErrors.java
+++ 
b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/VdsmErrors.java
@@ -721,6 +721,9 @@
     @DefaultStringValue("Gluster Volume Rebalance Start Failed.")
     String GlusterVolumeRebalanceStartFailed();
 
+    @DefaultStringValue("Failed to check if gluster volume is empty")
+    String GlusterVolumeEmptyCheckFailed();
+
     @DefaultStringValue("Failed to create gluster host public key file.")
     String GlusterGeoRepPublicKeyFileCreateFailed();
 
diff --git 
a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIMessages.java
 
b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIMessages.java
index 2cca3c8..537f58d 100644
--- 
a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIMessages.java
+++ 
b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIMessages.java
@@ -465,7 +465,9 @@
         "SLAVE_VOLUME_SHOULD_NOT_BE_SLAVE_OF_ANOTHER_GEO_REP_SESSION", 
"Destination volume is already a part of another geo replication session.",
         "SLAVE_VOLUME_SHOULD_BE_UP", "Destination volume should be up.",
         "SLAVE_VOLUME_SIZE_TO_BE_AVAILABLE", "Capacity information of the 
destination volume is not available.",
-        "MASTER_VOLUME_SIZE_TO_BE_AVAILABLE", "Capacity information of the 
master volume is not available."
+        "MASTER_VOLUME_SIZE_TO_BE_AVAILABLE", "Capacity information of the 
master volume is not available.",
+        "SLAVE_VOLUME_TO_BE_EMPTY", "Destination volume should be empty.",
+        "NO_UP_SLAVE_SERVER", "No up server in the destination volume"
     })
     String geoRepEligibilityViolations(@Select 
GlusterGeoRepNonEligibilityReason reason);
 }


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

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

Reply via email to