X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=modules%2Fpuppetmaster%2Flib%2Fpuppet%2Fparser%2Ffunctions%2Fwhohosts.rb;h=20f83d367851f75ad07ad9ba6f957eaaff82038b;hb=69c19f570b0c7668d1374600a5a7cedaa81fbe2d;hp=4b4371db132612fe9617695305367981bf81abc2;hpb=5c6109f1d1fe490d5c725f2706644e88574f0b41;p=dsa-puppet.git diff --git a/modules/puppetmaster/lib/puppet/parser/functions/whohosts.rb b/modules/puppetmaster/lib/puppet/parser/functions/whohosts.rb index 4b4371db..20f83d36 100644 --- a/modules/puppetmaster/lib/puppet/parser/functions/whohosts.rb +++ b/modules/puppetmaster/lib/puppet/parser/functions/whohosts.rb @@ -3,7 +3,7 @@ module Puppet::Parser::Functions require 'ipaddr' require 'yaml' - nodeinfo = args[0] + ipAddrs = args[0] yamlfile = args[1] parser.watch_file(yamlfile) @@ -12,24 +12,22 @@ module Puppet::Parser::Functions ans = {"name" => "unknown"} yaml = YAML.load_file(yamlfile) - if (nodeinfo['ldap'].has_key?('ipHostNumber')) - nodeinfo['ldap']['ipHostNumber'].each do |addr| - yaml.keys.each do |hoster| - if yaml[hoster].kind_of?(Hash) and yaml[hoster].has_key?('netrange') - netrange = yaml[hoster]['netrange'] - else - next - end + ipAddrs.each do |addr| + yaml.keys.each do |hoster| + if yaml[hoster].kind_of?(Hash) and yaml[hoster].has_key?('netrange') + netrange = yaml[hoster]['netrange'] + else + next + end - netrange.each do |net| - begin - if IPAddr.new(net).include?(addr) - ans = yaml[hoster] - ans['name'] = hoster - end - rescue => e - raise Puppet::ParseError, "Error while trying to match addr #{addr} for net #{net}: #{e.message}\n#{e.backtrace}" + netrange.each do |net| + begin + if IPAddr.new(net).include?(addr) + ans = yaml[hoster] + ans['name'] = hoster end + rescue => e + raise Puppet::ParseError, "Error while trying to match addr #{addr} for net #{net}: #{e.message}\n#{e.backtrace}" end end end