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