| action | [RW] | |
| ddl | [RW] | |
| functions | [RW] |
# File lib/mcollective/aggregate.rb, line 8
8: def initialize(ddl)
9: @functions = []
10: @ddl = ddl
11: @action = ddl[:action]
12:
13: create_functions
14: end
Call all the appropriate functions with the reply data received from RPC::Client
# File lib/mcollective/aggregate.rb, line 35
35: def call_functions(reply)
36: @functions.each do |function|
37: Log.debug("Calling aggregate function #{function} for result")
38: function.process_result(reply[:data][function.output_name], reply)
39: end
40: end
Check if the function param is defined as an output for the action in the ddl
# File lib/mcollective/aggregate.rb, line 30
30: def contains_output?(output)
31: raise "'#{@ddl[:action]}' action does not contain output '#{output}'" unless @ddl[:output].keys.include?(output)
32: end
Creates instances of the Aggregate functions and stores them in the function array. All aggregate call and summarize method calls operate on these function as a batch.
# File lib/mcollective/aggregate.rb, line 18
18: def create_functions
19: @ddl[:aggregate].each_with_index do |agg, i|
20: contains_output?(agg[:args][0])
21:
22: output = agg[:args][0]
23: arguments = agg[:args][1..(agg[:args].size)]
24:
25: @functions << load_function(agg[:function]).new(output, arguments, agg[:format], @action)
26: end
27: end
Loads function from disk for use
# File lib/mcollective/aggregate.rb, line 52
52: def load_function(function_name)
53: function_name = function_name.to_s.capitalize
54:
55: PluginManager.loadclass("MCollective::Aggregate::#{function_name}") unless Aggregate.const_defined?(function_name)
56: Aggregate.const_get(function_name)
57: rescue Exception
58: raise "Aggregate function file '#{function_name.downcase}.rb' cannot be loaded"
59: end