CLOUDSTACK-741: Granular Global Parameters Added parameters to cluster level cluster.storage.allocated.capacity.notificationthreshold cluster.storage.capacity.notificationthreshold

CLOUDSTACK-2036
global parameter for Router Template ID functionality added
We use 5 parameters to set the router template name for each hypervisor

Moved cpu.overprovisioning.factor and mem.overprovisioning.factor to be able to update/list using update/list configuration API at cluster level.

Signed-off-by: Abhinandan Prateek <aprateek@apache.org>
This commit is contained in:
Harikrishna Patnala 2013-04-30 16:41:25 +05:30 committed by Abhinandan Prateek
parent bb63d713ce
commit 10b6c1c6c8
8 changed files with 60 additions and 11 deletions

View File

@ -569,7 +569,10 @@ public class AlertManagerImpl extends ManagerBase implements AlertManager {
switch (capacityType) {
case Capacity.CAPACITY_TYPE_STORAGE:
capacity.add(getUsedStats(capacityType, cluster.getDataCenterId(), cluster.getPodId(), cluster.getId()));
capacityValue = _capacityTypeThresholdMap.get(capacityType);
capacityValue = Double.parseDouble(_configServer.getConfigValue(Config.StorageCapacityThreshold.key(), Config.ConfigurationParameterScope.cluster.toString(), cluster.getId()));
break;
case Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED:
capacityValue = Double.parseDouble(_configServer.getConfigValue(Config.StorageAllocatedCapacityThreshold.key(), Config.ConfigurationParameterScope.cluster.toString(), cluster.getId()));
break;
case Capacity.CAPACITY_TYPE_CPU:
overProvFactor = ApiDBUtils.getCpuOverprovisioningFactor();

View File

@ -51,8 +51,8 @@ public enum Config {
AlertSMTPUsername("Alert", ManagementServer.class, String.class, "alert.smtp.username", null, "Username for SMTP authentication (applies only if alert.smtp.useAuth is true).", null),
AlertWait("Alert", AgentManager.class, Integer.class, "alert.wait", null, "Seconds to wait before alerting on a disconnected agent", null),
CapacityCheckPeriod("Alert", ManagementServer.class, Integer.class, "capacity.check.period", "300000", "The interval in milliseconds between capacity checks", null),
StorageAllocatedCapacityThreshold("Alert", ManagementServer.class, Float.class, "cluster.storage.allocated.capacity.notificationthreshold", "0.75", "Percentage (as a value between 0 and 1) of allocated storage utilization above which alerts will be sent about low storage available.", null),
StorageCapacityThreshold("Alert", ManagementServer.class, Float.class, "cluster.storage.capacity.notificationthreshold", "0.75", "Percentage (as a value between 0 and 1) of storage utilization above which alerts will be sent about low storage available.", null),
StorageAllocatedCapacityThreshold("Alert", ManagementServer.class, Float.class, "cluster.storage.allocated.capacity.notificationthreshold", "0.75", "Percentage (as a value between 0 and 1) of allocated storage utilization above which alerts will be sent about low storage available.", null, ConfigurationParameterScope.cluster.toString()),
StorageCapacityThreshold("Alert", ManagementServer.class, Float.class, "cluster.storage.capacity.notificationthreshold", "0.75", "Percentage (as a value between 0 and 1) of storage utilization above which alerts will be sent about low storage available.", null, ConfigurationParameterScope.cluster.toString()),
CPUCapacityThreshold("Alert", ManagementServer.class, Float.class, "cluster.cpu.allocated.capacity.notificationthreshold", "0.75", "Percentage (as a value between 0 and 1) of cpu utilization above which alerts will be sent about low cpu available.", null, ConfigurationParameterScope.cluster.toString()),
MemoryCapacityThreshold("Alert", ManagementServer.class, Float.class, "cluster.memory.allocated.capacity.notificationthreshold", "0.75", "Percentage (as a value between 0 and 1) of memory utilization above which alerts will be sent about low memory available.", null, ConfigurationParameterScope.cluster.toString()),
PublicIpCapacityThreshold("Alert", ManagementServer.class, Float.class, "zone.virtualnetwork.publicip.capacity.notificationthreshold", "0.75", "Percentage (as a value between 0 and 1) of public IP address space utilization above which alerts will be sent.", null),
@ -173,6 +173,11 @@ public enum Config {
RouterCheckInterval("Advanced", NetworkManager.class, Integer.class, "router.check.interval", "30", "Interval (in seconds) to report redundant router status.", null),
RouterCheckPoolSize("Advanced", NetworkManager.class, Integer.class, "router.check.poolsize", "10", "Numbers of threads using to check redundant router status.", null),
RouterTemplateId("Advanced", NetworkManager.class, Long.class, "router.template.id", "1", "Default ID for template.", null),
RouterTemplateXen("Advanced", NetworkManager.class, String.class, "router.template.xen", "SystemVM Template (XenServer)", "Name of the default router template on Xenserver.", null, ConfigurationParameterScope.zone.toString()),
RouterTemplateKVM("Advanced", NetworkManager.class, String.class, "router.template.kvm", "SystemVM Template (KVM)", "Name of the default router template on KVM.", null, ConfigurationParameterScope.zone.toString()),
RouterTemplateVmware("Advanced", NetworkManager.class, String.class, "router.template.vmware", "SystemVM Template (vSphere)", "Name of the default router template on Vmware.", null, ConfigurationParameterScope.zone.toString()),
RouterTemplateHyperv("Advanced", NetworkManager.class, String.class, "router.template.hyperv", "SystemVM Template (HyperV)", "Name of the default router template on Hyperv.", null, ConfigurationParameterScope.zone.toString()),
RouterTemplateLXC("Advanced", NetworkManager.class, String.class, "router.template.lxc", "SystemVM Template (LXC)", "Name of the default router template on LXC.", null, ConfigurationParameterScope.zone.toString()),
RouterExtraPublicNics("Advanced", NetworkManager.class, Integer.class, "router.extra.public.nics", "2", "specify extra public nics used for virtual router(up to 5)", "0-5"),
StartRetry("Advanced", AgentManager.class, Integer.class, "start.retry", "10", "Number of times to retry create and start commands", null),
ScaleRetry("Advanced", AgentManager.class, Integer.class, "scale.retry", "2", "Number of times to retry scaling up the vm", null),
@ -191,8 +196,8 @@ public enum Config {
SystemVMAutoReserveCapacity("Advanced", ManagementServer.class, Boolean.class, "system.vm.auto.reserve.capacity", "true", "Indicates whether or not to automatically reserver system VM standby capacity.", null),
SystemVMDefaultHypervisor("Advanced", ManagementServer.class, String.class, "system.vm.default.hypervisor", null, "Hypervisor type used to create system vm", null),
SystemVMRandomPassword("Advanced", ManagementServer.class, Boolean.class, "system.vm.random.password", "false", "Randomize system vm password the first time management server starts", null),
CPUOverprovisioningFactor("Advanced", ManagementServer.class, String.class, "cpu.overprovisioning.factor", "1", "Used for CPU overprovisioning calculation; available CPU will be (actualCpuCapacity * cpu.overprovisioning.factor)", null),
MemOverprovisioningFactor("Advanced", ManagementServer.class, String.class, "mem.overprovisioning.factor", "1", "Used for memory overprovisioning calculation", null),
CPUOverprovisioningFactor("Advanced", ManagementServer.class, String.class, "cpu.overprovisioning.factor", "1", "Used for CPU overprovisioning calculation; available CPU will be (actualCpuCapacity * cpu.overprovisioning.factor)", null, ConfigurationParameterScope.cluster.toString()),
MemOverprovisioningFactor("Advanced", ManagementServer.class, String.class, "mem.overprovisioning.factor", "1", "Used for memory overprovisioning calculation", null, ConfigurationParameterScope.cluster.toString()),
LinkLocalIpNums("Advanced", ManagementServer.class, Integer.class, "linkLocalIp.nums", "10", "The number of link local ip that needed by domR(in power of 2)", null),
HypervisorList("Advanced", ManagementServer.class, String.class, "hypervisor.list", HypervisorType.KVM + "," + HypervisorType.XenServer + "," + HypervisorType.VMware + "," + HypervisorType.BareMetal + "," + HypervisorType.Ovm + "," + HypervisorType.LXC, "The list of hypervisors that this deployment will use.", "hypervisorList"),
ManagementHostIPAdr("Advanced", ManagementServer.class, String.class, "host", "localhost", "The ip address of management server", null),

View File

@ -324,7 +324,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
@DB
public String updateConfiguration(long userId, String name, String category, String value, String scope, Long resourceId) {
String validationMsg = validateConfigurationValue(name, value);
String validationMsg = validateConfigurationValue(name, value, scope);
if (validationMsg != null) {
s_logger.error("Invalid configuration option, name: " + name + ", value:" + value);
@ -553,7 +553,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
}
}
private String validateConfigurationValue(String name, String value) {
private String validateConfigurationValue(String name, String value, String scope) {
Config c = Config.getConfig(name);
if (c == null) {
@ -561,6 +561,16 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
return "Invalid configuration variable.";
}
String configScope = c.getScope();
if (scope != null) {
if (!configScope.contains(scope)) {
s_logger.error("Invalid scope id provided for the parameter " + name);
return "Invalid scope id provided for the parameter " + name;
}
if ((name.equalsIgnoreCase("cpu.overprovisioning.factor") || name.equalsIgnoreCase("mem.overprovisioning.factor")) && value == null) {
s_logger.error("value cannot be null for cpu.overprovisioning.factor/mem.overprovisioning.factor");
return "value cannot be null for cpu.overprovisioning.factor/mem.overprovisioning.factor";
}
}
Class<?> type = c.getType();

View File

@ -50,9 +50,17 @@ public class ClusterDetailsDaoImpl extends GenericDaoBase<ClusterDetailsVO, Long
@Override
public ClusterDetailsVO findDetail(long clusterId, String name) {
SearchCriteria<ClusterDetailsVO> sc = DetailSearch.create();
// This is temporary fix to support list/update configuration api for cpu and memory overprovisioning ratios
if(name.equalsIgnoreCase("cpu.overprovisioning.factor")) {
name = "cpuOvercommitRatio";
}
if (name.equalsIgnoreCase("mem.overprovisioning.factor")) {
name = "memoryOvercommitRatio";
}
sc.setParameters("clusterId", clusterId);
sc.setParameters("name", name);
ClusterDetailsVO detail = findOneIncludingRemovedBy(sc);
if("password".equals(name) && detail != null){
detail.setValue(DBEncryptionUtil.decrypt(detail.getValue()));

View File

@ -1591,7 +1591,26 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
HypervisorType hType = iter.next();
try {
s_logger.debug("Allocating the domR with the hypervisor type " + hType);
VMTemplateVO template = _templateDao.findRoutingTemplate(hType);
String templateName = null;
switch (hType) {
case XenServer:
templateName = _configServer.getConfigValue(Config.RouterTemplateXen.key(), Config.ConfigurationParameterScope.zone.toString(), dest.getDataCenter().getId());
break;
case KVM:
templateName = _configServer.getConfigValue(Config.RouterTemplateKVM.key(), Config.ConfigurationParameterScope.zone.toString(), dest.getDataCenter().getId());
break;
case VMware:
templateName = _configServer.getConfigValue(Config.RouterTemplateVmware.key(), Config.ConfigurationParameterScope.zone.toString(), dest.getDataCenter().getId());
break;
case Hyperv:
templateName = _configServer.getConfigValue(Config.RouterTemplateHyperv.key(), Config.ConfigurationParameterScope.zone.toString(), dest.getDataCenter().getId());
break;
case LXC:
templateName = _configServer.getConfigValue(Config.RouterTemplateLXC.key(), Config.ConfigurationParameterScope.zone.toString(), dest.getDataCenter().getId());
break;
default: break;
}
VMTemplateVO template = _templateDao.findRoutingTemplate(hType, templateName);
if (template == null) {
s_logger.debug(hType + " won't support system vm, skip it");

View File

@ -75,7 +75,7 @@ public interface VMTemplateDao extends GenericDao<VMTemplateVO, Long>, StateDao<
VMTemplateVO findSystemVMTemplate(long zoneId);
VMTemplateVO findSystemVMTemplate(long zoneId, HypervisorType hType);
VMTemplateVO findRoutingTemplate(HypervisorType type);
VMTemplateVO findRoutingTemplate(HypervisorType type, String templateName);
List<Long> listPrivateTemplatesByHost(Long hostId);
public Long countTemplatesForAccount(long accountId);

View File

@ -353,6 +353,7 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
tmpltTypeHyperSearch2 = createSearchBuilder();
tmpltTypeHyperSearch2.and("templateType", tmpltTypeHyperSearch2.entity().getTemplateType(), SearchCriteria.Op.EQ);
tmpltTypeHyperSearch2.and("hypervisorType", tmpltTypeHyperSearch2.entity().getHypervisorType(), SearchCriteria.Op.EQ);
tmpltTypeHyperSearch2.and("templateName", tmpltTypeHyperSearch2.entity().getName(), SearchCriteria.Op.EQ);
tmpltTypeSearch = createSearchBuilder();
@ -897,10 +898,13 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
}
@Override
public VMTemplateVO findRoutingTemplate(HypervisorType hType) {
public VMTemplateVO findRoutingTemplate(HypervisorType hType, String templateName) {
SearchCriteria<VMTemplateVO> sc = tmpltTypeHyperSearch2.create();
sc.setParameters("templateType", Storage.TemplateType.SYSTEM);
sc.setParameters("hypervisorType", hType);
if (templateName != null) {
sc.setParameters("templateName", templateName);
}
//order by descending order of id and select the first (this is going to be the latest)
List<VMTemplateVO> tmplts = listBy(sc, new Filter(VMTemplateVO.class, "id", false, null, 1l));

View File

@ -54,7 +54,7 @@ class TestUpdateConfigWithScope(cloudstackTestCase):
self.assertNotEqual(len(listConfigurationsResponse), 0, "Check if the list API \
returns a non-empty response")
configParam = listConfigurationsResponse[2]
configParam = listConfigurationsResponse[7]
self.assertEqual(configParam.value, updateConfigurationResponse.value, "Check if the update API returned \
is the same as the one we got in the list API")