Update version according to OSCI-856
[packages/precise/mcollective.git] / plugins / mcollective / application / rpc.rb
index 32d59f97264459ae05c97ef94a53a0deb292fd75..47d5665a123d38218daf5f3f6f0bf36a427297d8 100644 (file)
@@ -95,13 +95,18 @@ class MCollective::Application::Rpc<MCollective::Application
 
       puts "Request sent with id: " + mc.send(configuration[:action], configuration[:arguments])
     else
-      # if there's stuff on STDIN assume its JSON that came from another
-      # rpc or printrpc, we feed that in as discovery data
       discover_args = {:verbose => true}
-
-      unless STDIN.tty?
-        discovery_data = STDIN.read.chomp
-        discover_args = {:json => discovery_data} unless discovery_data == ""
+      # IF the discovery method hasn't been explicitly overridden
+      #  and we're not being run interactively,
+      #  and someone has piped us some data
+      # Then we assume it's a discovery list - this can be either:
+      #  - list of hosts in plaintext
+      #  - JSON that came from another rpc or printrpc
+      if mc.default_discovery_method && !STDIN.tty? && !STDIN.eof?
+          # Then we override discovery to try to grok the data on STDIN
+          mc.discovery_method = 'stdin'
+          mc.discovery_options = 'auto'
+          discover_args = {:verbose => false}
       end
 
       mc.discover discover_args