diff options
author | Luke Kanies <luke@madstop.com> | 2008-08-25 18:00:42 -0700 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2008-08-26 22:40:42 -0700 |
commit | 8b45d13ab28837caf3bb09cc1c90ab61974bf4db (patch) | |
tree | f249010d44605ec22db96130d280039a8882a672 /lib | |
parent | 6ed8dfaf7c0cf091dca0374de310f524b0a033cc (diff) | |
download | puppet-8b45d13ab28837caf3bb09cc1c90ab61974bf4db.tar.gz puppet-8b45d13ab28837caf3bb09cc1c90ab61974bf4db.tar.xz puppet-8b45d13ab28837caf3bb09cc1c90ab61974bf4db.zip |
Adding automatic attribute collection to the new fileserving code.
Basically, this just includes a consistent method for collecting
info (either content or metadata) and then calls that method
when returning instances via the indirector.
It's such a large commit mostly because of small changes in the normal
code and large changes in the testing to accomodate those small changes.
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/puppet/file_serving/content.rb | 1 | ||||
-rw-r--r-- | lib/puppet/file_serving/fileset.rb | 2 | ||||
-rw-r--r-- | lib/puppet/file_serving/metadata.rb | 2 | ||||
-rw-r--r-- | lib/puppet/file_serving/terminus_helper.rb | 1 | ||||
-rw-r--r-- | lib/puppet/indirector/file_metadata/file.rb | 4 | ||||
-rw-r--r-- | lib/puppet/indirector/file_metadata/modules.rb | 2 | ||||
-rw-r--r-- | lib/puppet/indirector/file_server.rb | 1 | ||||
-rwxr-xr-x | lib/puppet/network/handler/fileserver.rb | 2 |
8 files changed, 9 insertions, 6 deletions
diff --git a/lib/puppet/file_serving/content.rb b/lib/puppet/file_serving/content.rb index 0f169c28b..c1ecff749 100644 --- a/lib/puppet/file_serving/content.rb +++ b/lib/puppet/file_serving/content.rb @@ -28,6 +28,7 @@ class Puppet::FileServing::Content < Puppet::FileServing::Base # Collect our data. def collect + return if stat.ftype == "directory" content end diff --git a/lib/puppet/file_serving/fileset.rb b/lib/puppet/file_serving/fileset.rb index fe54350b1..80a718c68 100644 --- a/lib/puppet/file_serving/fileset.rb +++ b/lib/puppet/file_serving/fileset.rb @@ -20,7 +20,7 @@ class Puppet::FileServing::Fileset # Now strip off the leading path, so each file becomes relative, and remove # any slashes that might end up at the beginning of the path. - result = files.collect { |file| file.sub(%r{^#{@path}/*}, '') } + result = files.collect { |file| file.sub(@path, '').sub(%r{^/},'') } # And add the path itself. result.unshift(".") diff --git a/lib/puppet/file_serving/metadata.rb b/lib/puppet/file_serving/metadata.rb index a1265dd8b..1cc3fa355 100644 --- a/lib/puppet/file_serving/metadata.rb +++ b/lib/puppet/file_serving/metadata.rb @@ -47,7 +47,7 @@ class Puppet::FileServing::Metadata < Puppet::FileServing::Base # Retrieve the attributes for this file, relative to a base directory. # Note that File.stat raises Errno::ENOENT if the file is absent and this # method does not catch that exception. - def collect_attributes + def collect real_path = full_path() stat = stat() @owner = stat.uid diff --git a/lib/puppet/file_serving/terminus_helper.rb b/lib/puppet/file_serving/terminus_helper.rb index bde0bd389..598a5007a 100644 --- a/lib/puppet/file_serving/terminus_helper.rb +++ b/lib/puppet/file_serving/terminus_helper.rb @@ -13,6 +13,7 @@ module Puppet::FileServing::TerminusHelper Puppet::FileServing::Fileset.new(path, args).files.collect do |file| inst = model.new(path, :relative_path => file) inst.links = request.options[:links] if request.options[:links] + inst.collect inst end end diff --git a/lib/puppet/indirector/file_metadata/file.rb b/lib/puppet/indirector/file_metadata/file.rb index c46015c38..bb586489d 100644 --- a/lib/puppet/indirector/file_metadata/file.rb +++ b/lib/puppet/indirector/file_metadata/file.rb @@ -11,7 +11,7 @@ class Puppet::Indirector::FileMetadata::File < Puppet::Indirector::DirectFileSer def find(request) return unless data = super - data.collect_attributes + data.collect return data end @@ -19,7 +19,7 @@ class Puppet::Indirector::FileMetadata::File < Puppet::Indirector::DirectFileSer def search(request) return unless result = super - result.each { |instance| instance.collect_attributes } + result.each { |instance| instance.collect } return result end diff --git a/lib/puppet/indirector/file_metadata/modules.rb b/lib/puppet/indirector/file_metadata/modules.rb index 5ed7a8a45..4598c2175 100644 --- a/lib/puppet/indirector/file_metadata/modules.rb +++ b/lib/puppet/indirector/file_metadata/modules.rb @@ -11,7 +11,7 @@ class Puppet::Indirector::FileMetadata::Modules < Puppet::Indirector::ModuleFile def find(*args) return unless instance = super - instance.collect_attributes + instance.collect instance end end diff --git a/lib/puppet/indirector/file_server.rb b/lib/puppet/indirector/file_server.rb index 476fc5b23..46a590f9c 100644 --- a/lib/puppet/indirector/file_server.rb +++ b/lib/puppet/indirector/file_server.rb @@ -27,6 +27,7 @@ class Puppet::Indirector::FileServer < Puppet::Indirector::Terminus return nil unless path = find_path(request) result = model.new(path) result.links = request.options[:links] if request.options[:links] + result.collect return result end diff --git a/lib/puppet/network/handler/fileserver.rb b/lib/puppet/network/handler/fileserver.rb index 183979429..14319ef96 100755 --- a/lib/puppet/network/handler/fileserver.rb +++ b/lib/puppet/network/handler/fileserver.rb @@ -75,7 +75,7 @@ class Puppet::Network::Handler return "" unless metadata.exist? begin - metadata.collect_attributes + metadata.collect rescue => detail puts detail.backtrace if Puppet[:trace] Puppet.err detail |