CLOUDSTACK-1381
Fixed inconsistency in cluster limit check for Vmware clusters.
While adding a new Vmware cluster limit check done correctly but while adding a 
host to an existing cluster there was an issue with limit check.


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/c502b467
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/c502b467
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/c502b467

Branch: refs/heads/qemu-img
Commit: c502b4670328b6b950630e84b4a7d3fd4bcb96ca
Parents: 3e4430d
Author: Koushik Das <koushik....@citrix.com>
Authored: Thu Mar 28 17:26:12 2013 +0530
Committer: Koushik Das <koushik....@citrix.com>
Committed: Thu Mar 28 17:26:12 2013 +0530

----------------------------------------------------------------------
 .../hypervisor/vmware/VmwareServerDiscoverer.java  |   12 ++++++------
 .../vmware/manager/VmwareManagerImpl.java          |    8 ++++----
 2 files changed, 10 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c502b467/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java
----------------------------------------------------------------------
diff --git 
a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java
 
b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java
index 94ba97d..2b3eba6 100755
--- 
a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java
+++ 
b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java
@@ -135,14 +135,14 @@ public class VmwareServerDiscoverer extends 
DiscovererBase implements
                        return null;
                }
 
-               List<HostVO> hosts = 
_resourceMgr.listAllHostsInCluster(clusterId);
+        List<HostVO> hosts = _resourceMgr.listAllHostsInCluster(clusterId);
         if (hosts != null && hosts.size() > 0) {
             int maxHostsPerCluster = 
_hvCapabilitiesDao.getMaxHostsPerCluster(hosts.get(0).getHypervisorType(), 
hosts.get(0).getHypervisorVersion());
-            if (hosts.size() > maxHostsPerCluster) {
-                   String msg = "VMware cluster " + cluster.getName() + " is 
too big to add new host now. (current configured cluster size: " + 
maxHostsPerCluster + ")";
-                       s_logger.error(msg);
-                       throw new DiscoveredWithErrorException(msg);
-               }
+            if (hosts.size() >= maxHostsPerCluster) {
+                String msg = "VMware cluster " + cluster.getName() + " is too 
big to add new host, current size: " + hosts.size() + ", max. size: " + 
maxHostsPerCluster;
+                s_logger.error(msg);
+                throw new DiscoveredWithErrorException(msg);
+            }
         }
 
                String privateTrafficLabel = null;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c502b467/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java
----------------------------------------------------------------------
diff --git 
a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java
 
b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java
index 9d29abf..b2e3768 100755
--- 
a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java
+++ 
b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java
@@ -355,10 +355,10 @@ public class VmwareManagerImpl extends ManagerBase 
implements VmwareManager, Vmw
                     String version = about.getApiVersion();
                     int maxHostsPerCluster = 
_hvCapabilitiesDao.getMaxHostsPerCluster(HypervisorType.VMware, version);
                     if (hosts.size() > maxHostsPerCluster) {
-                        String msg = "vCenter cluster size is too big (current 
configured cluster size: " + maxHostsPerCluster + ")";
-                    s_logger.error(msg);
-                    throw new DiscoveredWithErrorException(msg);
-                }
+                        String msg = "Failed to add VMware cluster as size is 
too big, current size: " + hosts.size() + ", max. size: " + maxHostsPerCluster;
+                        s_logger.error(msg);
+                        throw new DiscoveredWithErrorException(msg);
+                    }
                 }
 
                 for(ManagedObjectReference morHost: hosts) {

Reply via email to