Sahina Bose has uploaded a new change for review.

Change subject: engine: Fixed validation when moving host to gluster cluster
......................................................................

engine: Fixed validation when moving host to gluster cluster

When moving a host to a gluster cluster, the host can be
added to target cluster only if target cluster is empty
or if there's another up server in target cluster
to perform the gluster command to add to gluster cluster.

The current check was causing NPE while performing
the AddGlusterServer command when there's no up server.
Fixing this with this patch.

Change-Id: Id2f2fbbc5da529932da967fc67ea8b7e34459fbd
Bug-Url: https://bugzilla.redhat.com/976896
Signed-off-by: Sahina Bose <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ChangeVDSClusterCommand.java
1 file changed, 10 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/27/16027/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ChangeVDSClusterCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ChangeVDSClusterCommand.java
index de46a08..11da132 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ChangeVDSClusterCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ChangeVDSClusterCommand.java
@@ -12,11 +12,11 @@
 import org.ovirt.engine.core.common.action.ChangeVDSClusterParameters;
 import org.ovirt.engine.core.common.action.VdcActionType;
 import org.ovirt.engine.core.common.action.VdcReturnValueBase;
+import org.ovirt.engine.core.common.businessentities.StoragePool;
 import org.ovirt.engine.core.common.businessentities.StorageType;
 import org.ovirt.engine.core.common.businessentities.VDS;
 import org.ovirt.engine.core.common.businessentities.VDSGroup;
 import org.ovirt.engine.core.common.businessentities.VdsStatic;
-import org.ovirt.engine.core.common.businessentities.StoragePool;
 import org.ovirt.engine.core.common.errors.VdcBllMessages;
 import org.ovirt.engine.core.common.vdscommands.VDSCommandType;
 import org.ovirt.engine.core.common.vdscommands.VDSReturnValue;
@@ -82,19 +82,24 @@
                 return false;
             }
 
-            if (!hasUpServer(getSourceCluster())) {
+            if (!hasUpServer(getSourceCluster(), false)) {
                 return false;
             }
+
         }
 
-        if (getTargetCluster().supportsGlusterService() && 
!hasUpServer(getTargetCluster())) {
+        if (getTargetCluster().supportsGlusterService() && 
!hasUpServer(getTargetCluster(), true)) {
             return false;
         }
         return true;
     }
 
-    private boolean hasUpServer(VDSGroup cluster) {
-        if (getClusterUtils().hasMultipleServers(cluster.getId())
+    private boolean hasUpServer(VDSGroup cluster, boolean isTargetCluster) {
+        // if target cluster, need to check if cluster has other servers
+        // otherwise, cluster should have multiple servers
+        int serverCount = isTargetCluster? 0:1;
+
+        if (getClusterUtils().getServerCount(cluster.getId()) > serverCount
                 && getClusterUtils().getUpServer(cluster.getId()) == null) {
             addCanDoActionMessage(String.format("$clusterName %1$s", 
cluster.getname()));
             
addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_NO_UP_SERVER_FOUND);


-- 
To view, visit http://gerrit.ovirt.org/16027
To unsubscribe, visit http://gerrit.ovirt.org/settings

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

Reply via email to