diff options
| author | Andrew Shafer <andrew@reductivelabs.com> | 2008-12-08 00:09:50 -0700 |
|---|---|---|
| committer | James Turnbull <james@lovedthanlost.net> | 2008-12-08 19:44:29 +1100 |
| commit | 68ffd46c9fd87e07d0171e7daa54b951f621c7b7 (patch) | |
| tree | dc7b1cde4d3cb1468a655ec049b0152ebe17f7c9 | |
| parent | 7e2da7eeb25bb8879af40f12c4a04047a159374e (diff) | |
| download | puppet-68ffd46c9fd87e07d0171e7daa54b951f621c7b7.tar.gz puppet-68ffd46c9fd87e07d0171e7daa54b951f621c7b7.tar.xz puppet-68ffd46c9fd87e07d0171e7daa54b951f621c7b7.zip | |
Bug #1803 Zfs should auto require the ancestor file systems
| -rwxr-xr-x | lib/puppet/type/zfs.rb | 6 | ||||
| -rwxr-xr-x | spec/unit/type/zfs.rb | 17 |
2 files changed, 23 insertions, 0 deletions
diff --git a/lib/puppet/type/zfs.rb b/lib/puppet/type/zfs.rb index d3af3a461..3a8806a5e 100755 --- a/lib/puppet/type/zfs.rb +++ b/lib/puppet/type/zfs.rb @@ -40,6 +40,12 @@ module Puppet #strip the zpool off the zfs name and autorequire it [@parameters[:name].value.split('/')[0]] end + + autorequire(:zfs) do + #slice and dice, we want all the zfs before this one + names = @parameters[:name].value.split('/') + names.slice(1..-2).inject([]) { |a,v| a << "#{a.last}/#{v}" }.collect { |fs| names[0] + fs } + end end end diff --git a/spec/unit/type/zfs.rb b/spec/unit/type/zfs.rb index 434415e24..bce6500b1 100755 --- a/spec/unit/type/zfs.rb +++ b/spec/unit/type/zfs.rb @@ -25,4 +25,21 @@ describe zpool do zpool.attrclass(parameter).ancestors.should be_include(Puppet::Parameter) end end + + it "should autorequire the containing zfss and the zpool" do + #this is a little funky because the autorequire depends on a property with a feature + foo_pool = Puppet.type(:zpool).create(:name => "foo") + + foo_bar_zfs = Puppet.type(:zfs).create(:name => "foo/bar") + foo_bar_baz_zfs = Puppet.type(:zfs).create(:name => "foo/bar/baz") + foo_bar_baz_buz_zfs = Puppet.type(:zfs).create(:name => "foo/bar/baz/buz") + + config = Puppet::Node::Catalog.new :testing do |conf| + [foo_pool, foo_bar_zfs, foo_bar_baz_zfs, foo_bar_baz_buz_zfs].each { |resource| conf.add_resource resource } + end + + req = foo_bar_baz_buz_zfs.autorequire.collect { |edge| edge.source.ref } + + [foo_pool.ref, foo_bar_zfs.ref, foo_bar_baz_zfs.ref].each { |ref| req.include?(ref).should == true } + end end |
