diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java index 60e23e5da2e..9c5f1356b97 100755 --- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java +++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java @@ -323,6 +323,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati private int _maxVolumeSizeInGb = Integer.parseInt(Config.MaxVolumeSize.getDefaultValue()); private long _defaultPageSize = Long.parseLong(Config.DefaultPageSize.getDefaultValue()); protected Set configValuesForValidation; + private Set weightBasedParametersForValidation; @Override public boolean configure(final String name, final Map params) throws ConfigurationException { @@ -335,6 +336,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati Long.parseLong(Config.DefaultPageSize.getDefaultValue())); populateConfigValuesForValidationSet(); + weightBasedParametersForValidation(); return true; } @@ -360,6 +362,28 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati configValuesForValidation.add("incorrect.login.attempts.allowed"); } + private void weightBasedParametersForValidation() { + weightBasedParametersForValidation = new HashSet(); + weightBasedParametersForValidation.add(Config.CPUCapacityThreshold.key()); + weightBasedParametersForValidation.add(Config.StorageAllocatedCapacityThreshold.key()); + weightBasedParametersForValidation.add(Config.StorageCapacityThreshold.key()); + weightBasedParametersForValidation.add(Config.MemoryCapacityThreshold.key()); + weightBasedParametersForValidation.add(Config.PublicIpCapacityThreshold.key()); + weightBasedParametersForValidation.add(Config.PrivateIpCapacityThreshold.key()); + weightBasedParametersForValidation.add(Config.SecondaryStorageCapacityThreshold.key()); + weightBasedParametersForValidation.add(Config.VlanCapacityThreshold.key()); + weightBasedParametersForValidation.add(Config.DirectNetworkPublicIpCapacityThreshold.key()); + weightBasedParametersForValidation.add(Config.LocalStorageCapacityThreshold.key()); + weightBasedParametersForValidation.add(Config.StorageAllocatedCapacityDisableThreshold.key()); + weightBasedParametersForValidation.add(Config.StorageCapacityDisableThreshold.key()); + weightBasedParametersForValidation.add(Config.CPUCapacityDisableThreshold.key()); + weightBasedParametersForValidation.add(Config.MemoryCapacityDisableThreshold.key()); + weightBasedParametersForValidation.add(Config.AgentLoadThreshold.key()); + weightBasedParametersForValidation.add(Config.VmUserDispersionWeight.key()); + + + } + @Override public boolean start() { @@ -692,6 +716,18 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati } } + if (type.equals(Float.class)) { + try { + Float val = Float.parseFloat(value); + if (weightBasedParametersForValidation.contains(name) && (val < 0f || val > 1f)) { + throw new InvalidParameterValueException("Please enter a value between 0 and 1 for the configuration parameter: "+ name); + } + } catch (NumberFormatException e) { + s_logger.error("There was an error trying to parse the float value for:" + name); + throw new InvalidParameterValueException("There was an error trying to parse the float value for:" + name); + } + } + String range = c.getRange(); if (range == null) { return null; diff --git a/test/integration/smoke/test_scale_vm.py b/test/integration/smoke/test_scale_vm.py index fa2418b7cd8..e79e1264663 100644 --- a/test/integration/smoke/test_scale_vm.py +++ b/test/integration/smoke/test_scale_vm.py @@ -145,7 +145,7 @@ class TestScaleVm(cloudstackTestCase): #how does it work ?? cls._cleanup = [ cls.small_offering, - cls.account + #cls.account ] @classmethod @@ -173,9 +173,10 @@ class TestScaleVm(cloudstackTestCase): - self.debug("Scaling VM-ID: %s to service offering: %s" % ( + self.debug("Scaling VM-ID: %s to service offering: %s and state %s" % ( self.virtual_machine.id, - self.big_offering.id + self.big_offering.id, + self.virtual_machine.state )) cmd = scaleVirtualMachine.scaleVirtualMachineCmd() @@ -207,6 +208,12 @@ class TestScaleVm(cloudstackTestCase): "Check virtual machine ID of scaled VM" ) + self.debug("Scaling VM-ID: %s from service offering: %s to new service offering %s and the response says %s" % ( + self.virtual_machine.id, + self.virtual_machine.serviceofferingid, + self.big_offering.id, + vm_response.serviceofferingid + )) self.assertEqual( vm_response.serviceofferingid, self.big_offering.id,