Skip to content

Commit bc493bd

Browse files
author
Koushik Das
committed
CLOUDSTACK-672: Set VMware cluster max. limit based on HV version
Max. number of hosts in a Vmware clueter is specific to the version of the HV. This limit is read from the hypervisor_capabilities table
1 parent bd4661e commit bc493bd

9 files changed

Lines changed: 118 additions & 156 deletions

File tree

api/src/com/cloud/hypervisor/HypervisorCapabilities.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,10 @@ public interface HypervisorCapabilities extends Identity, InternalIdentity{
4646
* @return the max. data volumes per VM supported by hypervisor
4747
*/
4848
Integer getMaxDataVolumesLimit();
49+
50+
/**
51+
* @return the max. hosts per cluster supported by hypervisor
52+
*/
53+
Integer getMaxHostsPerCluster();
54+
4955
}

core/src/com/cloud/hypervisor/HypervisorCapabilitiesVO.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ public class HypervisorCapabilitiesVO implements HypervisorCapabilities {
5959
@Column(name="max_data_volumes_limit")
6060
private Integer maxDataVolumesLimit;
6161

62+
@Column(name="max_hosts_per_cluster")
63+
private Integer maxHostsPerCluster;
64+
6265
protected HypervisorCapabilitiesVO() {
6366
this.uuid = UUID.randomUUID().toString();
6467
}
@@ -157,6 +160,15 @@ public void setMaxDataVolumesLimit(Integer maxDataVolumesLimit) {
157160
this.maxDataVolumesLimit = maxDataVolumesLimit;
158161
}
159162

163+
@Override
164+
public Integer getMaxHostsPerCluster() {
165+
return maxHostsPerCluster;
166+
}
167+
168+
public void setMaxHostsPerCluster(Integer maxHostsPerCluster) {
169+
this.maxHostsPerCluster = maxHostsPerCluster;
170+
}
171+
160172
@Override
161173
public boolean equals(Object obj) {
162174
if (obj instanceof HypervisorCapabilitiesVO) {

plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java

Lines changed: 60 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import com.cloud.host.dao.HostDao;
4646
import com.cloud.hypervisor.Hypervisor;
4747
import com.cloud.hypervisor.Hypervisor.HypervisorType;
48+
import com.cloud.hypervisor.dao.HypervisorCapabilitiesDao;
4849
import com.cloud.hypervisor.vmware.manager.VmwareManager;
4950
import com.cloud.hypervisor.vmware.mo.ClusterMO;
5051
import com.cloud.hypervisor.vmware.mo.HostMO;
@@ -95,78 +96,69 @@ public class VmwareServerDiscoverer extends DiscovererBase implements
9596
CiscoNexusVSMDeviceDao _nexusDao;
9697
@Inject
9798
NetworkModel _netmgr;
98-
99+
@Inject
100+
HypervisorCapabilitiesDao _hvCapabilitiesDao;
101+
99102
public VmwareServerDiscoverer() {
100103
s_logger.info("VmwareServerDiscoverer is constructed");
101104
}
102-
103-
@Override
104-
public Map<? extends ServerResource, Map<String, String>> find(long dcId,
105-
Long podId, Long clusterId, URI url, String username,
106-
String password, List<String> hostTags) throws DiscoveryException {
107-
108-
if (s_logger.isInfoEnabled())
109-
s_logger.info("Discover host. dc: " + dcId + ", pod: " + podId
110-
+ ", cluster: " + clusterId + ", uri host: "
111-
+ url.getHost());
112-
113-
if (podId == null) {
114-
if (s_logger.isInfoEnabled())
115-
s_logger.info("No pod is assigned, assuming that it is not for vmware and skip it to next discoverer");
116-
return null;
117-
}
118-
119-
ClusterVO cluster = _clusterDao.findById(clusterId);
120-
if (cluster == null
121-
|| cluster.getHypervisorType() != HypervisorType.VMware) {
122-
if (s_logger.isInfoEnabled())
123-
s_logger.info("invalid cluster id or cluster is not for VMware hypervisors");
124-
return null;
125-
}
126105

127-
List<HostVO> hosts = _resourceMgr.listAllHostsInCluster(clusterId);
128-
if (hosts.size() >= _vmwareMgr.getMaxHostsPerCluster()) {
129-
String msg = "VMware cluster "
130-
+ cluster.getName()
131-
+ " is too big to add new host now. (current configured cluster size: "
132-
+ _vmwareMgr.getMaxHostsPerCluster() + ")";
133-
s_logger.error(msg);
134-
throw new DiscoveredWithErrorException(msg);
135-
}
136-
137-
String privateTrafficLabel = null;
138-
String publicTrafficLabel = null;
139-
String guestTrafficLabel = null;
140-
Map<String, String> vsmCredentials = null;
141-
142-
privateTrafficLabel = _netmgr.getDefaultManagementTrafficLabel(dcId,
143-
HypervisorType.VMware);
144-
if (privateTrafficLabel != null) {
145-
s_logger.info("Detected private network label : "
146-
+ privateTrafficLabel);
147-
}
148-
149-
if (_vmwareMgr.getNexusVSwitchGlobalParameter()) {
150-
DataCenterVO zone = _dcDao.findById(dcId);
151-
NetworkType zoneType = zone.getNetworkType();
152-
if (zoneType != NetworkType.Basic) {
153-
publicTrafficLabel = _netmgr.getDefaultPublicTrafficLabel(dcId,
154-
HypervisorType.VMware);
155-
if (publicTrafficLabel != null) {
156-
s_logger.info("Detected public network label : "
157-
+ publicTrafficLabel);
158-
}
159-
}
160-
// Get physical network label
161-
guestTrafficLabel = _netmgr.getDefaultGuestTrafficLabel(dcId,
162-
HypervisorType.VMware);
163-
if (guestTrafficLabel != null) {
164-
s_logger.info("Detected guest network label : "
165-
+ guestTrafficLabel);
166-
}
167-
vsmCredentials = _vmwareMgr
168-
.getNexusVSMCredentialsByClusterId(clusterId);
169-
}
106+
@Override
107+
public Map<? extends ServerResource, Map<String, String>> find(long dcId, Long podId, Long clusterId, URI url,
108+
String username, String password, List<String> hostTags) throws DiscoveryException {
109+
110+
if(s_logger.isInfoEnabled())
111+
s_logger.info("Discover host. dc: " + dcId + ", pod: " + podId + ", cluster: " + clusterId + ", uri host: " + url.getHost());
112+
113+
if(podId == null) {
114+
if(s_logger.isInfoEnabled())
115+
s_logger.info("No pod is assigned, assuming that it is not for vmware and skip it to next discoverer");
116+
return null;
117+
}
118+
119+
ClusterVO cluster = _clusterDao.findById(clusterId);
120+
if(cluster == null || cluster.getHypervisorType() != HypervisorType.VMware) {
121+
if(s_logger.isInfoEnabled())
122+
s_logger.info("invalid cluster id or cluster is not for VMware hypervisors");
123+
return null;
124+
}
125+
126+
List<HostVO> hosts = _resourceMgr.listAllHostsInCluster(clusterId);
127+
if (hosts != null && hosts.size() > 0) {
128+
int maxHostsPerCluster = _hvCapabilitiesDao.getMaxHostsPerCluster(hosts.get(0).getHypervisorType(), hosts.get(0).getHypervisorVersion());
129+
if (hosts.size() > maxHostsPerCluster) {
130+
String msg = "VMware cluster " + cluster.getName() + " is too big to add new host now. (current configured cluster size: " + maxHostsPerCluster + ")";
131+
s_logger.error(msg);
132+
throw new DiscoveredWithErrorException(msg);
133+
}
134+
}
135+
136+
String privateTrafficLabel = null;
137+
String publicTrafficLabel = null;
138+
String guestTrafficLabel = null;
139+
Map<String, String> vsmCredentials = null;
140+
141+
privateTrafficLabel = _netmgr.getDefaultManagementTrafficLabel(dcId, HypervisorType.VMware);
142+
if (privateTrafficLabel != null) {
143+
s_logger.info("Detected private network label : " + privateTrafficLabel);
144+
}
145+
146+
if (_vmwareMgr.getNexusVSwitchGlobalParameter()) {
147+
DataCenterVO zone = _dcDao.findById(dcId);
148+
NetworkType zoneType = zone.getNetworkType();
149+
if (zoneType != NetworkType.Basic) {
150+
publicTrafficLabel = _netmgr.getDefaultPublicTrafficLabel(dcId, HypervisorType.VMware);
151+
if (publicTrafficLabel != null) {
152+
s_logger.info("Detected public network label : " + publicTrafficLabel);
153+
}
154+
}
155+
// Get physical network label
156+
guestTrafficLabel = _netmgr.getDefaultGuestTrafficLabel(dcId, HypervisorType.VMware);
157+
if (guestTrafficLabel != null) {
158+
s_logger.info("Detected guest network label : " + guestTrafficLabel);
159+
}
160+
vsmCredentials = _vmwareMgr.getNexusVSMCredentialsByClusterId(clusterId);
161+
}
170162

171163
VmwareContext context = null;
172164
try {

plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManager.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@
2929
public interface VmwareManager {
3030
public final String CONTEXT_STOCK_NAME = "vmwareMgr";
3131

32-
// this limitation comes from the fact that we are using linked clone on shared VMFS storage,
33-
// we need to limit the size of vCenter cluster, http://en.wikipedia.org/wiki/VMware_VMFS
34-
public final int MAX_HOSTS_PER_CLUSTER = 8;
35-
3632
String composeWorkerName();
3733

3834
String getSystemVMIsoFileNameOnDatastore();
@@ -57,7 +53,6 @@ List<ManagedObjectReference> addHostToPodCluster(VmwareContext serviceContext, l
5753

5854
Pair<Integer, Integer> getAddiionalVncPortRange();
5955

60-
int getMaxHostsPerCluster();
6156
int getRouterExtraPublicNics();
6257

6358
boolean beginExclusiveOperation(int timeOutSeconds);

plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
import com.cloud.host.Status;
5959
import com.cloud.host.dao.HostDao;
6060
import com.cloud.hypervisor.Hypervisor.HypervisorType;
61+
import com.cloud.hypervisor.dao.HypervisorCapabilitiesDao;
6162
import com.cloud.hypervisor.vmware.VmwareCleanupMaid;
6263
import com.cloud.hypervisor.vmware.mo.DiskControllerType;
6364
import com.cloud.hypervisor.vmware.mo.HostFirewallSystemMO;
@@ -91,6 +92,7 @@
9192
import com.cloud.vm.DomainRouterVO;
9293
import com.google.gson.Gson;
9394
import com.vmware.apputils.vim25.ServiceUtil;
95+
import com.vmware.vim25.AboutInfo;
9496
import com.vmware.vim25.HostConnectSpec;
9597
import com.vmware.vim25.ManagedObjectReference;
9698

@@ -119,6 +121,7 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
119121
@Inject ClusterVSMMapDao _vsmMapDao;
120122
@Inject ConfigurationDao _configDao;
121123
@Inject ConfigurationServer _configServer;
124+
@Inject HypervisorCapabilitiesDao _hvCapabilitiesDao;
122125

123126
String _mountParent;
124127
StorageLayer _storage;
@@ -133,7 +136,6 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
133136
String _recycleHungWorker = "false";
134137
int _additionalPortRangeStart;
135138
int _additionalPortRangeSize;
136-
int _maxHostsPerCluster;
137139
int _routerExtraPublicNics = 2;
138140

139141
String _cpuOverprovisioningFactor = "1";
@@ -260,7 +262,6 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
260262

261263
_routerExtraPublicNics = NumbersUtil.parseInt(_configDao.getValue(Config.RouterExtraPublicNics.key()), 2);
262264

263-
_maxHostsPerCluster = NumbersUtil.parseInt(_configDao.getValue(Config.VmwarePerClusterHostMax.key()), VmwareManager.MAX_HOSTS_PER_CLUSTER);
264265
_cpuOverprovisioningFactor = _configDao.getValue(Config.CPUOverprovisioningFactor.key());
265266
if(_cpuOverprovisioningFactor == null || _cpuOverprovisioningFactor.isEmpty())
266267
_cpuOverprovisioningFactor = "1";
@@ -400,10 +401,15 @@ public List<ManagedObjectReference> addHostToPodCluster(VmwareContext serviceCon
400401
ManagedObjectReference[] hosts = (ManagedObjectReference[])serviceContext.getServiceUtil().getDynamicProperty(mor, "host");
401402
assert(hosts != null);
402403

403-
if(hosts.length > _maxHostsPerCluster) {
404-
String msg = "vCenter cluster size is too big (current configured cluster size: " + _maxHostsPerCluster + ")";
405-
s_logger.error(msg);
406-
throw new DiscoveredWithErrorException(msg);
404+
if (hosts.length > 0) {
405+
AboutInfo about = (AboutInfo)(serviceContext.getServiceUtil().getDynamicProperty(hosts[0], "config.product"));
406+
String version = about.getApiVersion();
407+
int maxHostsPerCluster = _hvCapabilitiesDao.getMaxHostsPerCluster(HypervisorType.VMware, version);
408+
if (hosts.length > maxHostsPerCluster) {
409+
String msg = "vCenter cluster size is too big (current configured cluster size: " + maxHostsPerCluster + ")";
410+
s_logger.error(msg);
411+
throw new DiscoveredWithErrorException(msg);
412+
}
407413
}
408414

409415
for(ManagedObjectReference morHost: hosts) {
@@ -868,11 +874,6 @@ public Pair<Integer, Integer> getAddiionalVncPortRange() {
868874
return new Pair<Integer, Integer>(_additionalPortRangeStart, _additionalPortRangeSize);
869875
}
870876

871-
@Override
872-
public int getMaxHostsPerCluster() {
873-
return this._maxHostsPerCluster;
874-
}
875-
876877
@Override
877878
public int getRouterExtraPublicNics() {
878879
return this._routerExtraPublicNics;

server/src/com/cloud/configuration/Config.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,6 @@ public enum Config {
258258
VmwareAdditionalVncPortRangeStart("Advanced", ManagementServer.class, Integer.class, "vmware.additional.vnc.portrange.start", "50000", "Start port number of additional VNC port range", null),
259259
VmwareAdditionalVncPortRangeSize("Advanced", ManagementServer.class, Integer.class, "vmware.additional.vnc.portrange.size", "1000", "Start port number of additional VNC port range", null),
260260
//VmwareGuestNicDeviceType("Advanced", ManagementServer.class, String.class, "vmware.guest.nic.device.type", "E1000", "Ethernet card type used in guest VM, valid values are E1000, PCNet32, Vmxnet2, Vmxnet3", null),
261-
VmwarePerClusterHostMax("Advanced", ManagementServer.class, Integer.class, "vmware.percluster.host.max", "8", "maxmium hosts per vCenter cluster(do not let it grow over 8)", "1-8"),
262261
VmwareReserveCpu("Advanced", ManagementServer.class, Boolean.class, "vmware.reserve.cpu", "false", "Specify whether or not to reserve CPU based on CPU overprovisioning factor", null),
263262
VmwareReserveMem("Advanced", ManagementServer.class, Boolean.class, "vmware.reserve.mem", "false", "Specify whether or not to reserve memory based on memory overprovisioning factor", null),
264263
VmwareRootDiskControllerType("Advanced", ManagementServer.class, String.class, "vmware.root.disk.controller", "ide", "Specify the default disk controller for root volumes, valid values are scsi, ide", null),

server/src/com/cloud/hypervisor/dao/HypervisorCapabilitiesDao.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,6 @@ public interface HypervisorCapabilitiesDao extends GenericDao<HypervisorCapabili
3131
Long getMaxGuestsLimit(HypervisorType hypervisorType, String hypervisorVersion);
3232

3333
Integer getMaxDataVolumesLimit(HypervisorType hypervisorType, String hypervisorVersion);
34+
35+
Integer getMaxHostsPerCluster(HypervisorType hypervisorType, String hypervisorVersion);
3436
}

0 commit comments

Comments
 (0)