X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=modules%2Fpuppetmaster%2Flib%2Fpuppet%2Fparser%2Ffunctions%2Fallnodeinfo.rb;h=012d58eac6700a222aac4b650ed025c35968cd6c;hb=a97bb246b7122f4bb7686b9b48ee379e00bf4914;hp=a71617e53aff13b6a802f5eb51901352aaf10174;hpb=a76d22733a5fa5f9847083d16a3c9dbf6a03ddf1;p=dsa-puppet.git diff --git a/modules/puppetmaster/lib/puppet/parser/functions/allnodeinfo.rb b/modules/puppetmaster/lib/puppet/parser/functions/allnodeinfo.rb index a71617e5..012d58ea 100644 --- a/modules/puppetmaster/lib/puppet/parser/functions/allnodeinfo.rb +++ b/modules/puppetmaster/lib/puppet/parser/functions/allnodeinfo.rb @@ -1,18 +1,22 @@ module Puppet::Parser::Functions newfunction(:allnodeinfo, :type => :rvalue) do |args| - required = args.shift.split() - optional = args.shift.split() + begin + required = args.shift.split() + optional = args.shift.split() - allhosts = function_ldapinfo('*', required+optional ) - res = {} - allhosts.each_pair do |hostname, host| - # If a returned value doesn't have all the attributes we're searching for, skip - # We'll skip if the array is empty, but we also seem to get back a nil object for empty attributes sometimes - next if required.any?{ |a| not host[a] or host[a].empty? } - res[hostname] = host - end + allhosts = function_ldapinfo(['*', *(required+optional) ]) + res = {} + allhosts.each_pair do |hostname, host| + # If a returned value doesn't have all the attributes we're searching for, skip + # We'll skip if the array is empty, but we also seem to get back a nil object for empty attributes sometimes + next if required.any?{ |a| not host[a] or host[a].empty? } + res[hostname] = host + end - return res + return res + rescue => e + raise Puppet::ParseError, "Error in allnodeinfo: #{e.message}\n#{e.backtrace}" + end end end # vim:set et: