Class: MCollective::Application::Find

Inherits:
MCollective::Application show all
Defined in:
lib/mcollective/application/find.rb

Overview

rubocop:disable Style/ClassAndModuleChildren

Instance Attribute Summary

Attributes inherited from MCollective::Application

#options

Instance Method Summary collapse

Methods inherited from MCollective::Application

[], []=, #application_cli_arguments, #application_description, #application_failure, application_options, #application_options, #application_parse_options, #application_usage, #clioptions, #configuration, description, #disconnect, exclude_argument_sections, external, external_help, #external_help, #external_main, #halt, #halt_code, #help, intialize_application_options, option, #rpcclient, #run, usage, #validate_cli_options, #validate_option

Methods included from RPC

const_missing, discovered, #empty_filter?, #printrpc, #printrpcstats, #rpcclient, #rpcoptions, stats

Instance Method Details

#mainObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/mcollective/application/find.rb', line 4

def main
  mc = rpcclient("rpcutil")

  starttime = Time.now

  mc.detect_and_set_stdin_discovery

  nodes = mc.discover

  discoverytime = Time.now - starttime

  $stderr.puts if options[:verbose]

  nodes.each {|c| puts c}

  warn "\nDiscovered %s nodes in %.2f seconds using the %s discovery plugin" % [nodes.size, discoverytime, mc.client.options[:discovery_method]] if options[:verbose]

  !nodes.empty? ? exit(0) : exit(1)
end