Merge "Use anchor to require necessary packages"

This commit is contained in:
Zuul 2020-05-04 15:30:21 +00:00 committed by Gerrit Code Review
commit 93e988c187
13 changed files with 85 additions and 27 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View 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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View 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