[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. 2.6.1rc1-141-gcdb2b90
Markus Roberts
Markus at reality.com
Mon Aug 16 12:48:57 UTC 2010
The following commit has been merged in the upstream branch:
commit d909827942fa571bea202818c92d081e7957a574
Author: Markus Roberts <Markus at reality.com>
Date: Wed Aug 4 14:24:13 2010 -0700
Fix for #4465 -- earlier "feature" patch broke ldap
The patch for #3904 should not have been accepted; it's buggy and the use case
(supporting having nodes in ldap more than once with the same name but distinct
records) is ill-conceived.
This commit reverts the patch (a7884b47) and the previous attempt to fix it
(e6709da4), restoring the old (0.25.x) behaviour.
diff --git a/lib/puppet/indirector/node/ldap.rb b/lib/puppet/indirector/node/ldap.rb
index b9fe355..ecebc82 100644
--- a/lib/puppet/indirector/node/ldap.rb
+++ b/lib/puppet/indirector/node/ldap.rb
@@ -19,30 +19,10 @@ class Puppet::Node::Ldap < Puppet::Indirector::Ldap
# LAK:NOTE Unfortunately, the ldap support is too stupid to throw anything
# but LDAP::ResultError, even on bad connections, so we are rough handed
# with our error handling.
- def name2hash(name,name_env,node_type)
+ def name2hash(name)
info = nil
- ldapsearch(search_filter(name)) {
- |entry| info = entry2hash(entry)
- if info[:environment]
- if name_env == info[:environment]
- return info
- else
- info = nil
- end
- else
- info_env = "production"
- if name_env == info[:environment]
- return info
- else
- info = nil
- end
- end
- }
- if node_type == 'parent'
- raise Puppet::Error.new("Could not find node '#{name}' with environment '#{name_env}'")
- end
-
- info = name2hash('default',name_env,'parent')
+ ldapsearch(search_filter(name)) { |entry| info = entry2hash(entry) }
+ info
end
# Look for our node in ldap.
@@ -53,18 +33,9 @@ class Puppet::Node::Ldap < Puppet::Indirector::Ldap
node = nil
names.each do |name|
- facts = Puppet::Node::Facts.find(name)
- if facts.values["environment"]
- name_env = facts.values["environment"]
- else
- name_env = "production"
- end
- info = name2hash(name,name_env,'child')
- next if info == nil
-
- if info
- break if node = info2node(request.key, info)
- end
+ next unless info = name2hash(name)
+
+ break if node = info2node(request.key, info)
end
node
@@ -200,29 +171,14 @@ class Puppet::Node::Ldap < Puppet::Indirector::Ldap
# Find information for our parent and merge it into the current info.
def find_and_merge_parent(parent, information)
-
- if information[:environment]
- name_env = information[:environment]
- else
- name_env = 'production'
- end
-
- parent_info = name2hash(parent,name_env,'parent')
- if parent_info
+ parent_info = name2hash(parent) || raise(Puppet::Error.new("Could not find parent node '#{parent}'"))
information[:classes] += parent_info[:classes]
parent_info[:parameters].each do |param, value|
- # Specifically test for whether it's set, so false values are handled
- # correctly.
+ # Specifically test for whether it's set, so false values are handled correctly.
information[:parameters][param] = value unless information[:parameters].include?(param)
end
-
information[:environment] ||= parent_info[:environment]
parent_info[:parent]
- else
- raise Puppet::Error.new("Could not find parent node '#{parent}'")
- nil
- end
-
end
# Take a name and a hash, and return a node instance.
diff --git a/spec/unit/indirector/node/ldap_spec.rb b/spec/unit/indirector/node/ldap_spec.rb
index a5f14fc..042e7bd 100755
--- a/spec/unit/indirector/node/ldap_spec.rb
+++ b/spec/unit/indirector/node/ldap_spec.rb
@@ -19,17 +19,17 @@ describe Puppet::Node::Ldap do
end
it "should convert the hostname into a search filter" do
- entry = stub 'entry', :dn => 'cn=mynode.domain.com,ou=hosts,dc=madstop,dc=com', :vals => %w{}, :to_hash => {"environment" => 'production'}
+ entry = stub 'entry', :dn => 'cn=mynode.domain.com,ou=hosts,dc=madstop,dc=com', :vals => %w{}, :to_hash => {}
@searcher.expects(:ldapsearch).with("(&(objectclass=puppetClient)(cn=#{@name}))").yields entry
- @searcher.name2hash(@name, 'production', 'parent')
+ @searcher.name2hash(@name)
end
it "should convert any found entry into a hash" do
- entry = stub 'entry', :dn => 'cn=mynode.domain.com,ou=hosts,dc=madstop,dc=com', :vals => %w{}, :to_hash => {"environment" => 'production'}
+ entry = stub 'entry', :dn => 'cn=mynode.domain.com,ou=hosts,dc=madstop,dc=com', :vals => %w{}, :to_hash => {}
@searcher.expects(:ldapsearch).with("(&(objectclass=puppetClient)(cn=#{@name}))").yields entry
- myhash = {"myhash" => true, :environment => 'production'}
+ myhash = {"myhash" => true}
@searcher.expects(:entry2hash).with(entry).returns myhash
- @searcher.name2hash(@name, 'production', 'parent').should == myhash
+ @searcher.name2hash(@name).should == myhash
end
# This heavily tests our entry2hash method, so we don't have to stub out the stupid entry information any more.
@@ -124,20 +124,20 @@ describe Puppet::Node::Ldap do
end
it "should search first for the provided key" do
- @searcher.expects(:name2hash).with("mynode.domain.com", 'production', 'child').returns({})
+ @searcher.expects(:name2hash).with("mynode.domain.com").returns({})
@searcher.find(@request)
end
it "should search for the short version of the provided key if the key looks like a hostname and no results are found for the key itself" do
- @searcher.expects(:name2hash).with("mynode.domain.com", 'production', 'child').returns(nil)
- @searcher.expects(:name2hash).with("mynode", 'production', 'child').returns({})
+ @searcher.expects(:name2hash).with("mynode.domain.com").returns(nil)
+ @searcher.expects(:name2hash).with("mynode").returns({})
@searcher.find(@request)
end
it "should search for default information if no information can be found for the key" do
- @searcher.expects(:name2hash).with("mynode.domain.com", 'production', 'child').returns(nil)
- @searcher.expects(:name2hash).with("mynode", 'production', 'child').returns(nil)
- @searcher.expects(:name2hash).with("default", 'production', 'child').returns({})
+ @searcher.expects(:name2hash).with("mynode.domain.com").returns(nil)
+ @searcher.expects(:name2hash).with("mynode").returns(nil)
+ @searcher.expects(:name2hash).with("default").returns({})
@searcher.find(@request)
end
@@ -158,8 +158,8 @@ describe Puppet::Node::Ldap do
end
it "should create the node with the correct name, even if it was found by a different name" do
- @searcher.expects(:name2hash).with("mynode.domain.com", 'production', 'child').returns nil
- @searcher.expects(:name2hash).with("mynode", 'production', 'child').returns @result
+ @searcher.expects(:name2hash).with("mynode.domain.com").returns nil
+ @searcher.expects(:name2hash).with("mynode").returns @result
Puppet::Node.expects(:new).with("mynode.domain.com").returns @node
@searcher.find(@request)
@@ -209,15 +209,17 @@ describe Puppet::Node::Ldap do
@parent = {:classes => [], :parameters => {}}
@parent_parent = {:classes => [], :parameters => {}}
- @searcher.stubs(:name2hash).with{|name, env, mode| name == @name}.returns(@entry)
- @searcher.stubs(:name2hash).with{|name, env, mode| name == 'parent'}.returns(@parent)
- @searcher.stubs(:name2hash).with{|name, env, mode| name == 'parent_parent'}.returns(@parent_parent)
+ @searcher.stubs(:name2hash).with(@name).returns(@entry)
+ @searcher.stubs(:name2hash).with('parent').returns(@parent)
+ @searcher.stubs(:name2hash).with('parent_parent').returns(@parent_parent)
@searcher.stubs(:parent_attribute).returns(:parent)
end
it "should search for the parent node" do
@entry[:parent] = "parent"
+ @searcher.expects(:name2hash).with(@name).returns @entry
+ @searcher.expects(:name2hash).with('parent').returns @parent
@searcher.find(@request)
end
@@ -225,7 +227,7 @@ describe Puppet::Node::Ldap do
it "should fail if the parent cannot be found" do
@entry[:parent] = "parent"
- @searcher.expects(:name2hash).with('parent', 'production', 'parent').returns nil
+ @searcher.expects(:name2hash).with('parent').returns nil
proc { @searcher.find(@request) }.should raise_error(Puppet::Error)
end
--
Puppet packaging for Debian
More information about the Pkg-puppet-devel
mailing list