Reflect provider change in puppet-openstacklib
With the creation of the new openstack_config provider, some processing
that was done in tempest_config has been centralized in
openstack_config.
Impacted methods are :
* section
* setting
* separator
Also, this commit adds the fact that, when passing a specific string
(ensure_absent_val) the provider will behave as if ensure => absent was
specified. '<SERVICE DEFAULT>' is the default value for
ensure_absent_val.
The use case is the following :
tempest_config { 'DEFAULT/foo' : value => 'bar' } # will work as usual
tempest_config { 'DEFAULT/foo' : value => '<SERVICE DEFAULT>' } # will mean absent
That means that all the current :
if $myvar {
tempest_config { 'DEFAULT/foo' : value => $myvar }
} else {
tempest_config { 'DEFAULT/foo' : ensure => absent }
}
can be removed in favor of :
tempest_config { 'DEFAULT/foo' : value => $myvar }
If for any reason '<SERVICE DEFAULT>' turns out to be a valid value for
a specific parameter. One could by pass that doing the following :
tempest_config { 'DEFAULT/foo' : value => '<SERVICE DEFAULT>',
ensure_absent_val => 'foo' }
Change-Id: Idb64253273ef5a1e4bc0311e1d5bb265a820b9b7
Depends-On: I0eeebde3aac2662cc7e69bfad7f8d2481463a218
This commit is contained in:
@@ -2,6 +2,7 @@ fixtures:
|
||||
repositories:
|
||||
stdlib: 'git://github.com/puppetlabs/puppetlabs-stdlib.git'
|
||||
inifile: 'git://github.com/puppetlabs/puppetlabs-inifile'
|
||||
openstacklib: 'git://github.com/stackforge/puppet-openstacklib.git'
|
||||
vcsrepo: 'git://github.com/puppetlabs/puppetlabs-vcsrepo'
|
||||
symlinks:
|
||||
tempest: "#{source_dir}"
|
||||
|
||||
@@ -1,18 +1,10 @@
|
||||
Puppet::Type.type(:tempest_config).provide(
|
||||
:ini_setting,
|
||||
:parent => Puppet::Type.type(:ini_setting).provider(:ruby)
|
||||
:parent => Puppet::Type.type(:openstack_config).provider(:ini_setting)
|
||||
) do
|
||||
|
||||
def section
|
||||
resource[:name].split('/', 2).first
|
||||
end
|
||||
|
||||
def setting
|
||||
resource[:name].split('/', 2).last
|
||||
end
|
||||
|
||||
def separator
|
||||
'='
|
||||
def file_path
|
||||
resource[:path]
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -14,6 +14,7 @@ Puppet::Type.newtype(:tempest_config) do
|
||||
value.capitalize! if value =~ /^(true|false)$/i
|
||||
value
|
||||
end
|
||||
newvalues(/^[\S ]*$/)
|
||||
|
||||
def is_to_s( currentvalue )
|
||||
if resource.secret?
|
||||
@@ -49,4 +50,9 @@ Puppet::Type.newtype(:tempest_config) do
|
||||
end
|
||||
end
|
||||
|
||||
newparam(:ensure_absent_val) do
|
||||
desc 'A value that is specified as the value property will behave as if ensure => absent was specified'
|
||||
defaultto('<SERVICE DEFAULT>')
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -9,6 +9,17 @@ $LOAD_PATH.push(
|
||||
'inifile',
|
||||
'lib')
|
||||
)
|
||||
$LOAD_PATH.push(
|
||||
File.join(
|
||||
File.dirname(__FILE__),
|
||||
'..',
|
||||
'..',
|
||||
'..',
|
||||
'fixtures',
|
||||
'modules',
|
||||
'openstacklib',
|
||||
'lib')
|
||||
)
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
@@ -32,4 +43,23 @@ describe provider_class do
|
||||
expect(provider.section).to eq('dude')
|
||||
expect(provider.setting).to eq('foo')
|
||||
end
|
||||
|
||||
it 'should ensure absent when <SERVICE DEFAULT> is specified as a value' do
|
||||
resource = Puppet::Type::Tempest_config.new(
|
||||
{:name => 'dude/foo', :value => '<SERVICE DEFAULT>', :path => '/tmp/tempest.conf' }
|
||||
)
|
||||
provider = provider_class.new(resource)
|
||||
provider.exists?
|
||||
expect(resource[:ensure]).to eq :absent
|
||||
end
|
||||
|
||||
it 'should ensure absent when value matches ensure_absent_val' do
|
||||
resource = Puppet::Type::Tempest_config.new(
|
||||
{:name => 'dude/foo', :value => 'foo', :ensure_absent_val => 'foo', :path => '/tmp/tempest.conf' }
|
||||
)
|
||||
provider = provider_class.new(resource)
|
||||
provider.exists?
|
||||
expect(resource[:ensure]).to eq :absent
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user