c0967d2bec490851d0bd026d46b06a31c205b0b2
[packages/precise/mcollective.git] / plugins / mcollective / application / find.rb
1 class MCollective::Application::Find<MCollective::Application
2   description "Find hosts using the discovery system matching filter criteria"
3
4   def main
5     mc = rpcclient("rpcutil")
6
7     starttime = Time.now
8
9     nodes = mc.discover
10
11     discoverytime = Time.now - starttime
12
13     STDERR.puts if options[:verbose]
14
15     nodes.each {|c| puts c}
16
17     STDERR.puts "\nDiscovered %s nodes in %.2f seconds using the %s discovery plugin" % [nodes.size, discoverytime, mc.client.discoverer.discovery_method] if options[:verbose]
18
19     nodes.size > 0 ? exit(0) : exit(1)
20   end
21 end