diff options
author | Luke Kanies <luke@reductivelabs.com> | 2009-12-21 16:23:44 -0800 |
---|---|---|
committer | Luke Kanies <luke@reductivelabs.com> | 2009-12-21 16:23:44 -0800 |
commit | 740fd6b301af89ab3aad89bca183ad1fcdc24ac4 (patch) | |
tree | f34617a229509c373d28d67abb453e7ae2136c39 /lib/puppet/file_serving | |
parent | 8971d8beae2c409f9052f27c3f80ad3bdfff4de2 (diff) | |
parent | 4a06379f8770c164e42bcc410d874076c6e95f24 (diff) | |
download | puppet-740fd6b301af89ab3aad89bca183ad1fcdc24ac4.tar.gz puppet-740fd6b301af89ab3aad89bca183ad1fcdc24ac4.tar.xz puppet-740fd6b301af89ab3aad89bca183ad1fcdc24ac4.zip |
Merge branch '0.25.x'
Conflicts:
lib/puppet/agent.rb
lib/puppet/application/puppetd.rb
lib/puppet/parser/ast/leaf.rb
lib/puppet/util/rdoc/parser.rb
Diffstat (limited to 'lib/puppet/file_serving')
-rw-r--r-- | lib/puppet/file_serving/base.rb | 17 | ||||
-rw-r--r-- | lib/puppet/file_serving/configuration.rb | 4 | ||||
-rw-r--r-- | lib/puppet/file_serving/metadata.rb | 45 |
3 files changed, 60 insertions, 6 deletions
diff --git a/lib/puppet/file_serving/base.rb b/lib/puppet/file_serving/base.rb index c82bb1992..a7ab9b66e 100644 --- a/lib/puppet/file_serving/base.rb +++ b/lib/puppet/file_serving/base.rb @@ -22,7 +22,7 @@ class Puppet::FileServing::Base end # Return the full path to our file. Fails if there's no path set. - def full_path + def full_path(dummy_argument=:work_arround_for_ruby_GC_bug) (if relative_path.nil? or relative_path == "" or relative_path == "." path else @@ -74,4 +74,19 @@ class Puppet::FileServing::Base end File.send(@stat_method, full_path()) end + + def to_pson_data_hash + { + # No 'document_type' since we don't send these bare + 'data' => { + 'path' => @path, + 'relative_path' => @relative_path, + 'links' => @links + }, + 'metadata' => { + 'api_version' => 1 + } + } + end + end diff --git a/lib/puppet/file_serving/configuration.rb b/lib/puppet/file_serving/configuration.rb index ac54a7a8a..9034caed1 100644 --- a/lib/puppet/file_serving/configuration.rb +++ b/lib/puppet/file_serving/configuration.rb @@ -96,9 +96,9 @@ class Puppet::FileServing::Configuration def mk_default_mounts @mounts["modules"] ||= Mount::Modules.new("modules") - @mounts["modules"].allow('*') + @mounts["modules"].allow('*') if @mounts["modules"].empty? @mounts["plugins"] ||= Mount::Plugins.new("plugins") - @mounts["plugins"].allow('*') + @mounts["plugins"].allow('*') if @mounts["plugins"].empty? end # Read the configuration file. diff --git a/lib/puppet/file_serving/metadata.rb b/lib/puppet/file_serving/metadata.rb index 335dad497..275a090eb 100644 --- a/lib/puppet/file_serving/metadata.rb +++ b/lib/puppet/file_serving/metadata.rb @@ -71,8 +71,47 @@ class Puppet::FileServing::Metadata < Puppet::FileServing::Base end end - def initialize(*args) - @checksum_type = "md5" - super + def initialize(path,data={}) + @owner = data.delete('owner') + @group = data.delete('group') + @mode = data.delete('mode') + if checksum = data.delete('checksum') + @checksum_type = checksum['type'] + @checksum = checksum['value'] + end + @checksum_type ||= "md5" + @ftype = data.delete('type') + @destination = data.delete('destination') + super(path,data) + end + + PSON.register_document_type('FileMetadata',self) + def to_pson_data_hash + { + 'document_type' => 'FileMetadata', + 'data' => super['data'].update({ + 'owner' => owner, + 'group' => group, + 'mode' => mode, + 'checksum' => { + 'type' => checksum_type, + 'value' => checksum + }, + 'type' => ftype, + 'destination' => destination, + }), + 'metadata' => { + 'api_version' => 1 + } + } + end + + def to_pson(*args) + to_pson_data_hash.to_pson(*args) + end + + def self.from_pson(data) + new(data.delete('path'), data) end + end |