summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2007-09-24 14:45:54 -0500
committerLuke Kanies <luke@madstop.com>2007-09-24 14:45:54 -0500
commitd6fd60cca15641fc1341cce52faf0506d7665044 (patch)
treeb7eb0df3dc1e46f4702c067192553da5f6a0fb75 /lib
parentcdc8ea6e81c1b5eba5ea784bb7079c4c1f3965a4 (diff)
downloadpuppet-d6fd60cca15641fc1341cce52faf0506d7665044.tar.gz
puppet-d6fd60cca15641fc1341cce52faf0506d7665044.tar.xz
puppet-d6fd60cca15641fc1341cce52faf0506d7665044.zip
Removing obsolete fact stores and node sources. The functionality has been moved into the indirector.
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/fact_stores/yaml.rb40
-rw-r--r--lib/puppet/node_source/external.rb51
-rw-r--r--lib/puppet/node_source/ldap.rb138
-rw-r--r--lib/puppet/node_source/none.rb10
4 files changed, 0 insertions, 239 deletions
diff --git a/lib/puppet/fact_stores/yaml.rb b/lib/puppet/fact_stores/yaml.rb
deleted file mode 100644
index b33e162ba..000000000
--- a/lib/puppet/fact_stores/yaml.rb
+++ /dev/null
@@ -1,40 +0,0 @@
-Puppet::Util::FactStore.newstore(:yaml) do
- desc "Store client facts as flat files, serialized using YAML."
-
- # Get a client's facts.
- def get(node)
- file = path(node)
-
- return nil unless FileTest.exists?(file)
-
- begin
- facts = YAML::load(File.read(file))
- rescue => detail
- Puppet.err "Could not load facts for %s: %s" % [node, detail]
- end
- facts
- end
-
- def initialize
- Puppet.settings.use(:yamlfacts)
- end
-
- # Store the facts to disk.
- def set(node, facts)
- File.open(path(node), "w", 0600) do |f|
- begin
- f.print YAML::dump(facts)
- rescue => detail
- Puppet.err "Could not write facts for %s: %s" % [node, detail]
- end
- end
- nil
- end
-
- private
-
- # Return the path to a given node's file.
- def path(node)
- File.join(Puppet[:yamlfactdir], node + ".yaml")
- end
-end
diff --git a/lib/puppet/node_source/external.rb b/lib/puppet/node_source/external.rb
deleted file mode 100644
index 54111d924..000000000
--- a/lib/puppet/node_source/external.rb
+++ /dev/null
@@ -1,51 +0,0 @@
-Puppet::Network::Handler::Node.newnode_source(:external, :fact_merge => true) do
- desc "Call an external program to get node information."
-
- include Puppet::Util
- # Look for external node definitions.
- def nodesearch(name)
- return nil unless Puppet[:external_nodes] != "none"
-
- # This is a very cheap way to do this, since it will break on
- # commands that have spaces in the arguments. But it's good
- # enough for most cases.
- external_node_command = Puppet[:external_nodes].split
- external_node_command << name
- begin
- output = Puppet::Util.execute(external_node_command)
- rescue Puppet::ExecutionFailure => detail
- if $?.exitstatus == 1
- return nil
- else
- Puppet.err "Could not retrieve external node information for %s: %s" % [name, detail]
- end
- return nil
- end
-
- if output =~ /\A\s*\Z/ # all whitespace
- Puppet.debug "Empty response for %s from external node source" % name
- return nil
- end
-
- begin
- result = YAML.load(output).inject({}) { |hash, data| hash[symbolize(data[0])] = data[1]; hash }
- rescue => detail
- raise Puppet::Error, "Could not load external node results for %s: %s" % [name, detail]
- end
-
- node = newnode(name)
- set = false
- [:parameters, :classes].each do |param|
- if value = result[param]
- node.send(param.to_s + "=", value)
- set = true
- end
- end
-
- if set
- return node
- else
- return nil
- end
- end
-end
diff --git a/lib/puppet/node_source/ldap.rb b/lib/puppet/node_source/ldap.rb
deleted file mode 100644
index 7b60a3c62..000000000
--- a/lib/puppet/node_source/ldap.rb
+++ /dev/null
@@ -1,138 +0,0 @@
-Puppet::Network::Handler::Node.newnode_source(:ldap, :fact_merge => true) do
- desc "Search in LDAP for node configuration information."
-
- # Find the ldap node, return the class list and parent node specially,
- # and everything else in a parameter hash.
- def ldapsearch(node)
- filter = Puppet[:ldapstring]
- classattrs = Puppet[:ldapclassattrs].split("\s*,\s*")
- if Puppet[:ldapattrs] == "all"
- # A nil value here causes all attributes to be returned.
- search_attrs = nil
- else
- search_attrs = classattrs + Puppet[:ldapattrs].split("\s*,\s*")
- end
- pattr = nil
- if pattr = Puppet[:ldapparentattr]
- if pattr == ""
- pattr = nil
- else
- search_attrs << pattr unless search_attrs.nil?
- end
- end
-
- if filter =~ /%s/
- filter = filter.gsub(/%s/, node)
- end
-
- parent = nil
- classes = []
- parameters = nil
-
- found = false
- count = 0
-
- begin
- # We're always doing a sub here; oh well.
- ldap.search(Puppet[:ldapbase], 2, filter, search_attrs) do |entry|
- found = true
- if pattr
- if values = entry.vals(pattr)
- if values.length > 1
- raise Puppet::Error,
- "Node %s has more than one parent: %s" %
- [node, values.inspect]
- end
- unless values.empty?
- parent = values.shift
- end
- end
- end
-
- classattrs.each { |attr|
- if values = entry.vals(attr)
- values.each do |v| classes << v end
- end
- }
-
- parameters = entry.to_hash.inject({}) do |hash, ary|
- if ary[1].length == 1
- hash[ary[0]] = ary[1].shift
- else
- hash[ary[0]] = ary[1]
- end
- hash
- end
- end
- rescue => detail
- if count == 0
- # Try reconnecting to ldap
- @ldap = nil
- retry
- else
- raise Puppet::Error, "LDAP Search failed: %s" % detail
- end
- end
-
- classes.flatten!
-
- if classes.empty?
- classes = nil
- end
-
- if parent or classes or parameters
- return parent, classes, parameters
- else
- return nil
- end
- end
-
- # Look for our node in ldap.
- def nodesearch(node)
- unless ary = ldapsearch(node)
- return nil
- end
- parent, classes, parameters = ary
-
- while parent
- parent, tmpclasses, tmpparams = ldapsearch(parent)
- classes += tmpclasses if tmpclasses
- tmpparams.each do |param, value|
- # Specifically test for whether it's set, so false values are handled
- # correctly.
- parameters[param] = value unless parameters.include?(param)
- end
- end
-
- return newnode(node, :classes => classes, :source => "ldap", :parameters => parameters)
- end
-
- private
-
- # Create an ldap connection.
- def ldap
- unless defined? @ldap and @ldap
- unless Puppet.features.ldap?
- raise Puppet::Error, "Could not set up LDAP Connection: Missing ruby/ldap libraries"
- end
- begin
- if Puppet[:ldapssl]
- @ldap = LDAP::SSLConn.new(Puppet[:ldapserver], Puppet[:ldapport])
- elsif Puppet[:ldaptls]
- @ldap = LDAP::SSLConn.new(
- Puppet[:ldapserver], Puppet[:ldapport], true
- )
- else
- @ldap = LDAP::Conn.new(Puppet[:ldapserver], Puppet[:ldapport])
- end
- @ldap.set_option(LDAP::LDAP_OPT_PROTOCOL_VERSION, 3)
- @ldap.set_option(LDAP::LDAP_OPT_REFERRALS, LDAP::LDAP_OPT_ON)
- @ldap.simple_bind(Puppet[:ldapuser], Puppet[:ldappassword])
- rescue => detail
- raise Puppet::Error, "Could not connect to LDAP: %s" % detail
- end
- end
-
- return @ldap
- end
-end
diff --git a/lib/puppet/node_source/none.rb b/lib/puppet/node_source/none.rb
deleted file mode 100644
index ce188add5..000000000
--- a/lib/puppet/node_source/none.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-Puppet::Network::Handler::Node.newnode_source(:none, :fact_merge => true) do
- desc "Always return an empty node object. This is the node source you should
- use when you don't have some other, functional source you want to use,
- as the compiler will not work without this node information."
-
- # Just return an empty node.
- def nodesearch(name)
- newnode(name)
- end
-end