diff --git a/lib/puppet/type/libvirtd_config.rb b/lib/puppet/type/libvirtd_config.rb index 7097873a3..05fb192aa 100644 --- a/lib/puppet/type/libvirtd_config.rb +++ b/lib/puppet/type/libvirtd_config.rb @@ -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 diff --git a/lib/puppet/type/nova_api_paste_ini.rb b/lib/puppet/type/nova_api_paste_ini.rb index 62dad9091..3fe2c45ce 100644 --- a/lib/puppet/type/nova_api_paste_ini.rb +++ b/lib/puppet/type/nova_api_paste_ini.rb @@ -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('') + end + + autorequire(:anchor) do + ['nova::install::end'] end end diff --git a/lib/puppet/type/nova_config.rb b/lib/puppet/type/nova_config.rb index e6bd15ee1..3abbc8150 100644 --- a/lib/puppet/type/nova_config.rb +++ b/lib/puppet/type/nova_config.rb @@ -54,8 +54,8 @@ Puppet::Type.newtype(:nova_config) do defaultto('') end - autorequire(:package) do - 'nova-common' + autorequire(:anchor) do + ['nova::install::end'] end end diff --git a/lib/puppet/type/nova_flavor.rb b/lib/puppet/type/nova_flavor.rb index 48587cf33..c8a6857b6 100644 --- a/lib/puppet/type/nova_flavor.rb +++ b/lib/puppet/type/nova_flavor.rb @@ -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 diff --git a/lib/puppet/type/nova_paste_api_ini.rb b/lib/puppet/type/nova_paste_api_ini.rb index 77564efc3..bb7e38cdc 100644 --- a/lib/puppet/type/nova_paste_api_ini.rb +++ b/lib/puppet/type/nova_paste_api_ini.rb @@ -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('') + end + + autorequire(:anchor) do + ['nova::install::end'] end end diff --git a/lib/puppet/type/novajoin_config.rb b/lib/puppet/type/novajoin_config.rb index ce18b43fd..e8667e04d 100644 --- a/lib/puppet/type/novajoin_config.rb +++ b/lib/puppet/type/novajoin_config.rb @@ -46,8 +46,8 @@ Puppet::Type.newtype(:novajoin_config) do defaultto('') end - autorequire(:package) do - 'novajoin' + autorequire(:anchor) do + ['nova::install::end'] end end diff --git a/lib/puppet/type/virtlogd_config.rb b/lib/puppet/type/virtlogd_config.rb index 167c93d40..c0f88ec17 100644 --- a/lib/puppet/type/virtlogd_config.rb +++ b/lib/puppet/type/virtlogd_config.rb @@ -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 diff --git a/spec/unit/type/libvirtd_config_spec.rb b/spec/unit/type/libvirtd_config_spec.rb new file mode 100644 index 000000000..2caaeea66 --- /dev/null +++ b/spec/unit/type/libvirtd_config_spec.rb @@ -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 diff --git a/spec/unit/type/nova_api_paste_spec.rb b/spec/unit/type/nova_api_paste_spec.rb index fd842d32c..ba440c16c 100644 --- a/spec/unit/type/nova_api_paste_spec.rb +++ b/spec/unit/type/nova_api_paste_spec.rb @@ -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 diff --git a/spec/unit/type/nova_config_spec.rb b/spec/unit/type/nova_config_spec.rb index f926ef373..c0f3f2690 100644 --- a/spec/unit/type/nova_config_spec.rb +++ b/spec/unit/type/nova_config_spec.rb @@ -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 diff --git a/spec/unit/type/nova_paste_api_spec.rb b/spec/unit/type/nova_paste_api_spec.rb index 7a54abd44..7afa69f8e 100644 --- a/spec/unit/type/nova_paste_api_spec.rb +++ b/spec/unit/type/nova_paste_api_spec.rb @@ -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 diff --git a/spec/unit/type/novajoin_config_spec.rb b/spec/unit/type/novajoin_config_spec.rb index 07a1b081a..84221ba8b 100644 --- a/spec/unit/type/novajoin_config_spec.rb +++ b/spec/unit/type/novajoin_config_spec.rb @@ -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 diff --git a/spec/unit/type/virtlogd_config_spec.rb b/spec/unit/type/virtlogd_config_spec.rb new file mode 100644 index 000000000..ba98ce964 --- /dev/null +++ b/spec/unit/type/virtlogd_config_spec.rb @@ -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