Updated mcollective.init according to OSCI-658
[packages/precise/mcollective.git] / plugins / mcollective / application / find.rb
diff --git a/plugins/mcollective/application/find.rb b/plugins/mcollective/application/find.rb
new file mode 100644 (file)
index 0000000..c0967d2
--- /dev/null
@@ -0,0 +1,21 @@
+class MCollective::Application::Find<MCollective::Application
+  description "Find hosts using the discovery system matching filter criteria"
+
+  def main
+    mc = rpcclient("rpcutil")
+
+    starttime = Time.now
+
+    nodes = mc.discover
+
+    discoverytime = Time.now - starttime
+
+    STDERR.puts if options[:verbose]
+
+    nodes.each {|c| puts c}
+
+    STDERR.puts "\nDiscovered %s nodes in %.2f seconds using the %s discovery plugin" % [nodes.size, discoverytime, mc.client.discoverer.discovery_method] if options[:verbose]
+
+    nodes.size > 0 ? exit(0) : exit(1)
+  end
+end