From c502b4670328b6b950630e84b4a7d3fd4bcb96ca Mon Sep 17 00:00:00 2001 From: Koushik Das Date: Thu, 28 Mar 2013 17:26:12 +0530 Subject: [PATCH] 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. --- .../hypervisor/vmware/VmwareServerDiscoverer.java | 12 ++++++------ .../hypervisor/vmware/manager/VmwareManagerImpl.java | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) 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 94ba97d96a1..2b3eba690e3 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 hosts = _resourceMgr.listAllHostsInCluster(clusterId); + List 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; 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 9d29abf8d35..b2e37685d17 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) {