X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=modules%2Fpuppetmaster%2Flib%2Fpuppet%2Fparser%2Ffunctions%2Fwhohosts.rb;h=84b618c3e6f93c05afe172e6bd800a58c2751f7a;hb=377748bbc8dc5824bb518905c0f618b27d5e9ea5;hp=c2bda8c4aa05db1fdf7052d5ef4dbb0e427515cd;hpb=48143e4a3da865ec35a02407723ee995f59f3413;p=mirror%2Fdsa-puppet.git diff --git a/modules/puppetmaster/lib/puppet/parser/functions/whohosts.rb b/modules/puppetmaster/lib/puppet/parser/functions/whohosts.rb index c2bda8c4a..84b618c3e 100644 --- a/modules/puppetmaster/lib/puppet/parser/functions/whohosts.rb +++ b/modules/puppetmaster/lib/puppet/parser/functions/whohosts.rb @@ -15,9 +15,20 @@ module Puppet::Parser::Functions if (nodeinfo['ldap'].has_key?('ipHostNumber')) nodeinfo['ldap']['ipHostNumber'].each do |addr| yaml.keys.each do |hoster| - yaml[hoster].each do |net| - if IPAddr.new(net).include?(addr) - ans = hoster + if yaml[hoster].kind_of?(Array) + netrange = yaml[hoster] + elsif 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 = hoster + end + rescue Exception => e + raise "Error while trying to match addr #{addr} for net #{net}: #{e.message}\n#{e.backtrace}" end end end @@ -26,3 +37,6 @@ module Puppet::Parser::Functions return ans end end +# vim:set ts=2: +# vim:set et: +# vim:set shiftwidth=2: