diff options
author | Luke Kanies <luke@madstop.com> | 2007-10-18 20:47:56 -0500 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2007-10-18 20:47:56 -0500 |
commit | fc607513faa54d64186a674a36d81ea010745569 (patch) | |
tree | d409b20c752cdb50e2fe72e8f6ef815951c360b4 /lib/puppet/indirector | |
parent | 64c6700bc7530f1213e124d248cc176a7cfe6180 (diff) | |
download | puppet-fc607513faa54d64186a674a36d81ea010745569.tar.gz puppet-fc607513faa54d64186a674a36d81ea010745569.tar.xz puppet-fc607513faa54d64186a674a36d81ea010745569.zip |
I've now split the file-serving termini into two separate types (in
addition to Rest): A local terminus that just uses direct file paths,
and a mounts terminus that uses the file server to figure out what
the path should be.
It looks like it also makes sense to split the 'mounts' terminus further,
so there is a 'modules' terminus used to look files up in the terminus.
I've added some integration tests to verify that everything is
hooked together correctly.
Lastly, I added a directory for shared behaviours. There's a ton of
duplication in this setup, because the Content and Metadata classes
behave almost but not quite identically across the board.
Diffstat (limited to 'lib/puppet/indirector')
-rw-r--r-- | lib/puppet/indirector/file_content/local.rb | 9 | ||||
-rw-r--r-- | lib/puppet/indirector/file_content/mounts.rb | 28 | ||||
-rw-r--r-- | lib/puppet/indirector/file_content/rest.rb | 12 | ||||
-rw-r--r-- | lib/puppet/indirector/file_metadata/local.rb | 16 | ||||
-rw-r--r-- | lib/puppet/indirector/file_metadata/mounts.rb | 28 | ||||
-rw-r--r-- | lib/puppet/indirector/file_metadata/rest.rb | 12 |
6 files changed, 100 insertions, 5 deletions
diff --git a/lib/puppet/indirector/file_content/local.rb b/lib/puppet/indirector/file_content/local.rb index 34d1c7794..a597fea55 100644 --- a/lib/puppet/indirector/file_content/local.rb +++ b/lib/puppet/indirector/file_content/local.rb @@ -3,12 +3,19 @@ # Copyright (c) 2007. All rights reserved. require 'puppet/file_serving/content' +require 'puppet/file_serving/terminus_helper' require 'puppet/indirector/file_content' require 'puppet/indirector/file' class Puppet::Indirector::FileContent::Local < Puppet::Indirector::File desc "Retrieve file contents from disk." - def find(path) + include Puppet::FileServing::TerminusHelper + + def find(key) + uri = key2uri(key) + + return nil unless FileTest.exists?(uri.path) + Puppet::FileServing::Content.new uri.path end end diff --git a/lib/puppet/indirector/file_content/mounts.rb b/lib/puppet/indirector/file_content/mounts.rb new file mode 100644 index 000000000..3d147d65a --- /dev/null +++ b/lib/puppet/indirector/file_content/mounts.rb @@ -0,0 +1,28 @@ +# +# Created by Luke Kanies on 2007-10-18. +# Copyright (c) 2007. All rights reserved. + +require 'puppet/file_serving/content' +require 'puppet/file_serving/terminus_helper' +require 'puppet/indirector/file_content' +require 'puppet/indirector/code' + +class Puppet::Indirector::FileContent::Mounts < Puppet::Indirector::Code + desc "Retrieve file contents using Puppet's fileserver." + + include Puppet::FileServing::TerminusHelper + + # This way it can be cleared or whatever and we aren't retaining + # a reference to the old one. + def configuration + Puppet::FileServing::Configuration.create + end + + def find(key) + uri = key2uri(key) + + return nil unless path = configuration.file_path(uri.path) and FileTest.exists?(path) + + Puppet::FileServing::Content.new path + end +end diff --git a/lib/puppet/indirector/file_content/rest.rb b/lib/puppet/indirector/file_content/rest.rb new file mode 100644 index 000000000..9e2de360c --- /dev/null +++ b/lib/puppet/indirector/file_content/rest.rb @@ -0,0 +1,12 @@ +# +# Created by Luke Kanies on 2007-10-18. +# Copyright (c) 2007. All rights reserved. + +require 'puppet/file_serving/content' +require 'puppet/file_serving/terminus_helper' +require 'puppet/indirector/file_content' +require 'puppet/indirector/rest' + +class Puppet::Indirector::FileContent::Rest < Puppet::Indirector::REST + desc "Retrieve file contents via a REST HTTP interface." +end diff --git a/lib/puppet/indirector/file_metadata/local.rb b/lib/puppet/indirector/file_metadata/local.rb index f6cfa1f1c..e1d774cc8 100644 --- a/lib/puppet/indirector/file_metadata/local.rb +++ b/lib/puppet/indirector/file_metadata/local.rb @@ -4,13 +4,21 @@ require 'puppet/file_serving/metadata' require 'puppet/indirector/file_metadata' +require 'puppet/file_serving/terminus_helper' require 'puppet/indirector/code' class Puppet::Indirector::FileMetadata::Local < Puppet::Indirector::Code - desc "Retrieve file metadata using Puppet's Resource Abstraction Layer. - Returns everything about the file except its content." + desc "Retrieve file metadata directly from the local filesystem." - def find(file) - Puppet::Node::Facts.new(key, Facter.to_hash) + include Puppet::FileServing::TerminusHelper + + def find(key) + uri = key2uri(key) + + return nil unless FileTest.exists?(uri.path) + data = Puppet::FileServing::Metadata.new uri.path + data.get_attributes + + return data end end diff --git a/lib/puppet/indirector/file_metadata/mounts.rb b/lib/puppet/indirector/file_metadata/mounts.rb new file mode 100644 index 000000000..6d7fe15c6 --- /dev/null +++ b/lib/puppet/indirector/file_metadata/mounts.rb @@ -0,0 +1,28 @@ +# +# Created by Luke Kanies on 2007-10-18. +# Copyright (c) 2007. All rights reserved. + +require 'puppet/file_serving/metadata' +require 'puppet/file_serving/terminus_helper' +require 'puppet/indirector/file_metadata' +require 'puppet/indirector/code' + +class Puppet::Indirector::FileMetadata::Mounts < Puppet::Indirector::Code + desc "Retrieve file metadata using Puppet's fileserver." + + include Puppet::FileServing::TerminusHelper + + # This way it can be cleared or whatever and we aren't retaining + # a reference to the old one. + def configuration + Puppet::FileServing::Configuration.create + end + + def find(key) + uri = key2uri(key) + + return nil unless path = configuration.file_path(uri.path) and FileTest.exists?(path) + + Puppet::FileServing::Metadata.new path + end +end diff --git a/lib/puppet/indirector/file_metadata/rest.rb b/lib/puppet/indirector/file_metadata/rest.rb new file mode 100644 index 000000000..dcf875b25 --- /dev/null +++ b/lib/puppet/indirector/file_metadata/rest.rb @@ -0,0 +1,12 @@ +# +# Created by Luke Kanies on 2007-10-18. +# Copyright (c) 2007. All rights reserved. + +require 'puppet/file_serving/metadata' +require 'puppet/file_serving/terminus_helper' +require 'puppet/indirector/file_metadata' +require 'puppet/indirector/rest' + +class Puppet::Indirector::FileMetadata::Rest < Puppet::Indirector::REST + desc "Retrieve file metadata via a REST HTTP interface." +end |