class Report::Processor

Public Class Methods

new() click to toggle source
   # File lib/puppet/indirector/report/processor.rb
 9 def initialize
10   Puppet.settings.use(:main, :reporting, :metrics)
11 end

Public Instance Methods

destroy(request) click to toggle source
   # File lib/puppet/indirector/report/processor.rb
17 def destroy(request)
18   processors do |mod|
19     mod.destroy(request.key) if mod.respond_to?(:destroy)
20   end
21 end
save(request) click to toggle source
   # File lib/puppet/indirector/report/processor.rb
13 def save(request)
14   process(request.instance)
15 end

Private Instance Methods

process(report) click to toggle source

Process the report with each of the configured report types. LAK:NOTE This isn't necessarily the best design, but it's backward compatible and that's good enough for now.

   # File lib/puppet/indirector/report/processor.rb
28 def process(report)
29   Puppet.debug { "Received report to process from #{report.host}" }
30   processors do |mod|
31     Puppet.debug { "Processing report from #{report.host} with processor #{mod}" }
32     # We have to use a dup because we're including a module in the
33     # report.
34     newrep = report.dup
35     begin
36       newrep.extend(mod)
37       newrep.process
38     rescue => detail
39       Puppet.log_exception(detail, _("Report %{report} failed: %{detail}") % { report: name, detail: detail })
40     end
41   end
42 end
processors() { |mod| ... } click to toggle source
   # File lib/puppet/indirector/report/processor.rb
49 def processors(&blk)
50   return [] if Puppet[:reports] == "none"
51   reports.each do |name|
52     mod = Puppet::Reports.report(name)
53     if mod
54       yield(mod)
55     else
56       Puppet.warning _("No report named '%{name}'") % { name: name }
57     end
58   end
59 end
reports() click to toggle source

Handle the parsing of the reports attribute.

   # File lib/puppet/indirector/report/processor.rb
45 def reports
46   Puppet[:reports].gsub(/(^\s+)|(\s+$)/, '').split(/\s*,\s*/)
47 end