1 module Puppet::Parser::Functions
2 newfunction(:whohosts, :type => :rvalue) do |args|
9 ans = {"name" => "unknown"}
10 yaml = YAML.load_file(yamlfile)
12 ipAddrs.each do |addr|
13 yaml.keys.each do |hoster|
14 next unless yaml[hoster].kind_of?(Hash) and yaml[hoster].has_key?('netrange')
15 netrange = yaml[hoster]['netrange']
17 netrange.each do |net|
19 if IPAddr.new(net).include?(addr)
24 raise Puppet::ParseError, "Error while trying to match addr #{addr} for net #{net}: #{e.message}\n#{e.backtrace}"
29 if not ans['longname']
30 ans['longname'] = ans['name']
37 # vim:set shiftwidth=2: