diff options
author | Luke Kanies <luke@madstop.com> | 2009-06-14 19:27:30 -0500 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2009-06-14 19:27:30 -0500 |
commit | ed876e0264bbb1ba86bc302d517d8f48f388da3e (patch) | |
tree | 3ff70b82002c608deb2a3bd66e5b8d0f272d6ccf /lib/puppet | |
parent | bd81c25b4072c3426af67e0366b18436c8236dc4 (diff) | |
download | puppet-ed876e0264bbb1ba86bc302d517d8f48f388da3e.tar.gz puppet-ed876e0264bbb1ba86bc302d517d8f48f388da3e.tar.xz puppet-ed876e0264bbb1ba86bc302d517d8f48f388da3e.zip |
Refactoring part of the file/filebucket integration
The goal of this commit is to fix ordering issues
that could result when the filebuckets are added
to the catalog after the resources that use them.
This condition showed up somewhat arbitrarily.
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'lib/puppet')
-rw-r--r-- | lib/puppet/type/file.rb | 72 |
1 files changed, 30 insertions, 42 deletions
diff --git a/lib/puppet/type/file.rb b/lib/puppet/type/file.rb index 721b5a1fa..55d4ec73b 100644 --- a/lib/puppet/type/file.rb +++ b/lib/puppet/type/file.rb @@ -87,7 +87,7 @@ module Puppet filebucketed files. " - defaultto { "puppet" } + defaultto "puppet" munge do |value| # I don't really know how this is happening. @@ -98,27 +98,10 @@ module Puppet false when true, "true", ".puppet-bak", :true ".puppet-bak" - when /^\./ - value when String - # We can't depend on looking this up right now, - # we have to do it after all of the objects - # have been instantiated. - if resource.catalog and bucketobj = resource.catalog.resource(:filebucket, value) - @resource.bucket = bucketobj.bucket - bucketobj.title - else - # Set it to the string; finish() turns it into a - # filebucket. - @resource.bucket = value - value - end - when Puppet::Network::Client.client(:Dipper) - @resource.bucket = value - value.name + value else - self.fail "Invalid backup type %s" % - value.inspect + self.fail "Invalid backup type %s" % value.inspect end end end @@ -250,8 +233,6 @@ module Puppet newvalues(:first, :all) end - attr_accessor :bucket - # Autorequire any parent directories. autorequire(:file) do if self[:path] @@ -349,6 +330,32 @@ module Puppet return asuser end + def bucket + return @bucket if defined?(@bucket) and @bucket + + backup = self[:backup] + return nil unless backup + return nil if backup =~ /^\./ + + unless catalog or backup == "puppet" + fail "Can not find filebucket for backups without a catalog" + end + + unless catalog and filebucket = catalog.resource(:filebucket, backup) or backup == "puppet" + fail "Could not find filebucket %s specified in backup" % backup + end + + return default_bucket unless filebucket + + @bucket = filebucket.bucket + + return @bucket + end + + def default_bucket + Puppet::Type.type(:filebucket).mkdefaultbucket.bucket + end + # Does the file currently exist? Just checks for whether # we have a stat def exist? @@ -359,26 +366,7 @@ module Puppet # there is one. def finish # Look up our bucket, if there is one - if bucket = self.bucket - case bucket - when String - if catalog and obj = catalog.resource(:filebucket, bucket) - self.bucket = obj.bucket - elsif bucket == "puppet" - obj = Puppet::Network::Client.client(:Dipper).new( - :Path => Puppet[:clientbucketdir] - ) - self.bucket = obj - else - self.fail "Could not find filebucket '%s'" % bucket - end - when Puppet::Network::Client.client(:Dipper) # things are hunky-dorey - when Puppet::Type::Filebucket # things are hunky-dorey - self.bucket = bucket.bucket - else - self.fail "Invalid bucket type %s" % bucket.class - end - end + bucket() super end |