diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java index 89a640daed4..704162e19c1 100755 --- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java +++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java @@ -324,6 +324,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 { @@ -336,6 +337,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati Long.parseLong(Config.DefaultPageSize.getDefaultValue())); populateConfigValuesForValidationSet(); + weightBasedParametersForValidation(); return true; } @@ -361,6 +363,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() { @@ -733,6 +757,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 b23ddd1b2cd..fd8d61e58f7 100644 --- a/test/integration/smoke/test_scale_vm.py +++ b/test/integration/smoke/test_scale_vm.py @@ -142,7 +142,7 @@ class TestScaleVm(cloudstackTestCase): #how does it work ?? cls._cleanup = [ cls.small_offering, - cls.account + #cls.account ] @classmethod @@ -170,9 +170,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() @@ -204,6 +205,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,