summaryrefslogtreecommitdiffstats
path: root/lib/puppet/indirector/file_server.rb
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2007-10-19 17:35:40 -0500
committerLuke Kanies <luke@madstop.com>2007-10-19 17:35:40 -0500
commit08099b7a383987e292357f285e05933e10205660 (patch)
treec8f08a3afca5c9b45f965c7c8d051023170ea0d5 /lib/puppet/indirector/file_server.rb
parentec396729d76b26d0d08c0bd633f28fa3c68c414c (diff)
downloadpuppet-08099b7a383987e292357f285e05933e10205660.tar.gz
puppet-08099b7a383987e292357f285e05933e10205660.tar.xz
puppet-08099b7a383987e292357f285e05933e10205660.zip
File serving now works. I've tested a couple of ways to
use it, and added integration tests at the most important hook points. This provides the final class structure for all of these classes, but a lot of the class names are pretty bad, so I'm planning on going through all of them (especially the file_server stuff) and renaming. The functionality is all here for finding files, though (finally). Once the classes are renamed, I'll be adding searching ability (which will enable the recursive file copies) and then adding the link management and enabling ignoring files.
Diffstat (limited to 'lib/puppet/indirector/file_server.rb')
-rw-r--r--lib/puppet/indirector/file_server.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/puppet/indirector/file_server.rb b/lib/puppet/indirector/file_server.rb
new file mode 100644
index 000000000..1b2e047e8
--- /dev/null
+++ b/lib/puppet/indirector/file_server.rb
@@ -0,0 +1,34 @@
+#
+# Created by Luke Kanies on 2007-10-19.
+# Copyright (c) 2007. All rights reserved.
+
+require 'puppet/util/uri_helper'
+require 'puppet/file_serving/configuration'
+require 'puppet/indirector/terminus'
+
+# Look files up using the file server.
+class Puppet::Indirector::FileServer < Puppet::Indirector::Terminus
+ include Puppet::Util::URIHelper
+
+ # Find our key using the fileserver.
+ def find(key, options = {})
+ uri = key2uri(key)
+
+ # First try the modules mount, at least for now.
+ if instance = indirection.terminus(:modules).find(key, options)
+ Puppet.warning "DEPRECATION NOTICE: Found file in module without using the 'modules' mount; please fix"
+ return instance
+ end
+
+ return nil unless path = configuration.file_path(uri.path, :node => options[:node]) and FileTest.exists?(path)
+
+ return model.new(path)
+ end
+
+ private
+
+ # Our fileserver configuration, if needed.
+ def configuration
+ Puppet::FileServing::Configuration.create
+ end
+end