Add MultiStrOpt for scheduler_available_filters
scheduler_available_filters option defines filter classes made available to the nova scheduler. This parameter can be used multiple times or it can be set as array value. It is helpful when owner want to add to nova scheduler external filters. Co-Authored-By: Daniel Pawlik <daniel.pawlik@corp.ovh.com> Change-Id: I6be7bb4cea1906bd98c513bd2d01153e4643e3ac Closes-Bug: #1591998
This commit is contained in:
parent
c3f198667a
commit
e7fe8c16ae
@ -1,6 +1,6 @@
|
||||
Puppet::Type.type(:nova_config).provide(
|
||||
:ini_setting,
|
||||
:parent => Puppet::Type.type(:openstack_config).provider(:ini_setting)
|
||||
:openstackconfig,
|
||||
:parent => Puppet::Type.type(:openstack_config).provider(:ruby)
|
||||
) do
|
||||
|
||||
def self.file_path
|
@ -7,14 +7,22 @@ Puppet::Type.newtype(:nova_config) do
|
||||
newvalues(/\S+\/\S+/)
|
||||
end
|
||||
|
||||
newproperty(:value) do
|
||||
newproperty(:value, :array_matching => :all) do
|
||||
desc 'The value of the setting to be defined.'
|
||||
def insync?(is)
|
||||
return true if @should.empty?
|
||||
return false unless is.is_a? Array
|
||||
return false unless is.length == @should.length
|
||||
return (
|
||||
is & @should == is or
|
||||
is & @should.map(&:to_s) == is
|
||||
)
|
||||
end
|
||||
munge do |value|
|
||||
value = value.to_s.strip
|
||||
value.capitalize! if value =~ /^(true|false)$/i
|
||||
value
|
||||
end
|
||||
newvalues(/^[\S ]*$/)
|
||||
|
||||
def is_to_s( currentvalue )
|
||||
if resource.secret?
|
||||
|
@ -33,8 +33,9 @@
|
||||
# Defaults to '50'
|
||||
#
|
||||
# [*scheduler_available_filters*]
|
||||
# (optional) Filter classes available to the scheduler
|
||||
# Defaults to 'nova.scheduler.filters.all_filters'
|
||||
# (optional) An array with filter classes available to the scheduler.
|
||||
# Example: ['first.filter.class', 'second.filter.class']
|
||||
# Defaults to ['nova.scheduler.filters.all_filters']
|
||||
#
|
||||
# [*scheduler_default_filters*]
|
||||
# (optional) An array of filters to be used by default
|
||||
@ -74,7 +75,7 @@ class nova::scheduler::filter (
|
||||
$max_instances_per_host = '50',
|
||||
$isolated_images = $::os_service_default,
|
||||
$isolated_hosts = $::os_service_default,
|
||||
$scheduler_available_filters = 'nova.scheduler.filters.all_filters',
|
||||
$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,
|
||||
@ -97,6 +98,14 @@ class nova::scheduler::filter (
|
||||
} else {
|
||||
$scheduler_default_filters_real = $::os_service_default
|
||||
}
|
||||
|
||||
if is_array($scheduler_available_filters) {
|
||||
$scheduler_available_filters_real = $scheduler_available_filters
|
||||
} else {
|
||||
warning('scheduler_available_filters must be an array and will fail in the future')
|
||||
$scheduler_available_filters_real = any2array($scheduler_available_filters)
|
||||
}
|
||||
|
||||
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, ',')
|
||||
@ -134,7 +143,7 @@ class nova::scheduler::filter (
|
||||
'DEFAULT/scheduler_host_subset_size': value => $scheduler_host_subset_size;
|
||||
'DEFAULT/max_io_ops_per_host': value => $max_io_ops_per_host;
|
||||
'DEFAULT/max_instances_per_host': value => $max_instances_per_host;
|
||||
'DEFAULT/scheduler_available_filters': value => $scheduler_available_filters;
|
||||
'DEFAULT/scheduler_available_filters': value => $scheduler_available_filters_real;
|
||||
'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;
|
||||
|
@ -0,0 +1,3 @@
|
||||
---
|
||||
upgrade:
|
||||
- Add MultiStrOpt for scheduler_available_filters parameter.
|
@ -14,7 +14,7 @@ describe 'nova::scheduler::filter' do
|
||||
it { is_expected.to contain_nova_config('DEFAULT/scheduler_host_subset_size').with_value('1') }
|
||||
it { is_expected.to contain_nova_config('DEFAULT/max_io_ops_per_host').with_value('8') }
|
||||
it { is_expected.to contain_nova_config('DEFAULT/max_instances_per_host').with_value('50') }
|
||||
it { is_expected.to contain_nova_config('DEFAULT/scheduler_available_filters').with_value('nova.scheduler.filters.all_filters') }
|
||||
it { is_expected.to contain_nova_config('DEFAULT/scheduler_available_filters').with_value(['nova.scheduler.filters.all_filters']) }
|
||||
it { is_expected.to contain_nova_config('DEFAULT/scheduler_weight_classes').with_value('nova.scheduler.weights.all_weighers') }
|
||||
it { is_expected.to contain_nova_config('DEFAULT/scheduler_use_baremetal_filters').with_value(false) }
|
||||
it { is_expected.to contain_nova_config('DEFAULT/isolated_images').with_value('<SERVICE DEFAULT>') }
|
||||
@ -30,7 +30,9 @@ describe 'nova::scheduler::filter' do
|
||||
:isolated_hosts => ['192.168.1.2','192.168.1.3'],
|
||||
:scheduler_default_filters => ['RetryFilter','AvailabilityZoneFilter','RamFilter'],
|
||||
:scheduler_use_baremetal_filters => true,
|
||||
:baremetal_scheduler_default_filters => ['ExactRamFilter','ExactDiskFilter','ExactCoreFilter'], }
|
||||
:baremetal_scheduler_default_filters => ['ExactRamFilter','ExactDiskFilter','ExactCoreFilter'],
|
||||
:scheduler_available_filters => ['nova_filter1','nova_filter2']
|
||||
}
|
||||
end
|
||||
|
||||
it { is_expected.to contain_nova_config('DEFAULT/scheduler_max_attempts').with_value('4') }
|
||||
@ -39,6 +41,7 @@ describe 'nova::scheduler::filter' do
|
||||
it { is_expected.to contain_nova_config('DEFAULT/scheduler_default_filters').with_value('RetryFilter,AvailabilityZoneFilter,RamFilter') }
|
||||
it { is_expected.to contain_nova_config('DEFAULT/scheduler_use_baremetal_filters').with_value(true) }
|
||||
it { is_expected.to contain_nova_config('DEFAULT/baremetal_scheduler_default_filters').with_value('ExactRamFilter,ExactDiskFilter,ExactCoreFilter') }
|
||||
it { is_expected.to contain_nova_config('DEFAULT/scheduler_available_filters').with_value(['nova_filter1','nova_filter2']) }
|
||||
end
|
||||
|
||||
context 'when overriding params with empty arrays' do
|
||||
|
@ -26,7 +26,7 @@ $LOAD_PATH.push(
|
||||
'lib')
|
||||
)
|
||||
require 'spec_helper'
|
||||
provider_class = Puppet::Type.type(:nova_config).provider(:ini_setting)
|
||||
provider_class = Puppet::Type.type(:nova_config).provider(:openstackconfig)
|
||||
describe provider_class do
|
||||
|
||||
it 'should default to the default setting when no other one is specified' do
|
@ -29,12 +29,12 @@ describe 'Puppet::Type.type(:nova_config)' do
|
||||
|
||||
it 'should accept a valid value' do
|
||||
@nova_config[:value] = 'bar'
|
||||
expect(@nova_config[:value]).to eq('bar')
|
||||
expect(@nova_config[:value]).to eq(['bar'])
|
||||
end
|
||||
|
||||
it 'should not accept a value with whitespace' do
|
||||
@nova_config[:value] = 'b ar'
|
||||
expect(@nova_config[:value]).to eq('b ar')
|
||||
expect(@nova_config[:value]).to eq(['b ar'])
|
||||
end
|
||||
|
||||
it 'should accept valid ensure values' do
|
||||
|
Loading…
x
Reference in New Issue
Block a user