diff --git a/packstack/installer/engine_validators.py b/packstack/installer/engine_validators.py index f048e0c7a..4534c5f48 100644 --- a/packstack/installer/engine_validators.py +++ b/packstack/installer/engine_validators.py @@ -18,7 +18,7 @@ from .setup_controller import Controller from .exceptions import ParamValidationError -__all__ = ('ParamValidationError', 'validate_integer', +__all__ = ('ParamValidationError', 'validate_integer', 'validate_float', 'validate_regexp', 'validate_port', 'validate_not_empty', 'validate_options', 'validate_ip', 'validate_multi_ip', 'validate_file', 'validate_ping', 'validate_ssh', @@ -39,6 +39,20 @@ def validate_integer(param, options=None): raise ParamValidationError(msg % param) +def validate_float(param, options=None): + """ + Raises ParamValidationError if given param is not a float. + """ + options = options or [] + try: + float(param) + except ValueError: + logging.debug('validate_float(%s, options=%s) failed.' % + (param, options)) + msg = 'Given value is not a float: %s' + raise ParamValidationError(msg % param) + + def validate_regexp(param, options=None): """ Raises ParamValidationError if given param doesn't match at least diff --git a/packstack/installer/run_setup.py b/packstack/installer/run_setup.py index bba950cd0..cb340e6d4 100644 --- a/packstack/installer/run_setup.py +++ b/packstack/installer/run_setup.py @@ -98,7 +98,7 @@ def _getInputFromUser(param): else: userInput = commandLineValues[param.getKey("CONF_NAME")] # If DEFAULT_VALUE is set and user did not input anything - if userInput == "" and len(param.getKey("DEFAULT_VALUE")) > 0: + if userInput == "" and len(str(param.getKey("DEFAULT_VALUE"))) > 0: userInput = param.getKey("DEFAULT_VALUE") # Param processing diff --git a/packstack/plugins/nova_300.py b/packstack/plugins/nova_300.py index cc7be3593..3a404c1c5 100644 --- a/packstack/plugins/nova_300.py +++ b/packstack/plugins/nova_300.py @@ -181,6 +181,34 @@ def initConfig(controllerObject): "USE_DEFAULT" : False, "NEED_CONFIRM" : False, "CONDITION" : False }, + {"CMD_OPTION" : "novasched-cpu-allocation-ratio", + "USAGE" : "The overcommitment ratio for virtual to physical CPUs. " + "Set to 1.0 to disable CPU overcommitment", + "PROMPT" : "Enter the CPU overcommitment ratio. " + "Set to 1.0 to disable CPU overcommitment", + "OPTION_LIST" : [], + "VALIDATORS" : [validate.validate_float], + "DEFAULT_VALUE" : 16.0, + "MASK_INPUT" : False, + "LOOSE_VALIDATION": True, + "CONF_NAME" : "CONFIG_NOVA_SCHED_CPU_ALLOC_RATIO", + "USE_DEFAULT" : False, + "NEED_CONFIRM" : False, + "CONDITION" : False }, + {"CMD_OPTION" : "novasched-ram-allocation-ratio", + "USAGE" : "The overcommitment ratio for virtual to physical RAM. " + "Set to 1.0 to disable RAM overcommitment", + "PROMPT" : "Enter the RAM overcommitment ratio. " + "Set to 1.0 to disable RAM overcommitment", + "OPTION_LIST" : [], + "VALIDATORS" : [validate.validate_float], + "DEFAULT_VALUE" : 1.5, + "MASK_INPUT" : False, + "LOOSE_VALIDATION": True, + "CONF_NAME" : "CONFIG_NOVA_SCHED_RAM_ALLOC_RATIO", + "USE_DEFAULT" : False, + "NEED_CONFIRM" : False, + "CONDITION" : False }, ] groupDict = { "GROUP_NAME" : "NOVA", "DESCRIPTION" : "Nova Options", diff --git a/packstack/puppet/templates/nova_sched.pp b/packstack/puppet/templates/nova_sched.pp index 860cfc049..1278568c7 100644 --- a/packstack/puppet/templates/nova_sched.pp +++ b/packstack/puppet/templates/nova_sched.pp @@ -1,3 +1,13 @@ +nova_config{ + # OpenStack doesn't include the CoreFilter (= CPU Filter) by default + "DEFAULT/scheduler_default_filters": + value => "RetryFilter,AvailabilityZoneFilter,RamFilter,ComputeFilter,ComputeCapabilitiesFilter,ImagePropertiesFilter,CoreFilter"; + "DEFAULT/cpu_allocation_ratio": + value => "%(CONFIG_NOVA_SCHED_CPU_ALLOC_RATIO)s"; + "DEFAULT/ram_allocation_ratio": + value => "%(CONFIG_NOVA_SCHED_RAM_ALLOC_RATIO)s"; +} + class {"nova::scheduler": enabled => true, }