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