1 class MCollective::Application::Facts<MCollective::Application
2 description "Reports on usage for a specific fact"
4 def post_option_parser(configuration)
5 configuration[:fact] = ARGV.shift if ARGV.size > 0
8 def validate_configuration(configuration)
9 raise "Please specify a fact to report for" unless configuration.include?(:fact)
12 def show_single_fact_report(fact, facts, verbose=false)
13 puts("Report for fact: #{fact}\n\n")
15 facts.keys.sort.each do |k|
16 printf(" %-40sfound %d times\n", k, facts[k].size)
21 facts[k].sort.each do |f|
31 rpcutil = rpcclient("rpcutil")
32 rpcutil.progress = false
36 rpcutil.get_fact(:fact => configuration[:fact]) do |resp|
38 value = resp[:body][:data][:value]
40 facts.include?(value) ? facts[value] << resp[:senderid] : facts[value] = [ resp[:senderid] ]
43 STDERR.puts "Could not parse facts for #{resp[:senderid]}: #{e.class}: #{e}"
47 show_single_fact_report(configuration[:fact], facts, options[:verbose])