Add nova::scheduler::filter for managing scheduler.filter
This patch is aim to add a new class to manage the filter params in nova.scheduler.The most useable params are the resource allocation ratio options. Fix bug #1201062 Change-Id: Iab2c76fdd07768471f6bab61aaf8c7eff6445a22
This commit is contained in:
92
manifests/scheduler/filter.pp
Normal file
92
manifests/scheduler/filter.pp
Normal file
@@ -0,0 +1,92 @@
|
||||
# == Class: nova:scheduler::filter
|
||||
#
|
||||
# This class is aim to configure nova.scheduler filter
|
||||
#
|
||||
# === Parameters:
|
||||
#
|
||||
# ==== Options defined in nova.scheduler.driver
|
||||
# scheduler_host_manager: The scheduler host manager class to use
|
||||
# scheduler_max_attempts: Maximum number of attempts to schedule an instance
|
||||
|
||||
# ==== Options defined in nova.scheduler.filter_scheduler
|
||||
# scheduler_host_subset_size: defines the subset size that a host is chosen from
|
||||
|
||||
# ==== Options defined in nova.scheduler.filters.core_filter
|
||||
# cpu_allocation_ratio: Virtual CPU to Physical CPU allocation ratio (float)
|
||||
|
||||
# ==== Options defined in nova.scheduler.filters.disk_filter
|
||||
# disk_allocation_ratio: Virtual disk to physical disk allocation ratio (float)
|
||||
|
||||
# ==== Options defined in nova.scheduler.filters.io_ops_filter
|
||||
# max_io_ops_per_host: Ignore hosts that have too many builds/resizes
|
||||
# /snaps/migrations (Int)
|
||||
|
||||
# ==== Options defined in nova.scheduler.filters.isolated_hosts_filter
|
||||
# isolated_images: Images to run on isolated host (list value)
|
||||
# isolated_hosts: Host reserved for specific images (list value)
|
||||
|
||||
# ==== Options defined in nova.scheduler.filters.num_instances_filter
|
||||
# max_instances_per_host: Ignore hosts that have too many instances (Int)
|
||||
|
||||
# ==== Options defined in nova.scheduler.filters.ram_filter
|
||||
# ram_allocation_ratio: Virtual ram to physical ram allocation ratio (Int)
|
||||
|
||||
# ==== Options defined in nova.scheduler.host_manager
|
||||
# scheduler_available_filters
|
||||
# scheduler_default_filters
|
||||
# scheduler_weight_classes
|
||||
#
|
||||
class nova::scheduler::filter (
|
||||
$scheduler_host_manager = 'nova.scheduler.host_manager.HostManager',
|
||||
$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 = false,
|
||||
$isolated_hosts = false,
|
||||
$scheduler_available_filters = 'nova.scheduler.filters.all_filters',
|
||||
$scheduler_default_filters = false,
|
||||
$scheduler_weight_classes = 'nova.scheduler.weights.all_weighers',
|
||||
) {
|
||||
|
||||
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
|
||||
}
|
||||
if ($scheduler_default_filters) {
|
||||
nova_config { 'DEFAULT/scheduler_default_filters': value => join($scheduler_default_filters,',')
|
||||
}
|
||||
} else {
|
||||
nova_config { 'DEFAULT/scheduler_default_filters': ensure => absent
|
||||
}
|
||||
}
|
||||
if ($isolated_images) {
|
||||
nova_config {
|
||||
'DEFAULT/isolated_images': value => join($isolated_images,',')
|
||||
}
|
||||
} else {
|
||||
nova_config {
|
||||
'DEFAULT/isolated_images': ensure => absent
|
||||
}
|
||||
}
|
||||
if ($isolated_hosts) {
|
||||
nova_config {
|
||||
'DEFAULT/isolated_hosts': value => join($isolated_hosts,',')
|
||||
}
|
||||
} else {
|
||||
nova_config {
|
||||
'DEFAULT/isolated_hosts': ensure => absent
|
||||
}
|
||||
}
|
||||
}
|
33
spec/classes/nova_scheduler_filter_spec.rb
Normal file
33
spec/classes/nova_scheduler_filter_spec.rb
Normal file
@@ -0,0 +1,33 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'nova::scheduler::filter' do
|
||||
|
||||
it { should contain_nova_config('DEFAULT/scheduler_host_manager').with_value('nova.scheduler.host_manager.HostManager') }
|
||||
it { should contain_nova_config('DEFAULT/scheduler_max_attempts').with_value('3') }
|
||||
it { should contain_nova_config('DEFAULT/scheduler_host_subset_size').with_value('1') }
|
||||
it { should contain_nova_config('DEFAULT/cpu_allocation_ratio').with_value('16.0') }
|
||||
it { should contain_nova_config('DEFAULT/disk_allocation_ratio').with_value('1.0') }
|
||||
it { should contain_nova_config('DEFAULT/max_io_ops_per_host').with_value('8') }
|
||||
it { should contain_nova_config('DEFAULT/max_instances_per_host').with_value('50') }
|
||||
it { should contain_nova_config('DEFAULT/ram_allocation_ratio').with_value('1.5') }
|
||||
it { should contain_nova_config('DEFAULT/scheduler_available_filters').with_value('nova.scheduler.filters.all_filters') }
|
||||
it { should contain_nova_config('DEFAULT/scheduler_weight_classes').with_value('nova.scheduler.weights.all_weighers') }
|
||||
|
||||
describe 'when overriding params' do
|
||||
|
||||
let :params do
|
||||
{:scheduler_max_attempts => '4',
|
||||
:isolated_images => ['ubuntu1','centos2'],
|
||||
:isolated_hosts => ['192.168.1.2','192.168.1.3'],
|
||||
:scheduler_default_filters => ['RetryFilter','AvailabilityZoneFilter','RamFilter']
|
||||
}
|
||||
end
|
||||
|
||||
it { should contain_nova_config('DEFAULT/scheduler_max_attempts').with_value('4') }
|
||||
it { should contain_nova_config('DEFAULT/isolated_images').with_value('ubuntu1,centos2') }
|
||||
it { should contain_nova_config('DEFAULT/isolated_hosts').with_value('192.168.1.2,192.168.1.3') }
|
||||
it { should contain_nova_config('DEFAULT/scheduler_default_filters').with_value('RetryFilter,AvailabilityZoneFilter,RamFilter') }
|
||||
|
||||
end
|
||||
|
||||
end
|
Reference in New Issue
Block a user