Use anchor to require necessary packages
... so that correct packages are required according without re-defining them in resource implementations. Change-Id: If3ae4736d655975d83f49676b8128d4e9f8b0cf4
This commit is contained in:
parent
5f453cd9bd
commit
fa5e4ff7cb
@ -39,8 +39,8 @@ Puppet::Type.newtype(:libvirtd_config) do
|
||||
defaultto false
|
||||
end
|
||||
|
||||
autorequire(:package) do
|
||||
'libvirt-daemon'
|
||||
autorequire(:anchor) do
|
||||
['nova::install::end']
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -40,8 +40,13 @@ Puppet::Type.newtype(:nova_api_paste_ini) do
|
||||
defaultto false
|
||||
end
|
||||
|
||||
autorequire(:package) do
|
||||
'nova-common'
|
||||
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
|
||||
|
||||
autorequire(:anchor) do
|
||||
['nova::install::end']
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -54,8 +54,8 @@ Puppet::Type.newtype(:nova_config) do
|
||||
defaultto('<SERVICE DEFAULT>')
|
||||
end
|
||||
|
||||
autorequire(:package) do
|
||||
'nova-common'
|
||||
autorequire(:anchor) do
|
||||
['nova::install::end']
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -60,8 +60,8 @@ Puppet::Type.newtype(:nova_flavor) do
|
||||
end
|
||||
|
||||
# Require the nova-api service to be running
|
||||
autorequire(:service) do
|
||||
['nova-api']
|
||||
autorequire(:anchor) do
|
||||
['nova::service::end']
|
||||
end
|
||||
|
||||
newparam(:name, :namevar => true) do
|
||||
|
@ -40,8 +40,13 @@ Puppet::Type.newtype(:nova_paste_api_ini) do
|
||||
defaultto false
|
||||
end
|
||||
|
||||
autorequire(:package) do
|
||||
'nova-common'
|
||||
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
|
||||
|
||||
autorequire(:anchor) do
|
||||
['nova::install::end']
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -46,8 +46,8 @@ Puppet::Type.newtype(:novajoin_config) do
|
||||
defaultto('<SERVICE DEFAULT>')
|
||||
end
|
||||
|
||||
autorequire(:package) do
|
||||
'novajoin'
|
||||
autorequire(:anchor) do
|
||||
['nova::install::end']
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -39,8 +39,8 @@ Puppet::Type.newtype(:virtlogd_config) do
|
||||
defaultto false
|
||||
end
|
||||
|
||||
autorequire(:package) do
|
||||
'libvirt-daemon'
|
||||
autorequire(:anchor) do
|
||||
['nova::install::end']
|
||||
end
|
||||
|
||||
end
|
||||
|
24
spec/unit/type/libvirtd_config_spec.rb
Normal file
24
spec/unit/type/libvirtd_config_spec.rb
Normal file
@ -0,0 +1,24 @@
|
||||
require 'puppet'
|
||||
require 'puppet/type/libvirtd_config'
|
||||
|
||||
describe 'Puppet::Type.type(:libvirtd_config)' do
|
||||
before :each do
|
||||
@libvirtd_config = Puppet::Type.type(:libvirtd_config).new(:name => 'DEFAULT/foo', :value => 'bar')
|
||||
end
|
||||
|
||||
it 'should accept a valid value' do
|
||||
@libvirtd_config[:value] = 'bar'
|
||||
expect(@libvirtd_config[:value]).to eq('bar')
|
||||
end
|
||||
|
||||
it 'should autorequire the package that install the file' do
|
||||
catalog = Puppet::Resource::Catalog.new
|
||||
anchor = Puppet::Type.type(:anchor).new(:name => 'nova::install::end')
|
||||
catalog.add_resource anchor, @libvirtd_config
|
||||
dependency = @libvirtd_config.autorequire
|
||||
expect(dependency.size).to eq(1)
|
||||
expect(dependency[0].target).to eq(@libvirtd_config)
|
||||
expect(dependency[0].source).to eq(anchor)
|
||||
end
|
||||
|
||||
end
|
@ -13,12 +13,12 @@ describe 'Puppet::Type.type(:nova_api_paste_ini)' do
|
||||
|
||||
it 'should autorequire the package that install the file' do
|
||||
catalog = Puppet::Resource::Catalog.new
|
||||
package = Puppet::Type.type(:package).new(:name => 'nova-common')
|
||||
catalog.add_resource package, @nova_api_paste_ini
|
||||
anchor = Puppet::Type.type(:anchor).new(:name => 'nova::install::end')
|
||||
catalog.add_resource anchor, @nova_api_paste_ini
|
||||
dependency = @nova_api_paste_ini.autorequire
|
||||
expect(dependency.size).to eq(1)
|
||||
expect(dependency[0].target).to eq(@nova_api_paste_ini)
|
||||
expect(dependency[0].source).to eq(package)
|
||||
expect(dependency[0].source).to eq(anchor)
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -1,5 +1,6 @@
|
||||
require 'puppet'
|
||||
require 'puppet/type/nova_config'
|
||||
|
||||
describe 'Puppet::Type.type(:nova_config)' do
|
||||
before :each do
|
||||
@nova_config = Puppet::Type.type(:nova_config).new(:name => 'DEFAULT/foo', :value => 'bar')
|
||||
@ -52,13 +53,12 @@ describe 'Puppet::Type.type(:nova_config)' do
|
||||
|
||||
it 'should autorequire the package that install the file' do
|
||||
catalog = Puppet::Resource::Catalog.new
|
||||
package = Puppet::Type.type(:package).new(:name => 'nova-common')
|
||||
catalog.add_resource package, @nova_config
|
||||
anchor = Puppet::Type.type(:anchor).new(:name => 'nova::install::end')
|
||||
catalog.add_resource anchor, @nova_config
|
||||
dependency = @nova_config.autorequire
|
||||
expect(dependency.size).to eq(1)
|
||||
expect(dependency[0].target).to eq(@nova_config)
|
||||
expect(dependency[0].source).to eq(package)
|
||||
expect(dependency[0].source).to eq(anchor)
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
@ -13,12 +13,12 @@ describe 'Puppet::Type.type(:nova_paste_api_ini)' do
|
||||
|
||||
it 'should autorequire the package that install the file' do
|
||||
catalog = Puppet::Resource::Catalog.new
|
||||
package = Puppet::Type.type(:package).new(:name => 'nova-common')
|
||||
catalog.add_resource package, @nova_paste_api_ini
|
||||
anchor = Puppet::Type.type(:anchor).new(:name => 'nova::install::end')
|
||||
catalog.add_resource anchor, @nova_paste_api_ini
|
||||
dependency = @nova_paste_api_ini.autorequire
|
||||
expect(dependency.size).to eq(1)
|
||||
expect(dependency[0].target).to eq(@nova_paste_api_ini)
|
||||
expect(dependency[0].source).to eq(package)
|
||||
expect(dependency[0].source).to eq(anchor)
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -52,12 +52,12 @@ describe 'Puppet::Type.type(:novajoin_config)' do
|
||||
|
||||
it 'should autorequire the package that install the file' do
|
||||
catalog = Puppet::Resource::Catalog.new
|
||||
package = Puppet::Type.type(:package).new(:name => 'novajoin')
|
||||
catalog.add_resource package, @novajoin_config
|
||||
anchor = Puppet::Type.type(:anchor).new(:name => 'nova::install::end')
|
||||
catalog.add_resource anchor, @novajoin_config
|
||||
dependency = @novajoin_config.autorequire
|
||||
expect(dependency.size).to eq(1)
|
||||
expect(dependency[0].target).to eq(@novajoin_config)
|
||||
expect(dependency[0].source).to eq(package)
|
||||
expect(dependency[0].source).to eq(anchor)
|
||||
end
|
||||
|
||||
|
||||
|
24
spec/unit/type/virtlogd_config_spec.rb
Normal file
24
spec/unit/type/virtlogd_config_spec.rb
Normal file
@ -0,0 +1,24 @@
|
||||
require 'puppet'
|
||||
require 'puppet/type/virtlogd_config'
|
||||
|
||||
describe 'Puppet::Type.type(:virtlogd_config)' do
|
||||
before :each do
|
||||
@virtlogd_config = Puppet::Type.type(:virtlogd_config).new(:name => 'DEFAULT/foo', :value => 'bar')
|
||||
end
|
||||
|
||||
it 'should accept a valid value' do
|
||||
@virtlogd_config[:value] = 'bar'
|
||||
expect(@virtlogd_config[:value]).to eq('bar')
|
||||
end
|
||||
|
||||
it 'should autorequire the package that install the file' do
|
||||
catalog = Puppet::Resource::Catalog.new
|
||||
anchor = Puppet::Type.type(:anchor).new(:name => 'nova::install::end')
|
||||
catalog.add_resource anchor, @virtlogd_config
|
||||
dependency = @virtlogd_config.autorequire
|
||||
expect(dependency.size).to eq(1)
|
||||
expect(dependency[0].target).to eq(@virtlogd_config)
|
||||
expect(dependency[0].source).to eq(anchor)
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in New Issue
Block a user