diff options
author | Luke Kanies <luke@madstop.com> | 2009-08-18 15:58:38 -0700 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2009-08-18 15:58:38 -0700 |
commit | 796ba5c4ccec117bbc4dec69c670337e70b48634 (patch) | |
tree | 549f59c2202da84a3c0d527f4df964bc61c1b6b4 /lib | |
parent | 6bd3627d606cde4bea9293b855be0dd2b1170a92 (diff) | |
download | puppet-796ba5c4ccec117bbc4dec69c670337e70b48634.tar.gz puppet-796ba5c4ccec117bbc4dec69c670337e70b48634.tar.xz puppet-796ba5c4ccec117bbc4dec69c670337e70b48634.zip |
Fixing #1544 - plugins in modules now works again
We had to fix the fileserving plumbing to use the request
environment instead of trying to use the node environment.
This was apparently never fixed after we added the environment
to the URI in REST calls.
There's still a bit of refactoring left to clean up the APIs used
in some of this code.
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/puppet/file_serving/mount.rb | 9 | ||||
-rw-r--r-- | lib/puppet/file_serving/mount/plugins.rb | 8 | ||||
-rw-r--r-- | lib/puppet/indirector/file_server.rb | 9 | ||||
-rw-r--r-- | lib/puppet/module.rb | 2 | ||||
-rw-r--r-- | lib/puppet/node/environment.rb | 1 |
5 files changed, 12 insertions, 17 deletions
diff --git a/lib/puppet/file_serving/mount.rb b/lib/puppet/file_serving/mount.rb index 5ab6d8688..7ee11a99b 100644 --- a/lib/puppet/file_serving/mount.rb +++ b/lib/puppet/file_serving/mount.rb @@ -16,15 +16,6 @@ class Puppet::FileServing::Mount < Puppet::Network::AuthStore attr_reader :name - # Determine the environment to use, if any. - def environment(node_name) - if node_name and node = Puppet::Node.find(node_name) - Puppet::Node::Environment.new(node.environment) - else - Puppet::Node::Environment.new - end - end - def find(path, options) raise NotImplementedError end diff --git a/lib/puppet/file_serving/mount/plugins.rb b/lib/puppet/file_serving/mount/plugins.rb index c7a3ee6ff..02b838c84 100644 --- a/lib/puppet/file_serving/mount/plugins.rb +++ b/lib/puppet/file_serving/mount/plugins.rb @@ -5,18 +5,18 @@ require 'puppet/file_serving/mount' # many directories into one. class Puppet::FileServing::Mount::Plugins < Puppet::FileServing::Mount # Return an instance of the appropriate class. - def find(relative_path, options = {}) - return nil unless mod = environment(options[:node]).modules.find { |mod| mod.plugin(relative_path) } + def find(relative_path, environment) + return nil unless mod = environment.modules.find { |mod| mod.plugin(relative_path) } path = mod.plugin(relative_path) return path end - def search(relative_path, options = {}) + def search(relative_path, environment) # We currently only support one kind of search on plugins - return # them all. - paths = environment(options[:node]).modules.find_all { |mod| mod.plugins? }.collect { |mod| mod.plugin_directory } + paths = environment.modules.find_all { |mod| mod.plugins? }.collect { |mod| mod.plugin_directory } return nil if paths.empty? return paths end diff --git a/lib/puppet/indirector/file_server.rb b/lib/puppet/indirector/file_server.rb index 5fe744a0e..fe4d4aa1c 100644 --- a/lib/puppet/indirector/file_server.rb +++ b/lib/puppet/indirector/file_server.rb @@ -30,7 +30,7 @@ class Puppet::Indirector::FileServer < Puppet::Indirector::Terminus # The mount checks to see if the file exists, and returns nil # if not. - return nil unless path = mount.find(relative_path, :node => request.node) + return nil unless path = mount.find(relative_path, request.environment) result = model.new(path) result.links = request.options[:links] if request.options[:links] result.collect @@ -42,9 +42,10 @@ class Puppet::Indirector::FileServer < Puppet::Indirector::Terminus def search(request) mount, relative_path = configuration.split_path(request) - return nil unless mount - - return nil unless paths = mount.search(relative_path, :node => request.node) + unless mount and paths = mount.search(relative_path, request.environment) + Puppet.info "Could not find filesystem info for file '%s' in environment %s" % [request.key, request.environment] + return nil + end filesets = paths.collect do |path| # Filesets support indirector requests as an options collection diff --git a/lib/puppet/module.rb b/lib/puppet/module.rb index 3a6f04d15..2b6777c43 100644 --- a/lib/puppet/module.rb +++ b/lib/puppet/module.rb @@ -49,6 +49,8 @@ class Puppet::Module end attr_reader :name, :environment + attr_writer :environment + def initialize(name, environment = nil) @name = name if environment.is_a?(Puppet::Node::Environment) diff --git a/lib/puppet/node/environment.rb b/lib/puppet/node/environment.rb index c053e0d5f..323f2793a 100644 --- a/lib/puppet/node/environment.rb +++ b/lib/puppet/node/environment.rb @@ -71,6 +71,7 @@ class Puppet::Node::Environment cached_attr(:modules, :ttl => Puppet[:filetimeout]) do result = [] Puppet::Module.each_module(modulepath) do |mod| + mod.environment = self result << mod end result |