diff options
author | Luke Kanies <luke@madstop.com> | 2007-09-20 15:24:20 -0500 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2007-09-20 15:24:20 -0500 |
commit | 8212f88ce3ad2ddbc7e1e713111d9478171c42b8 (patch) | |
tree | 5c61cfd3ca2b76d9ab093feeee89c351796667e0 /lib | |
parent | 4cde0344b50084b897792ba4cdd1f62a733d7f53 (diff) | |
download | puppet-8212f88ce3ad2ddbc7e1e713111d9478171c42b8.tar.gz puppet-8212f88ce3ad2ddbc7e1e713111d9478171c42b8.tar.xz puppet-8212f88ce3ad2ddbc7e1e713111d9478171c42b8.zip |
Fixing all existing spec tests so that they now
pass given the redesign that Rick implemented.
This was mostly a question of fixing
the method names and the mocks.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/puppet/indirector.rb | 17 | ||||
-rw-r--r-- | lib/puppet/indirector/facts/yaml.rb | 4 | ||||
-rw-r--r-- | lib/puppet/indirector/node/external.rb | 2 | ||||
-rw-r--r-- | lib/puppet/indirector/node/ldap.rb | 2 | ||||
-rw-r--r-- | lib/puppet/indirector/node/none.rb | 2 | ||||
-rw-r--r-- | lib/puppet/node.rb | 2 | ||||
-rw-r--r-- | lib/puppet/node/searching.rb | 6 |
7 files changed, 20 insertions, 15 deletions
diff --git a/lib/puppet/indirector.rb b/lib/puppet/indirector.rb index ca1b4b673..cdfd28908 100644 --- a/lib/puppet/indirector.rb +++ b/lib/puppet/indirector.rb @@ -106,7 +106,12 @@ module Puppet::Indirector def self.terminus_for_indirection(name) # JRB:TODO make this do something useful, aka look something up in a .yml file # JRB:TODO look up name + '_source' in standard configuration - :ldap + case name + when :node: :none + when :facts: :yaml + else + raise ArgumentError, "Unknown indirection" + end end # Declare that the including class indirects its methods to @@ -131,30 +136,30 @@ module Puppet::Indirector # instantiate the actual Terminus for that type and this name (:ldap, w/ args :node) # & hook the instantiated Terminus into this registered class (Node: @indirection = terminus) Puppet::Indirector.enable_autoloading_indirection indirection - @indirection = Puppet::Indirector.terminus(indirection, terminus) + raise("No Terminus %s for %s" % [terminus, indirection]) unless @indirection = Puppet::Indirector.terminus(indirection, terminus).new end module ClassMethods attr_reader :indirection def find(*args) - self.indirection.find(args) + self.indirection.find(*args) # JRB:TODO look up the indirection, and call its .find method end def destroy(*args) - self.indirection.destroy(args) + self.indirection.destroy(*args) end def search(*args) - self.indirection.search(args) + self.indirection.search(*args) end end module InstanceMethods # these become instance methods def save(*args) - self.class.indirection.save(args) + self.class.indirection.save(self, *args) end end diff --git a/lib/puppet/indirector/facts/yaml.rb b/lib/puppet/indirector/facts/yaml.rb index f29ea8ebc..cb02f05c6 100644 --- a/lib/puppet/indirector/facts/yaml.rb +++ b/lib/puppet/indirector/facts/yaml.rb @@ -2,7 +2,7 @@ Puppet::Indirector.register_terminus :facts, :yaml do desc "Store client facts as flat files, serialized using YAML." # Get a client's facts. - def get(node) + def find(node) file = path(node) return nil unless FileTest.exists?(file) @@ -21,7 +21,7 @@ Puppet::Indirector.register_terminus :facts, :yaml do end # Store the facts to disk. - def post(facts) + def save(facts) File.open(path(facts.name), "w", 0600) do |f| begin f.print YAML::dump(facts.values) diff --git a/lib/puppet/indirector/node/external.rb b/lib/puppet/indirector/node/external.rb index 13cd265fb..66aca6048 100644 --- a/lib/puppet/indirector/node/external.rb +++ b/lib/puppet/indirector/node/external.rb @@ -11,7 +11,7 @@ Puppet::Indirector.register_terminus :node, :external do end # Look for external node definitions. - def get(name) + def find(name) unless Puppet[:external_nodes] != "none" raise ArgumentError, "You must set the 'external_nodes' parameter to use the external node source" end diff --git a/lib/puppet/indirector/node/ldap.rb b/lib/puppet/indirector/node/ldap.rb index fb60cad31..230ca2467 100644 --- a/lib/puppet/indirector/node/ldap.rb +++ b/lib/puppet/indirector/node/ldap.rb @@ -2,7 +2,7 @@ Puppet::Indirector.register_terminus :node, :ldap do desc "Search in LDAP for node configuration information." # Look for our node in ldap. - def get(name) + def find(name) unless ary = ldapsearch(name) return nil end diff --git a/lib/puppet/indirector/node/none.rb b/lib/puppet/indirector/node/none.rb index 2b326968e..034c0b349 100644 --- a/lib/puppet/indirector/node/none.rb +++ b/lib/puppet/indirector/node/none.rb @@ -6,7 +6,7 @@ Puppet::Indirector.register_terminus :node, :none do as the compiler will not work without this node information." # Just return an empty node. - def get(name) + def find(name) node = Puppet::Node.new(name) node.fact_merge node diff --git a/lib/puppet/node.rb b/lib/puppet/node.rb index 7ad7bc3b3..852f98a99 100644 --- a/lib/puppet/node.rb +++ b/lib/puppet/node.rb @@ -70,7 +70,7 @@ class Puppet::Node # Merge the node facts with parameters from the node source. def fact_merge - if facts = Puppet::Node::Facts.get(name) + if facts = Puppet::Node::Facts.find(name) merge(facts.values) end end diff --git a/lib/puppet/node/searching.rb b/lib/puppet/node/searching.rb index 3a632d50e..10dd588ab 100644 --- a/lib/puppet/node/searching.rb +++ b/lib/puppet/node/searching.rb @@ -14,7 +14,7 @@ module Puppet::Node::Searching names = node_names(key, facts) names.each do |name| name = name.to_s if name.is_a?(Symbol) - if node = get(name) + if node = find(name) #Puppet.info "Found %s in %s" % [name, @source] break end @@ -23,7 +23,7 @@ module Puppet::Node::Searching # If they made it this far, we haven't found anything, so look for a # default node. unless node or names.include?("default") - if node = get("default") + if node = find("default") Puppet.notice "Using default node for %s" % key end end @@ -62,7 +62,7 @@ module Puppet::Node::Searching # Look up the node facts from our fact handler. def node_facts(key) - if facts = Puppet::Node::Facts.get(key) + if facts = Puppet::Node::Facts.find(key) facts.values else {} |