class Report::Processor
Public Class Methods
new()
click to toggle source
# File lib/puppet/indirector/report/processor.rb 10 def initialize 11 Puppet.settings.use(:main, :reporting, :metrics) 12 end
Public Instance Methods
destroy(request)
click to toggle source
# File lib/puppet/indirector/report/processor.rb 18 def destroy(request) 19 processors do |mod| 20 mod.destroy(request.key) if mod.respond_to?(:destroy) 21 end 22 end
save(request)
click to toggle source
# File lib/puppet/indirector/report/processor.rb 14 def save(request) 15 process(request.instance) 16 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 29 def process(report) 30 Puppet.debug { "Received report to process from #{report.host}" } 31 processors do |mod| 32 Puppet.debug { "Processing report from #{report.host} with processor #{mod}" } 33 # We have to use a dup because we're including a module in the 34 # report. 35 newrep = report.dup 36 begin 37 newrep.extend(mod) 38 newrep.process 39 rescue => detail 40 Puppet.log_exception(detail, _("Report %{report} failed: %{detail}") % { report: name, detail: detail }) 41 end 42 end 43 end
processors() { |mod| ... }
click to toggle source
# File lib/puppet/indirector/report/processor.rb 50 def processors(&blk) 51 return [] if Puppet[:reports] == "none" 52 reports.each do |name| 53 mod = Puppet::Reports.report(name) 54 if mod 55 yield(mod) 56 else 57 Puppet.warning _("No report named '%{name}'") % { name: name } 58 end 59 end 60 end
reports()
click to toggle source
Handle the parsing of the reports attribute.
# File lib/puppet/indirector/report/processor.rb 46 def reports 47 Puppet[:reports].gsub(/(^\s+)|(\s+$)/, '').split(/\s*,\s*/) 48 end