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
This commit is contained in:
Koushik Das 2013-01-21 16:40:43 +05:30
parent bd4661e467
commit bc493bd39b
9 changed files with 117 additions and 155 deletions

View File

@ -46,4 +46,10 @@ public interface HypervisorCapabilities extends Identity, InternalIdentity{
* @return the max. data volumes per VM supported by hypervisor
*/
Integer getMaxDataVolumesLimit();
/**
* @return the max. hosts per cluster supported by hypervisor
*/
Integer getMaxHostsPerCluster();
}

View File

@ -59,6 +59,9 @@ public class HypervisorCapabilitiesVO implements HypervisorCapabilities {
@Column(name="max_data_volumes_limit")
private Integer maxDataVolumesLimit;
@Column(name="max_hosts_per_cluster")
private Integer maxHostsPerCluster;
protected HypervisorCapabilitiesVO() {
this.uuid = UUID.randomUUID().toString();
}
@ -157,6 +160,15 @@ public class HypervisorCapabilitiesVO implements HypervisorCapabilities {
this.maxDataVolumesLimit = maxDataVolumesLimit;
}
@Override
public Integer getMaxHostsPerCluster() {
return maxHostsPerCluster;
}
public void setMaxHostsPerCluster(Integer maxHostsPerCluster) {
this.maxHostsPerCluster = maxHostsPerCluster;
}
@Override
public boolean equals(Object obj) {
if (obj instanceof HypervisorCapabilitiesVO) {

View File

@ -45,6 +45,7 @@ import com.cloud.host.HostVO;
import com.cloud.host.dao.HostDao;
import com.cloud.hypervisor.Hypervisor;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.hypervisor.dao.HypervisorCapabilitiesDao;
import com.cloud.hypervisor.vmware.manager.VmwareManager;
import com.cloud.hypervisor.vmware.mo.ClusterMO;
import com.cloud.hypervisor.vmware.mo.HostMO;
@ -95,78 +96,69 @@ public class VmwareServerDiscoverer extends DiscovererBase implements
CiscoNexusVSMDeviceDao _nexusDao;
@Inject
NetworkModel _netmgr;
@Inject
HypervisorCapabilitiesDao _hvCapabilitiesDao;
public VmwareServerDiscoverer() {
s_logger.info("VmwareServerDiscoverer is constructed");
}
@Override
public Map<? extends ServerResource, Map<String, String>> find(long dcId,
Long podId, Long clusterId, URI url, String username,
String password, List<String> hostTags) throws DiscoveryException {
if (s_logger.isInfoEnabled())
s_logger.info("Discover host. dc: " + dcId + ", pod: " + podId
+ ", cluster: " + clusterId + ", uri host: "
+ url.getHost());
@Override
public Map<? extends ServerResource, Map<String, String>> find(long dcId, Long podId, Long clusterId, URI url,
String username, String password, List<String> hostTags) throws DiscoveryException {
if(s_logger.isInfoEnabled())
s_logger.info("Discover host. dc: " + dcId + ", pod: " + podId + ", cluster: " + clusterId + ", uri host: " + url.getHost());
if(podId == null) {
if(s_logger.isInfoEnabled())
s_logger.info("No pod is assigned, assuming that it is not for vmware and skip it to next discoverer");
return null;
}
ClusterVO cluster = _clusterDao.findById(clusterId);
if(cluster == null || cluster.getHypervisorType() != HypervisorType.VMware) {
if(s_logger.isInfoEnabled())
s_logger.info("invalid cluster id or cluster is not for VMware hypervisors");
return null;
}
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 (podId == null) {
if (s_logger.isInfoEnabled())
s_logger.info("No pod is assigned, assuming that it is not for vmware and skip it to next discoverer");
return null;
}
ClusterVO cluster = _clusterDao.findById(clusterId);
if (cluster == null
|| cluster.getHypervisorType() != HypervisorType.VMware) {
if (s_logger.isInfoEnabled())
s_logger.info("invalid cluster id or cluster is not for VMware hypervisors");
return null;
}
List<HostVO> hosts = _resourceMgr.listAllHostsInCluster(clusterId);
if (hosts.size() >= _vmwareMgr.getMaxHostsPerCluster()) {
String msg = "VMware cluster "
+ cluster.getName()
+ " is too big to add new host now. (current configured cluster size: "
+ _vmwareMgr.getMaxHostsPerCluster() + ")";
s_logger.error(msg);
throw new DiscoveredWithErrorException(msg);
}
String privateTrafficLabel = null;
String publicTrafficLabel = null;
String guestTrafficLabel = null;
Map<String, String> vsmCredentials = null;
privateTrafficLabel = _netmgr.getDefaultManagementTrafficLabel(dcId,
HypervisorType.VMware);
if (privateTrafficLabel != null) {
s_logger.info("Detected private network label : "
+ privateTrafficLabel);
}
if (_vmwareMgr.getNexusVSwitchGlobalParameter()) {
DataCenterVO zone = _dcDao.findById(dcId);
NetworkType zoneType = zone.getNetworkType();
if (zoneType != NetworkType.Basic) {
publicTrafficLabel = _netmgr.getDefaultPublicTrafficLabel(dcId,
HypervisorType.VMware);
if (publicTrafficLabel != null) {
s_logger.info("Detected public network label : "
+ publicTrafficLabel);
}
}
// Get physical network label
guestTrafficLabel = _netmgr.getDefaultGuestTrafficLabel(dcId,
HypervisorType.VMware);
if (guestTrafficLabel != null) {
s_logger.info("Detected guest network label : "
+ guestTrafficLabel);
}
vsmCredentials = _vmwareMgr
.getNexusVSMCredentialsByClusterId(clusterId);
}
String privateTrafficLabel = null;
String publicTrafficLabel = null;
String guestTrafficLabel = null;
Map<String, String> vsmCredentials = null;
privateTrafficLabel = _netmgr.getDefaultManagementTrafficLabel(dcId, HypervisorType.VMware);
if (privateTrafficLabel != null) {
s_logger.info("Detected private network label : " + privateTrafficLabel);
}
if (_vmwareMgr.getNexusVSwitchGlobalParameter()) {
DataCenterVO zone = _dcDao.findById(dcId);
NetworkType zoneType = zone.getNetworkType();
if (zoneType != NetworkType.Basic) {
publicTrafficLabel = _netmgr.getDefaultPublicTrafficLabel(dcId, HypervisorType.VMware);
if (publicTrafficLabel != null) {
s_logger.info("Detected public network label : " + publicTrafficLabel);
}
}
// Get physical network label
guestTrafficLabel = _netmgr.getDefaultGuestTrafficLabel(dcId, HypervisorType.VMware);
if (guestTrafficLabel != null) {
s_logger.info("Detected guest network label : " + guestTrafficLabel);
}
vsmCredentials = _vmwareMgr.getNexusVSMCredentialsByClusterId(clusterId);
}
VmwareContext context = null;
try {

View File

@ -29,10 +29,6 @@ import com.vmware.vim25.ManagedObjectReference;
public interface VmwareManager {
public final String CONTEXT_STOCK_NAME = "vmwareMgr";
// this limitation comes from the fact that we are using linked clone on shared VMFS storage,
// we need to limit the size of vCenter cluster, http://en.wikipedia.org/wiki/VMware_VMFS
public final int MAX_HOSTS_PER_CLUSTER = 8;
String composeWorkerName();
String getSystemVMIsoFileNameOnDatastore();
@ -57,7 +53,6 @@ public interface VmwareManager {
Pair<Integer, Integer> getAddiionalVncPortRange();
int getMaxHostsPerCluster();
int getRouterExtraPublicNics();
boolean beginExclusiveOperation(int timeOutSeconds);

View File

@ -58,6 +58,7 @@ import com.cloud.host.HostVO;
import com.cloud.host.Status;
import com.cloud.host.dao.HostDao;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.hypervisor.dao.HypervisorCapabilitiesDao;
import com.cloud.hypervisor.vmware.VmwareCleanupMaid;
import com.cloud.hypervisor.vmware.mo.DiskControllerType;
import com.cloud.hypervisor.vmware.mo.HostFirewallSystemMO;
@ -91,6 +92,7 @@ import com.cloud.utils.ssh.SshHelper;
import com.cloud.vm.DomainRouterVO;
import com.google.gson.Gson;
import com.vmware.apputils.vim25.ServiceUtil;
import com.vmware.vim25.AboutInfo;
import com.vmware.vim25.HostConnectSpec;
import com.vmware.vim25.ManagedObjectReference;
@ -119,6 +121,7 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
@Inject ClusterVSMMapDao _vsmMapDao;
@Inject ConfigurationDao _configDao;
@Inject ConfigurationServer _configServer;
@Inject HypervisorCapabilitiesDao _hvCapabilitiesDao;
String _mountParent;
StorageLayer _storage;
@ -133,7 +136,6 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
String _recycleHungWorker = "false";
int _additionalPortRangeStart;
int _additionalPortRangeSize;
int _maxHostsPerCluster;
int _routerExtraPublicNics = 2;
String _cpuOverprovisioningFactor = "1";
@ -260,7 +262,6 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
_routerExtraPublicNics = NumbersUtil.parseInt(_configDao.getValue(Config.RouterExtraPublicNics.key()), 2);
_maxHostsPerCluster = NumbersUtil.parseInt(_configDao.getValue(Config.VmwarePerClusterHostMax.key()), VmwareManager.MAX_HOSTS_PER_CLUSTER);
_cpuOverprovisioningFactor = _configDao.getValue(Config.CPUOverprovisioningFactor.key());
if(_cpuOverprovisioningFactor == null || _cpuOverprovisioningFactor.isEmpty())
_cpuOverprovisioningFactor = "1";
@ -400,10 +401,15 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
ManagedObjectReference[] hosts = (ManagedObjectReference[])serviceContext.getServiceUtil().getDynamicProperty(mor, "host");
assert(hosts != null);
if(hosts.length > _maxHostsPerCluster) {
String msg = "vCenter cluster size is too big (current configured cluster size: " + _maxHostsPerCluster + ")";
s_logger.error(msg);
throw new DiscoveredWithErrorException(msg);
if (hosts.length > 0) {
AboutInfo about = (AboutInfo)(serviceContext.getServiceUtil().getDynamicProperty(hosts[0], "config.product"));
String version = about.getApiVersion();
int maxHostsPerCluster = _hvCapabilitiesDao.getMaxHostsPerCluster(HypervisorType.VMware, version);
if (hosts.length > maxHostsPerCluster) {
String msg = "vCenter cluster size is too big (current configured cluster size: " + maxHostsPerCluster + ")";
s_logger.error(msg);
throw new DiscoveredWithErrorException(msg);
}
}
for(ManagedObjectReference morHost: hosts) {
@ -868,11 +874,6 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
return new Pair<Integer, Integer>(_additionalPortRangeStart, _additionalPortRangeSize);
}
@Override
public int getMaxHostsPerCluster() {
return this._maxHostsPerCluster;
}
@Override
public int getRouterExtraPublicNics() {
return this._routerExtraPublicNics;

View File

@ -258,7 +258,6 @@ public enum Config {
VmwareAdditionalVncPortRangeStart("Advanced", ManagementServer.class, Integer.class, "vmware.additional.vnc.portrange.start", "50000", "Start port number of additional VNC port range", null),
VmwareAdditionalVncPortRangeSize("Advanced", ManagementServer.class, Integer.class, "vmware.additional.vnc.portrange.size", "1000", "Start port number of additional VNC port range", null),
//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),
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"),
VmwareReserveCpu("Advanced", ManagementServer.class, Boolean.class, "vmware.reserve.cpu", "false", "Specify whether or not to reserve CPU based on CPU overprovisioning factor", null),
VmwareReserveMem("Advanced", ManagementServer.class, Boolean.class, "vmware.reserve.mem", "false", "Specify whether or not to reserve memory based on memory overprovisioning factor", null),
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),

View File

@ -31,4 +31,6 @@ public interface HypervisorCapabilitiesDao extends GenericDao<HypervisorCapabili
Long getMaxGuestsLimit(HypervisorType hypervisorType, String hypervisorVersion);
Integer getMaxDataVolumesLimit(HypervisorType hypervisorType, String hypervisorVersion);
Integer getMaxHostsPerCluster(HypervisorType hypervisorType, String hypervisorVersion);
}

View File

@ -38,8 +38,6 @@ public class HypervisorCapabilitiesDaoImpl extends GenericDaoBase<HypervisorCapa
protected final SearchBuilder<HypervisorCapabilitiesVO> HypervisorTypeSearch;
protected final SearchBuilder<HypervisorCapabilitiesVO> HypervisorTypeAndVersionSearch;
protected final GenericSearchBuilder<HypervisorCapabilitiesVO, Long> MaxGuestLimitByHypervisorSearch;
protected final GenericSearchBuilder<HypervisorCapabilitiesVO, Integer> MaxDataVolumesLimitByHypervisorSearch;
private static final String DEFAULT_VERSION = "default";
@ -52,18 +50,14 @@ public class HypervisorCapabilitiesDaoImpl extends GenericDaoBase<HypervisorCapa
HypervisorTypeAndVersionSearch.and("hypervisorType", HypervisorTypeAndVersionSearch.entity().getHypervisorType(), SearchCriteria.Op.EQ);
HypervisorTypeAndVersionSearch.and("hypervisorVersion", HypervisorTypeAndVersionSearch.entity().getHypervisorVersion(), SearchCriteria.Op.EQ);
HypervisorTypeAndVersionSearch.done();
MaxGuestLimitByHypervisorSearch = createSearchBuilder(Long.class);
MaxGuestLimitByHypervisorSearch.selectField(MaxGuestLimitByHypervisorSearch.entity().getMaxGuestsLimit());
MaxGuestLimitByHypervisorSearch.and("hypervisorType", MaxGuestLimitByHypervisorSearch.entity().getHypervisorType(), SearchCriteria.Op.EQ);
MaxGuestLimitByHypervisorSearch.and("hypervisorVersion", MaxGuestLimitByHypervisorSearch.entity().getHypervisorVersion(), SearchCriteria.Op.EQ);
MaxGuestLimitByHypervisorSearch.done();
}
MaxDataVolumesLimitByHypervisorSearch = createSearchBuilder(Integer.class);
MaxDataVolumesLimitByHypervisorSearch.selectField(MaxDataVolumesLimitByHypervisorSearch.entity().getMaxDataVolumesLimit());
MaxDataVolumesLimitByHypervisorSearch.and("hypervisorType", MaxDataVolumesLimitByHypervisorSearch.entity().getHypervisorType(), SearchCriteria.Op.EQ);
MaxDataVolumesLimitByHypervisorSearch.and("hypervisorVersion", MaxDataVolumesLimitByHypervisorSearch.entity().getHypervisorVersion(), SearchCriteria.Op.EQ);
MaxDataVolumesLimitByHypervisorSearch.done();
HypervisorCapabilitiesVO getCapabilities(HypervisorType hypervisorType, String hypervisorVersion) {
HypervisorCapabilitiesVO result = findByHypervisorTypeAndVersion(hypervisorType, hypervisorVersion);
if (result == null) { // if data is not available for a specific version then use 'default' as version
result = findByHypervisorTypeAndVersion(hypervisorType, DEFAULT_VERSION);
}
return result;
}
@Override
@ -84,63 +78,22 @@ public class HypervisorCapabilitiesDaoImpl extends GenericDaoBase<HypervisorCapa
@Override
public Long getMaxGuestsLimit(HypervisorType hypervisorType, String hypervisorVersion){
Long defaultLimit = new Long(50);
Long result = null;
boolean useDefault = false;
if(hypervisorVersion != null){
SearchCriteria<Long> sc = MaxGuestLimitByHypervisorSearch.create();
sc.setParameters("hypervisorType", hypervisorType);
sc.setParameters("hypervisorVersion", hypervisorVersion);
List<Long> limitList = customSearch(sc, null);
if(!limitList.isEmpty()){
result = limitList.get(0);
}else{
useDefault = true;
}
}else{
useDefault = true;
}
if(useDefault){
SearchCriteria<Long> sc = MaxGuestLimitByHypervisorSearch.create();
sc.setParameters("hypervisorType", hypervisorType);
sc.setParameters("hypervisorVersion", DEFAULT_VERSION);
List<Long> limitList = customSearch(sc, null);
if(!limitList.isEmpty()){
result = limitList.get(0);
}
}
if(result == null){
HypervisorCapabilitiesVO result = getCapabilities(hypervisorType, hypervisorVersion);
Long limit = result.getMaxGuestsLimit();
if (limit == null)
return defaultLimit;
}
return result;
return limit;
}
@Override
public Integer getMaxDataVolumesLimit(HypervisorType hypervisorType, String hypervisorVersion) {
Integer result = null;
boolean useDefault = false;
if (hypervisorVersion != null) {
SearchCriteria<Integer> sc = MaxDataVolumesLimitByHypervisorSearch.create();
sc.setParameters("hypervisorType", hypervisorType);
sc.setParameters("hypervisorVersion", hypervisorVersion);
List<Integer> limitList = customSearch(sc, null);
if (!limitList.isEmpty()) {
result = limitList.get(0);
} else {
useDefault = true;
}
} else {
useDefault = true;
}
// If data is not available for a specific hypervisor version then use 'default' as the version
if (useDefault) {
SearchCriteria<Integer> sc = MaxDataVolumesLimitByHypervisorSearch.create();
sc.setParameters("hypervisorType", hypervisorType);
sc.setParameters("hypervisorVersion", DEFAULT_VERSION);
List<Integer> limitList = customSearch(sc, null);
if (!limitList.isEmpty()) {
result = limitList.get(0);
}
}
return result;
HypervisorCapabilitiesVO result = getCapabilities(hypervisorType, hypervisorVersion);
return result.getMaxDataVolumesLimit();
}
}
@Override
public Integer getMaxHostsPerCluster(HypervisorType hypervisorType, String hypervisorVersion) {
HypervisorCapabilitiesVO result = getCapabilities(hypervisorType, hypervisorVersion);
return result.getMaxHostsPerCluster();
}
}

View File

@ -1650,6 +1650,7 @@ CREATE TABLE `cloud`.`hypervisor_capabilities` (
`max_guests_limit` bigint unsigned DEFAULT 50,
`security_group_enabled` int(1) unsigned DEFAULT 1 COMMENT 'Is security group supported',
`max_data_volumes_limit` int unsigned DEFAULT 6 COMMENT 'Max. data volumes per VM supported by hypervisor',
`max_hosts_per_cluster` int unsigned DEFAULT NULL COMMENT 'Max. hosts in cluster supported by hypervisor',
PRIMARY KEY (`id`),
CONSTRAINT `uc_hypervisor_capabilities__uuid` UNIQUE (`uuid`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
@ -1661,10 +1662,11 @@ INSERT IGNORE INTO `cloud`.`hypervisor_capabilities`(hypervisor_type, hypervisor
INSERT IGNORE INTO `cloud`.`hypervisor_capabilities`(hypervisor_type, hypervisor_version, max_guests_limit, security_group_enabled) VALUES ('XenServer', '5.6 SP2', 50, 1);
INSERT IGNORE INTO `cloud`.`hypervisor_capabilities`(hypervisor_type, hypervisor_version, max_guests_limit, security_group_enabled, max_data_volumes_limit) VALUES ('XenServer', '6.0', 50, 1, 13);
INSERT IGNORE INTO `cloud`.`hypervisor_capabilities`(hypervisor_type, hypervisor_version, max_guests_limit, security_group_enabled, max_data_volumes_limit) VALUES ('XenServer', '6.0.2', 50, 1, 13);
INSERT IGNORE INTO `cloud`.`hypervisor_capabilities`(hypervisor_type, hypervisor_version, max_guests_limit, security_group_enabled) VALUES ('VMware', 'default', 128, 0);
INSERT IGNORE INTO `cloud`.`hypervisor_capabilities`(hypervisor_type, hypervisor_version, max_guests_limit, security_group_enabled) VALUES ('VMware', '4.0', 128, 0);
INSERT IGNORE INTO `cloud`.`hypervisor_capabilities`(hypervisor_type, hypervisor_version, max_guests_limit, security_group_enabled) VALUES ('VMware', '4.1', 128, 0);
INSERT IGNORE INTO `cloud`.`hypervisor_capabilities`(hypervisor_type, hypervisor_version, max_guests_limit, security_group_enabled) VALUES ('VMware', '5.0', 128, 0);
INSERT IGNORE INTO `cloud`.`hypervisor_capabilities`(hypervisor_type, hypervisor_version, max_guests_limit, security_group_enabled, max_hosts_per_cluster) VALUES ('VMware', 'default', 128, 0, 32);
INSERT IGNORE INTO `cloud`.`hypervisor_capabilities`(hypervisor_type, hypervisor_version, max_guests_limit, security_group_enabled, max_hosts_per_cluster) VALUES ('VMware', '4.0', 128, 0, 32);
INSERT IGNORE INTO `cloud`.`hypervisor_capabilities`(hypervisor_type, hypervisor_version, max_guests_limit, security_group_enabled, max_hosts_per_cluster) VALUES ('VMware', '4.1', 128, 0, 32);
INSERT IGNORE INTO `cloud`.`hypervisor_capabilities`(hypervisor_type, hypervisor_version, max_guests_limit, security_group_enabled, max_hosts_per_cluster) VALUES ('VMware', '5.0', 128, 0, 32);
INSERT IGNORE INTO `cloud`.`hypervisor_capabilities`(hypervisor_type, hypervisor_version, max_guests_limit, security_group_enabled, max_hosts_per_cluster) VALUES ('VMware', '5.1', 128, 0, 32);
INSERT IGNORE INTO `cloud`.`hypervisor_capabilities`(hypervisor_type, hypervisor_version, max_guests_limit, security_group_enabled) VALUES ('KVM', 'default', 50, 1);
INSERT IGNORE INTO `cloud`.`hypervisor_capabilities`(hypervisor_type, hypervisor_version, max_guests_limit, security_group_enabled) VALUES ('Ovm', 'default', 25, 1);
INSERT IGNORE INTO `cloud`.`hypervisor_capabilities`(hypervisor_type, hypervisor_version, max_guests_limit, security_group_enabled) VALUES ('Ovm', '2.3', 25, 1);