Class MCollective::Application::Controller
In: plugins/mcollective/application/controller.rb
Parent: Application

Methods

Public Instance methods

[Source]

    # File plugins/mcollective/application/controller.rb, line 53
53:         def main
54:             client = MCollective::Client.new(options[:config])
55:             client.options = options
56: 
57:             counter = 0
58: 
59:             command = configuration[:command]
60:             command += " #{configuration[:argument]}" if configuration[:argument]
61: 
62:             statistics = client.discovered_req(command, 'mcollective') do |response|
63:                 next unless response
64: 
65:                 counter += 1
66: 
67:                 sender = response[:senderid]
68:                 body   = response[:body]
69: 
70:                 case command
71:                     when /^stats$/
72:                         print_statistics(sender, body[:stats])
73:                     when /^reload_agent(?:.+)/
74:                         printf("%40s> %s\n", sender, body)
75:                     else
76:                         if options[:verbose]
77:                             puts "#{sender}>"
78:                             pp body
79:                         else
80:                             puts if counter % 4 == 1
81:                             print "#{sender} "
82:                         end
83:                 end
84:             end
85: 
86:             client.disconnect
87: 
88:             client.display_stats(statistics, false, "mcollectived controller summary")
89:         end

[Source]

    # File plugins/mcollective/application/controller.rb, line 31
31:         def post_option_parser(configuration)
32:             configuration[:command] = ARGV.shift if ARGV.size > 0
33:         end

[Source]

    # File plugins/mcollective/application/controller.rb, line 23
23:         def print_statistics(sender, statistics)
24:             printf("%40s> total=%d, replies=%d, valid=%d, invalid=%d, " +
25:                 "filtered=%d, passed=%d\n", sender,
26:                 statistics[:total], statistics[:replies],
27:                 statistics[:validated], statistics[:unvalidated],
28:                 statistics[:filtered], statistics[:passed])
29:         end

[Source]

    # File plugins/mcollective/application/controller.rb, line 35
35:         def validate_configuration(configuration)
36:             unless configuration.include?(:command)
37:                 raise "Please specify a command and optional arguments"
38:             end
39: 
40:             #
41:             # When asked to restart an agent we need to make sure that
42:             # we have this agent name and set appropriate filters ...
43:             #
44:             if configuration[:command].match(/^reload_agent$/)
45:                 unless configuration.include?(:argument)
46:                     raise "Please specify an agent name to reload with --argument"
47:                 end
48: 
49:                 options[:filter]['agent'] << configuration[:argument]
50:             end
51:         end

[Validate]