Sha256: 63d9c5dfefa52c0689d6ec8f87accdb7bdbf198254cccb3646f2cb56034f4888

Contents?: true

Size: 1.49 KB

Versions: 6

Compression:

Stored size: 1.49 KB

Contents

require 'puppet/transaction/report'
require 'puppet/indirector/code'
require 'puppet/reports'

class Puppet::Transaction::Report::Processor < Puppet::Indirector::Code
  desc "Puppet's report processor.  Processes the report with each of
    the report types listed in the 'reports' setting."

  def initialize
    Puppet.settings.use(:main, :reporting, :metrics)
  end

  def save(request)
    process(request.instance)
  end

  private

  # 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.
  def process(report)
    Puppet.debug "Recieved report to process from #{report.host}"
    return if Puppet[:reports] == "none"

    reports.each do |name|
      Puppet.debug "Processing report from #{report.host} with processor #{name}"
      if mod = Puppet::Reports.report(name)
        # We have to use a dup because we're including a module in the
        # report.
        newrep = report.dup
        begin
          newrep.extend(mod)
          newrep.process
        rescue => detail
          puts detail.backtrace if Puppet[:trace]
          Puppet.err "Report #{name} failed: #{detail}"
        end
      else
        Puppet.warning "No report named '#{name}'"
      end
    end
  end

  # Handle the parsing of the reports attribute.
  def reports
    # LAK:NOTE See http://snurl.com/21zf8  [groups_google_com]
    x = Puppet[:reports].gsub(/(^\s+)|(\s+$)/, '').split(/\s*,\s*/)
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
puppet-2.6.18 lib/puppet/indirector/report/processor.rb
puppet-2.6.17 lib/puppet/indirector/report/processor.rb
puppet-2.6.16 lib/puppet/indirector/report/processor.rb
puppet-2.6.15 lib/puppet/indirector/report/processor.rb
puppet-2.6.14 lib/puppet/indirector/report/processor.rb
puppet-2.6.13 lib/puppet/indirector/report/processor.rb