Sha256: 819aa5cde4c7d3976e38527f65be9e6a9dfa193e28c1eb3439d6dd300f8cf033

Contents?: true

Size: 1.57 KB

Versions: 246

Compression:

Stored size: 1.57 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

  def destroy(request)
    processors do |mod|
      mod.destroy(request.key) if mod.respond_to?(:destroy)
    end
  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 "Received report to process from #{report.host}"
    processors do |mod|
      Puppet.debug "Processing report from #{report.host} with processor #{mod}"
      # 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
        Puppet.log_exception(detail, "Report #{name} failed: #{detail}")
      end
    end
  end

  # Handle the parsing of the reports attribute.
  def reports
    Puppet[:reports].gsub(/(^\s+)|(\s+$)/, '').split(/\s*,\s*/)
  end

  def processors(&blk)
    return [] if Puppet[:reports] == "none"
    reports.each do |name|
      if mod = Puppet::Reports.report(name)
        yield(mod)
      else
        Puppet.warning "No report named '#{name}'"
      end
    end
  end
end

Version data entries

246 entries across 246 versions & 2 rubygems

Version Path
puppet-retrospec-1.8.0 vendor/pup410/lib/puppet/indirector/report/processor.rb
puppet-retrospec-1.7.0 vendor/pup410/lib/puppet/indirector/report/processor.rb
puppet-4.10.12 lib/puppet/indirector/report/processor.rb
puppet-4.10.12-x86-mingw32 lib/puppet/indirector/report/processor.rb
puppet-4.10.12-x64-mingw32 lib/puppet/indirector/report/processor.rb
puppet-4.10.12-universal-darwin lib/puppet/indirector/report/processor.rb
puppet-4.10.11 lib/puppet/indirector/report/processor.rb
puppet-4.10.11-x86-mingw32 lib/puppet/indirector/report/processor.rb
puppet-4.10.11-x64-mingw32 lib/puppet/indirector/report/processor.rb
puppet-4.10.11-universal-darwin lib/puppet/indirector/report/processor.rb
puppet-4.10.10 lib/puppet/indirector/report/processor.rb
puppet-4.10.10-x86-mingw32 lib/puppet/indirector/report/processor.rb
puppet-4.10.10-x64-mingw32 lib/puppet/indirector/report/processor.rb
puppet-4.10.10-universal-darwin lib/puppet/indirector/report/processor.rb
puppet-retrospec-1.6.1 vendor/pup410/lib/puppet/indirector/report/processor.rb
puppet-retrospec-1.6.0 vendor/pup410/lib/puppet/indirector/report/processor.rb
puppet-4.10.9 lib/puppet/indirector/report/processor.rb
puppet-4.10.9-x86-mingw32 lib/puppet/indirector/report/processor.rb
puppet-4.10.9-x64-mingw32 lib/puppet/indirector/report/processor.rb
puppet-4.10.9-universal-darwin lib/puppet/indirector/report/processor.rb