fix munin 1
[mirror/dsa-puppet.git] / modules / puppetmaster / lib / puppet / parser / functions / whohosts.rb
index 20f83d3..4359285 100644 (file)
@@ -5,20 +5,14 @@ module Puppet::Parser::Functions
 
     ipAddrs = args[0]
     yamlfile = args[1]
-    parser.watch_file(yamlfile)
-
-    $KCODE = 'utf-8'
 
     ans = {"name" => "unknown"}
     yaml = YAML.load_file(yamlfile)
 
     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
+        next unless yaml[hoster].kind_of?(Hash) and yaml[hoster].has_key?('netrange')
+        netrange = yaml[hoster]['netrange']
 
         netrange.each do |net|
           begin
@@ -32,6 +26,9 @@ module Puppet::Parser::Functions
         end
       end
     end
+    if not ans['longname']
+      ans['longname'] = ans['name']
+    end
     return ans
   end
 end