Use anchor to require necessary packages
... so that correct packages are required without re-defining them in resource implementations. Change-Id: I25f0aa5e0b8c8847627e37c396285131df6a2696
This commit is contained in:
parent
da1d7ff2c0
commit
6431321eee
@ -45,8 +45,8 @@ Puppet::Type.newtype(:aodh_api_paste_ini) do
|
|||||||
defaultto('<SERVICE DEFAULT>')
|
defaultto('<SERVICE DEFAULT>')
|
||||||
end
|
end
|
||||||
|
|
||||||
autorequire(:package) do
|
autorequire(:anchor) do
|
||||||
'aodh-common'
|
['aodh::install::end']
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -44,8 +44,8 @@ Puppet::Type.newtype(:aodh_config) do
|
|||||||
defaultto('<SERVICE DEFAULT>')
|
defaultto('<SERVICE DEFAULT>')
|
||||||
end
|
end
|
||||||
|
|
||||||
autorequire(:package) do
|
autorequire(:anchor) do
|
||||||
'aodh'
|
['aodh::install::end']
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -1,21 +1,11 @@
|
|||||||
require 'spec_helper'
|
require 'puppet'
|
||||||
# this hack is required for now to ensure that the path is set up correctly
|
|
||||||
# to retrieve the parent provider
|
|
||||||
$LOAD_PATH.push(
|
|
||||||
File.join(
|
|
||||||
File.dirname(__FILE__),
|
|
||||||
'..',
|
|
||||||
'..',
|
|
||||||
'fixtures',
|
|
||||||
'modules',
|
|
||||||
'inifile',
|
|
||||||
'lib')
|
|
||||||
)
|
|
||||||
require 'puppet/type/aodh_api_paste_ini'
|
require 'puppet/type/aodh_api_paste_ini'
|
||||||
|
|
||||||
describe 'Puppet::Type.type(:aodh_api_paste_ini)' do
|
describe 'Puppet::Type.type(:aodh_api_paste_ini)' do
|
||||||
before :each do
|
before :each do
|
||||||
@aodh_api_paste_ini = Puppet::Type.type(:aodh_api_paste_ini).new(:name => 'DEFAULT/foo', :value => 'bar')
|
@aodh_api_paste_ini = Puppet::Type.type(:aodh_api_paste_ini).new(:name => 'DEFAULT/foo', :value => 'bar')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should accept a valid value' do
|
it 'should accept a valid value' do
|
||||||
@aodh_api_paste_ini[:value] = 'bar'
|
@aodh_api_paste_ini[:value] = 'bar'
|
||||||
expect(@aodh_api_paste_ini[:value]).to eq('bar')
|
expect(@aodh_api_paste_ini[:value]).to eq('bar')
|
||||||
@ -23,12 +13,12 @@ describe 'Puppet::Type.type(:aodh_api_paste_ini)' do
|
|||||||
|
|
||||||
it 'should autorequire the package that install the file' do
|
it 'should autorequire the package that install the file' do
|
||||||
catalog = Puppet::Resource::Catalog.new
|
catalog = Puppet::Resource::Catalog.new
|
||||||
package = Puppet::Type.type(:package).new(:name => 'aodh-common')
|
anchor = Puppet::Type.type(:anchor).new(:name => 'aodh::install::end')
|
||||||
catalog.add_resource package, @aodh_api_paste_ini
|
catalog.add_resource anchor, @aodh_api_paste_ini
|
||||||
dependency = @aodh_api_paste_ini.autorequire
|
dependency = @aodh_api_paste_ini.autorequire
|
||||||
expect(dependency.size).to eq(1)
|
expect(dependency.size).to eq(1)
|
||||||
expect(dependency[0].target).to eq(@aodh_api_paste_ini)
|
expect(dependency[0].target).to eq(@aodh_api_paste_ini)
|
||||||
expect(dependency[0].source).to eq(package)
|
expect(dependency[0].source).to eq(anchor)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
require 'puppet'
|
require 'puppet'
|
||||||
require 'puppet/type/aodh_config'
|
require 'puppet/type/aodh_config'
|
||||||
|
|
||||||
describe 'Puppet::Type.type(:aodh_config)' do
|
describe 'Puppet::Type.type(:aodh_config)' do
|
||||||
before :each do
|
before :each do
|
||||||
@aodh_config = Puppet::Type.type(:aodh_config).new(:name => 'DEFAULT/foo', :value => 'bar')
|
@aodh_config = Puppet::Type.type(:aodh_config).new(:name => 'DEFAULT/foo', :value => 'bar')
|
||||||
@ -52,12 +53,12 @@ describe 'Puppet::Type.type(:aodh_config)' do
|
|||||||
|
|
||||||
it 'should autorequire the package that install the file' do
|
it 'should autorequire the package that install the file' do
|
||||||
catalog = Puppet::Resource::Catalog.new
|
catalog = Puppet::Resource::Catalog.new
|
||||||
package = Puppet::Type.type(:package).new(:name => 'aodh')
|
anchor = Puppet::Type.type(:anchor).new(:name => 'aodh::install::end')
|
||||||
catalog.add_resource package, @aodh_config
|
catalog.add_resource anchor, @aodh_config
|
||||||
dependency = @aodh_config.autorequire
|
dependency = @aodh_config.autorequire
|
||||||
expect(dependency.size).to eq(1)
|
expect(dependency.size).to eq(1)
|
||||||
expect(dependency[0].target).to eq(@aodh_config)
|
expect(dependency[0].target).to eq(@aodh_config)
|
||||||
expect(dependency[0].source).to eq(package)
|
expect(dependency[0].source).to eq(anchor)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user