summaryrefslogtreecommitdiffstats
path: root/lib/puppet/indirector/node
diff options
context:
space:
mode:
authorMarkus Roberts <Markus@reality.com>2009-12-17 19:58:27 -0800
committerJames Turnbull <james@lovedthanlost.net>2009-12-20 09:15:36 +1100
commit813cb58815f1f8f987ad64f7c7bfb640fbcdfa81 (patch)
treec93b3ce57cc66d6cca3eb8e43d50e087b335b050 /lib/puppet/indirector/node
parente9a0cb7a28a34fd04db4bfe1db347da5d774f2e8 (diff)
downloadpuppet-813cb58815f1f8f987ad64f7c7bfb640fbcdfa81.tar.gz
puppet-813cb58815f1f8f987ad64f7c7bfb640fbcdfa81.tar.xz
puppet-813cb58815f1f8f987ad64f7c7bfb640fbcdfa81.zip
Fix for #2765 (--no-fqdn regression in puppetrun)
This is basically the fix suggested on the ticket, cleaned up and ruby-ized, with tests. The only functional modification is leaving the default on entry2hash as --no-fqdn to preserve 0.25.1 behaviour as the default. Signed- ff-by: Markus Roberts <Markus@reality.com>
Diffstat (limited to 'lib/puppet/indirector/node')
-rw-r--r--lib/puppet/indirector/node/ldap.rb9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/puppet/indirector/node/ldap.rb b/lib/puppet/indirector/node/ldap.rb
index dd8cebfac..954bc8d78 100644
--- a/lib/puppet/indirector/node/ldap.rb
+++ b/lib/puppet/indirector/node/ldap.rb
@@ -55,7 +55,7 @@ class Puppet::Node::Ldap < Puppet::Indirector::Ldap
end
infos = []
- ldapsearch(filter) { |entry| infos << entry2hash(entry) }
+ ldapsearch(filter) { |entry| infos << entry2hash(entry, request.options[:fqdn]) }
return infos.collect do |info|
info2node(info[:name], info)
@@ -78,9 +78,12 @@ class Puppet::Node::Ldap < Puppet::Indirector::Ldap
end
# Convert the found entry into a simple hash.
- def entry2hash(entry)
+ def entry2hash(entry, fqdn = false)
result = {}
- result[:name] = entry.dn.split(',')[0].split("=")[1]
+
+ cn = entry.dn[ /cn\s*=\s*([^,\s]+)/i,1]
+ dcs = entry.dn.scan(/dc\s*=\s*([^,\s]+)/i)
+ result[:name] = fqdn ? ([cn]+dcs).join('.') : cn
result[:parent] = get_parent_from_entry(entry) if parent_attribute
result[:classes] = get_classes_from_entry(entry)
result[:stacked] = get_stacked_values_from_entry(entry)