diff options
author | Markus Roberts <Markus@reality.com> | 2009-12-17 19:58:27 -0800 |
---|---|---|
committer | James Turnbull <james@lovedthanlost.net> | 2009-12-20 09:15:36 +1100 |
commit | 813cb58815f1f8f987ad64f7c7bfb640fbcdfa81 (patch) | |
tree | c93b3ce57cc66d6cca3eb8e43d50e087b335b050 /lib | |
parent | e9a0cb7a28a34fd04db4bfe1db347da5d774f2e8 (diff) | |
download | puppet-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')
-rw-r--r-- | lib/puppet/application/puppetrun.rb | 4 | ||||
-rw-r--r-- | lib/puppet/indirector/node/ldap.rb | 9 |
2 files changed, 8 insertions, 5 deletions
diff --git a/lib/puppet/application/puppetrun.rb b/lib/puppet/application/puppetrun.rb index 41ebf9f1a..4febcf524 100644 --- a/lib/puppet/application/puppetrun.rb +++ b/lib/puppet/application/puppetrun.rb @@ -167,12 +167,12 @@ Puppet::Application.new(:puppetrun) do if Puppet[:node_terminus] == "ldap" and (options[:all] or @classes) if options[:all] - @hosts = Puppet::Node.search("whatever").collect { |node| node.name } + @hosts = Puppet::Node.search("whatever", :fqdn => options[:fqdn]).collect { |node| node.name } puts "all: %s" % @hosts.join(", ") else @hosts = [] @classes.each do |klass| - list = Puppet::Node.search("whatever", :class => klass).collect { |node| node.name } + list = Puppet::Node.search("whatever", :fqdn => options[:fqdn], :class => klass).collect { |node| node.name } puts "%s: %s" % [klass, list.join(", ")] @hosts += list 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) |