summaryrefslogtreecommitdiffstats
path: root/lib/puppet/network
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2009-02-18 12:00:29 -0600
committerLuke Kanies <luke@madstop.com>2009-02-19 16:22:45 -0600
commit19b85346a60a05fd146fe39742cb873490eb6b4c (patch)
tree6569d5b0be9657d1e4efe59e268368b5aaf56a3d /lib/puppet/network
parent1be7c763b51c0cb6b271429f83ca4afb733bbf63 (diff)
downloadpuppet-19b85346a60a05fd146fe39742cb873490eb6b4c.tar.gz
puppet-19b85346a60a05fd146fe39742cb873490eb6b4c.tar.xz
puppet-19b85346a60a05fd146fe39742cb873490eb6b4c.zip
Migrating the old FileServer to the new Module/Environment code
The interface is *much* cleaner, and I'd removed one of the methods used in this code. Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'lib/puppet/network')
-rwxr-xr-xlib/puppet/network/handler/fileserver.rb25
1 files changed, 13 insertions, 12 deletions
diff --git a/lib/puppet/network/handler/fileserver.rb b/lib/puppet/network/handler/fileserver.rb
index 4e00b605f..b39396091 100755
--- a/lib/puppet/network/handler/fileserver.rb
+++ b/lib/puppet/network/handler/fileserver.rb
@@ -254,8 +254,7 @@ class Puppet::Network::Handler
end
# And use the environment to look up the module.
- mod = Puppet::Module::find(module_name, env)
- if mod
+ if mod = Puppet::Node::Environment.new(env).module(module_name)
return @mounts[MODULES].copy(mod.name, mod.files)
else
return nil
@@ -477,7 +476,10 @@ class Puppet::Network::Handler
def file_path(relative_path, node = nil)
full_path = path(node)
- raise ArgumentError.new("Mounts without paths are not usable") unless full_path
+ unless full_path
+ p self
+ raise ArgumentError.new("Mounts without paths are not usable") unless full_path
+ end
# If there's no relative path name, then we're serving the mount itself.
return full_path unless relative_path and relative_path != "/"
@@ -699,11 +701,11 @@ class Puppet::Network::Handler
end
def mod_path_exists?(mod, relpath, client = nil)
- File.exists?(File.join(mod, PLUGINS, relpath))
+ ! mod.plugin(relpath).nil?
end
def path_exists?(relpath, client = nil)
- !valid_modules.find { |m| mod_path_exists?(m, relpath, client) }.nil?
+ !valid_modules(client).find { |mod| mod.plugin(relpath) }.nil?
end
def valid?
@@ -715,16 +717,15 @@ class Puppet::Network::Handler
end
def file_path(relpath, client = nil)
- return nil unless mod = valid_modules.map { |m| mod_path_exists?(m, relpath, client) ? m : nil }.compact.first
- mod_file_path(mod, relpath, client)
+ return nil unless mod = valid_modules(client).find { |m| m.plugin(relpath) }
+ mod.plugin(relpath)
end
# create a list of files by merging all modules
def list(relpath, recurse, ignore, client = nil)
result = []
- valid_modules.each do |m|
- modpath = mod_file_path(m, relpath, client)
- if FileTest.exists?(modpath)
+ valid_modules(client).each do |mod|
+ if modpath = mod.plugin(relpath)
if FileTest.directory?(modpath) and recurse
ary = reclist(modpath, recurse, ignore)
ary = [] if ary.nil?
@@ -738,8 +739,8 @@ class Puppet::Network::Handler
end
private
- def valid_modules
- Puppet::Module.all.find_all { |m| File.directory?(File.join(m, PLUGINS)) }
+ def valid_modules(client)
+ Puppet::Node::Environment.new.modules.find_all { |mod| mod.plugins? }
end
def add_to_filetree(f, filetree)