diff options
Diffstat (limited to 'lib/puppet')
-rw-r--r-- | lib/puppet/indirector/catalog/compiler.rb | 16 | ||||
-rw-r--r-- | lib/puppet/indirector/exec.rb | 4 | ||||
-rw-r--r-- | lib/puppet/indirector/facts/facter.rb | 4 | ||||
-rw-r--r-- | lib/puppet/indirector/ldap.rb | 4 | ||||
-rw-r--r-- | lib/puppet/indirector/node/exec.rb | 13 | ||||
-rw-r--r-- | lib/puppet/indirector/node/ldap.rb | 9 | ||||
-rw-r--r-- | lib/puppet/indirector/node/plain.rb | 9 | ||||
-rw-r--r-- | lib/puppet/indirector/report/processor.rb | 4 | ||||
-rw-r--r-- | lib/puppet/indirector/terminus.rb | 27 |
9 files changed, 21 insertions, 69 deletions
diff --git a/lib/puppet/indirector/catalog/compiler.rb b/lib/puppet/indirector/catalog/compiler.rb index 6d769b97d..ecc340f75 100644 --- a/lib/puppet/indirector/catalog/compiler.rb +++ b/lib/puppet/indirector/catalog/compiler.rb @@ -13,11 +13,9 @@ class Puppet::Node::Catalog::Compiler < Puppet::Indirector::Code attr_accessor :code # Compile a node's catalog. - def find(key, client = nil, clientip = nil) - if key.is_a?(Puppet::Node) - node = key - else - node = find_node(key) + def find(request) + unless node = request.options[:node] || find_node(request.key) + raise ArgumentError, "Could not find node '%s'; cannot compile" % request.key end if catalog = compile(node) @@ -102,16 +100,12 @@ class Puppet::Node::Catalog::Compiler < Puppet::Indirector::Code def find_node(key) # If we want to use the cert name as our key # LAK:FIXME This needs to be figured out somehow, but it requires the routing. + # This should be able to use the request, yay. #if Puppet[:node_name] == 'cert' and client # key = client #end - # Note that this is reasonable, because either their node source should actually - # know about the node, or they should be using the ``null`` node source, which - # will always return data. - unless node = Puppet::Node.find_by_any_name(key) - raise Puppet::Error, "Could not find node '%s'" % key - end + return nil unless node = Puppet::Node.find_by_any_name(key) # Add any external data to the node. add_node_data(node) diff --git a/lib/puppet/indirector/exec.rb b/lib/puppet/indirector/exec.rb index 7e4ac8d18..2462e31da 100644 --- a/lib/puppet/indirector/exec.rb +++ b/lib/puppet/indirector/exec.rb @@ -3,9 +3,9 @@ require 'puppet/util' class Puppet::Indirector::Exec < Puppet::Indirector::Terminus # Look for external node definitions. - def find(name) + def find(request) # Run the command. - unless output = query(name) + unless output = query(request.key) return nil end diff --git a/lib/puppet/indirector/facts/facter.rb b/lib/puppet/indirector/facts/facter.rb index a8c47e3bf..465d90c13 100644 --- a/lib/puppet/indirector/facts/facter.rb +++ b/lib/puppet/indirector/facts/facter.rb @@ -56,8 +56,8 @@ class Puppet::Node::Facts::Facter < Puppet::Indirector::Code end # Look a host's facts up in Facter. - def find(key) - Puppet::Node::Facts.new(key, Facter.to_hash) + def find(request) + Puppet::Node::Facts.new(request.key, Facter.to_hash) end def save(facts) diff --git a/lib/puppet/indirector/ldap.rb b/lib/puppet/indirector/ldap.rb index fb883def6..07ad38933 100644 --- a/lib/puppet/indirector/ldap.rb +++ b/lib/puppet/indirector/ldap.rb @@ -2,10 +2,10 @@ require 'puppet/indirector/terminus' class Puppet::Indirector::Ldap < Puppet::Indirector::Terminus # Perform our ldap search and process the result. - def find(name) + def find(request) # We have to use 'yield' here because the LDAP::Entry objects # get destroyed outside the scope of the search, strangely. - ldapsearch(name) { |entry| return process(name, entry) } + ldapsearch(request.key) { |entry| return process(request.key, entry) } # Return nil if we haven't found something. return nil diff --git a/lib/puppet/indirector/node/exec.rb b/lib/puppet/indirector/node/exec.rb index dcfc625b2..52cbc370c 100644 --- a/lib/puppet/indirector/node/exec.rb +++ b/lib/puppet/indirector/node/exec.rb @@ -15,20 +15,13 @@ class Puppet::Node::Exec < Puppet::Indirector::Exec end # Look for external node definitions. - def find(name) + def find(request) output = super or return nil # Translate the output to ruby. - result = translate(name, output) + result = translate(request.key, output) - return create_node(name, result) - end - - # Use the version of the facts, since we assume that's the main thing - # that changes. If someone wants their own way of defining version, - # they can easily provide their own, um, version of this class. - def version(name) - Puppet::Node::Facts.version(name) + return create_node(request.key, result) end private diff --git a/lib/puppet/indirector/node/ldap.rb b/lib/puppet/indirector/node/ldap.rb index 73b5cdd70..6c41c18d4 100644 --- a/lib/puppet/indirector/node/ldap.rb +++ b/lib/puppet/indirector/node/ldap.rb @@ -12,8 +12,11 @@ class Puppet::Node::Ldap < Puppet::Indirector::Ldap end # Look for our node in ldap. - def find(name) + def find(request) return nil unless information = super + + name = request.key + node = Puppet::Node.new(name) parent_info = nil @@ -123,8 +126,4 @@ class Puppet::Node::Ldap < Puppet::Indirector::Ldap end filter end - - def version(name) - Puppet::Node::Facts.version(name) - end end diff --git a/lib/puppet/indirector/node/plain.rb b/lib/puppet/indirector/node/plain.rb index 8058563e6..37ceb064d 100644 --- a/lib/puppet/indirector/node/plain.rb +++ b/lib/puppet/indirector/node/plain.rb @@ -11,16 +11,9 @@ class Puppet::Node::Plain < Puppet::Indirector::Plain node instance before it is returned." # Just return an empty node. - def find(name) + def find(request) node = super node.fact_merge node end - - # Use the version of the facts, since we assume that's the main thing - # that changes. If someone wants their own way of defining version, - # they can easily provide their own, um, version of this class. - def version(name) - Puppet::Node::Facts.version(name) - end end diff --git a/lib/puppet/indirector/report/processor.rb b/lib/puppet/indirector/report/processor.rb index fa2b7f36b..135f1649d 100644 --- a/lib/puppet/indirector/report/processor.rb +++ b/lib/puppet/indirector/report/processor.rb @@ -10,8 +10,8 @@ class Puppet::Transaction::Report::Processor < Puppet::Indirector::Code Puppet.settings.use(:main, :reporting, :metrics) end - def save(report) - process(report) + def save(request) + process(request.instance) end private diff --git a/lib/puppet/indirector/terminus.rb b/lib/puppet/indirector/terminus.rb index 3015c8a37..22c56a4d2 100644 --- a/lib/puppet/indirector/terminus.rb +++ b/lib/puppet/indirector/terminus.rb @@ -128,20 +128,6 @@ class Puppet::Indirector::Terminus end end - # Do we have an update for this object? This compares the provided version - # to our version, and returns true if our version is at least as high - # as the asked-about version. - def has_most_recent?(key, vers) - raise Puppet::DevError.new("Cannot check update status when no 'version' method is defined") unless respond_to?(:version) - - if existing_version = version(key) - #puts "%s fresh: %s (%s vs %s)" % [self.name, (existing_version.to_f >= vers.to_f).inspect, existing_version.to_f, vers.to_f] - existing_version.to_f >= vers.to_f - else - false - end - end - def indirection self.class.indirection end @@ -163,17 +149,4 @@ class Puppet::Indirector::Terminus def terminus_type self.class.terminus_type end - - # Provide a default method for retrieving an instance's version. - # By default, just find the resource and get its version. Individual - # terminus types can override this method to provide custom definitions of - # 'versions'. - def version(name) - raise Puppet::DevError.new("Cannot retrieve an instance's version without a :find method") unless respond_to?(:find) - if instance = find(name) - instance.version - else - nil - end - end end |