6 oparser = MCollective::Optionparser.new({:verbose => true}, "filter")
8 options = oparser.parse{|parser, options|
9 parser.define_head "Call an agent parsing an argument to it"
10 parser.banner = "Usage: mc-call-agent [options] --agent agent --argument arg"
12 parser.on('-a', '--agent AGENT', 'Agent to call') do |v|
16 parser.on('--arg', '--argument ARGUMENT', 'Argument to pass to agent') do |v|
17 options[:argument] = v
21 if options[:agent] == nil || options[:argument] == nil
22 puts("Please use either --agent or --argument")
27 options[:filter]["agent"] << options[:agent]
29 client = MCollective::Client.new(options[:config])
30 client.options = options
34 stats = client.discovered_req(options[:argument], options[:agent]) do |resp|
40 puts("#{resp[:senderid]}>")
44 printf("%-30s", resp[:senderid])
50 STDERR.puts "Could not call remote agent: #{e}"
54 client.display_stats(stats)