1 module Puppet::Parser::Functions
2 newfunction(:whohosts, :type => :rvalue) do |args|
8 parser = Puppet::Parser::Parser.new(environment)
9 parser.watch_file(yamlfile)
13 ans = {"name" => "unknown"}
14 yaml = YAML.load_file(yamlfile)
16 ipAddrs.each do |addr|
17 yaml.keys.each do |hoster|
18 next unless yaml[hoster].kind_of?(Hash) and yaml[hoster].has_key?('netrange')
19 netrange = yaml[hoster]['netrange']
21 netrange.each do |net|
23 if IPAddr.new(net).include?(addr)
28 raise Puppet::ParseError, "Error while trying to match addr #{addr} for net #{net}: #{e.message}\n#{e.backtrace}"
38 # vim:set shiftwidth=2: