Files
puppet-nova/manifests/scheduler/filter.pp
Emilien Macchi 61bf070188 scheduler/filter: use os_service_default for arrays
Some arrays were set to False by default.
This patch makes the values with the following rules:
- default is $::os_service_default so Puppet won't try to configure it.
- if set to something, we'll validate it's an array that is not empty
  and configure the parameter.
- Otherwise, fallback to default.

That way, our users can let the default value or set an empty array, it
won't try to configure it; or set the parameters to an array and Puppet
will configure it properly.

Change-Id: Ib6c441f89f9cee81991fccdf1d3b4f6eb77e4d55
2016-07-07 10:54:29 -04:00

135 lines
5.5 KiB
Puppet

# == Class: nova:scheduler::filter
#
# This class is aim to configure nova.scheduler filter
#
# === Parameters:
#
# [*scheduler_host_manager*]
# (optional) The scheduler host manager class to use
# Defaults to 'host_manager'
#
# [*scheduler_max_attempts*]
# (optional) Maximum number of attempts to schedule an instance
# Defaults to '3'
#
# [*scheduler_host_subset_size*]
# (optional) defines the subset size that a host is chosen from
# Defaults to '1'
#
# [*cpu_allocation_ratio*]
# (optional) Virtual CPU to Physical CPU allocation ratio
# Defaults to '16.0'
#
# [*disk_allocation_ratio*]
# (optional) Virtual disk to physical disk allocation ratio
# Defaults to '1.0'
#
# [*max_io_ops_per_host*]
# (optional) Ignore hosts that have too many builds/resizes/snaps/migrations
# Defaults to '8'
#
# [*isolated_images*]
# (optional) An array of images to run on isolated host
# Defaults to $::os_service_default
#
# [*isolated_hosts*]
# (optional) An array of hosts reserved for specific images
# Defaults to $::os_service_default
#
# [*max_instances_per_host*]
# (optional) Ignore hosts that have too many instances
# Defaults to '50'
#
# [*ram_allocation_ratio*]
# (optional) Virtual ram to physical ram allocation ratio
# Defaults to '1.5'
#
# [*scheduler_available_filters*]
# (optional) Filter classes available to the scheduler
# Defaults to 'nova.scheduler.filters.all_filters'
#
# [*scheduler_default_filters*]
# (optional) An array of filters to be used by default
# Defaults to $::os_service_default
#
# [*scheduler_weight_classes*]
# (optional) Which weight class names to use for weighing hosts
# Defaults to 'nova.scheduler.weights.all_weighers'
#
# [*baremetal_scheduler_default_filters*]
# (optional) An array of filters to be used by default for baremetal hosts
# Defaults to $::os_service_default
#
# [*scheduler_use_baremetal_filters*]
# (optional) Use baremetal_scheduler_default_filters or not.
# Defaults to false
#
class nova::scheduler::filter (
$scheduler_host_manager = 'host_manager',
$scheduler_max_attempts = '3',
$scheduler_host_subset_size = '1',
$cpu_allocation_ratio = '16.0',
$disk_allocation_ratio = '1.0',
$max_io_ops_per_host = '8',
$max_instances_per_host = '50',
$ram_allocation_ratio = '1.5',
$isolated_images = $::os_service_default,
$isolated_hosts = $::os_service_default,
$scheduler_available_filters = 'nova.scheduler.filters.all_filters',
$scheduler_default_filters = $::os_service_default,
$scheduler_weight_classes = 'nova.scheduler.weights.all_weighers',
$baremetal_scheduler_default_filters = $::os_service_default,
$scheduler_use_baremetal_filters = false,
) {
include ::nova::deps
# The following values are following this rule:
# - default is $::os_service_default so Puppet won't try to configure it.
# - if set, we'll validate it's an array that is not empty and configure the parameter.
# - Otherwise, fallback to default.
if !is_service_default($scheduler_default_filters) and !empty($scheduler_default_filters){
validate_array($scheduler_default_filters)
$scheduler_default_filters_real = join($scheduler_default_filters, ',')
} else {
$scheduler_default_filters_real = $::os_service_default
}
if !is_service_default($baremetal_scheduler_default_filters) and !empty($baremetal_scheduler_default_filters){
validate_array($baremetal_scheduler_default_filters)
$baremetal_scheduler_default_filters_real = join($baremetal_scheduler_default_filters, ',')
} else {
$baremetal_scheduler_default_filters_real = $::os_service_default
}
if !is_service_default($isolated_images) and !empty($isolated_images){
validate_array($isolated_images)
$isolated_images_real = join($isolated_images, ',')
} else {
$isolated_images_real = $::os_service_default
}
if !is_service_default($isolated_hosts) and !empty($isolated_hosts){
validate_array($isolated_hosts)
$isolated_hosts_real = join($isolated_hosts, ',')
} else {
$isolated_hosts_real = $::os_service_default
}
nova_config {
'DEFAULT/scheduler_host_manager': value => $scheduler_host_manager;
'DEFAULT/scheduler_max_attempts': value => $scheduler_max_attempts;
'DEFAULT/scheduler_host_subset_size': value => $scheduler_host_subset_size;
'DEFAULT/cpu_allocation_ratio': value => $cpu_allocation_ratio;
'DEFAULT/disk_allocation_ratio': value => $disk_allocation_ratio;
'DEFAULT/max_io_ops_per_host': value => $max_io_ops_per_host;
'DEFAULT/max_instances_per_host': value => $max_instances_per_host;
'DEFAULT/ram_allocation_ratio': value => $ram_allocation_ratio;
'DEFAULT/scheduler_available_filters': value => $scheduler_available_filters;
'DEFAULT/scheduler_weight_classes': value => $scheduler_weight_classes;
'DEFAULT/scheduler_use_baremetal_filters': value => $scheduler_use_baremetal_filters;
'DEFAULT/scheduler_default_filters': value => $scheduler_default_filters_real;
'DEFAULT/baremetal_scheduler_default_filters': value => $baremetal_scheduler_default_filters_real;
'DEFAULT/isolated_images': value => $isolated_images_real;
'DEFAULT/isolated_hosts': value => $isolated_hosts_real;
}
}