Sha256: 8e5ee6c5e05221e4080ae43e0be57d40b8f297dcb0b8afbed93382f437cbae8e

Contents?: true

Size: 1.66 KB

Versions: 34

Compression:

Stored size: 1.66 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
        puts detail.backtrace if Puppet[:trace]
        Puppet.err "Report #{name} failed: #{detail}"
      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

  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

34 entries across 34 versions & 4 rubygems

Version Path
puppet-parse-0.1.4 lib/vendor/puppet/indirector/report/processor.rb
puppet-parse-0.1.3 lib/vendor/puppet/indirector/report/processor.rb
puppet-parse-0.1.2 lib/vendor/puppet/indirector/report/processor.rb
puppet-parse-0.1.1 lib/vendor/puppet/indirector/report/processor.rb
puppet-parse-0.1.0 lib/vendor/puppet/indirector/report/processor.rb
puppet-parse-0.0.6 lib/vendor/puppet/indirector/report/processor.rb
puppet-2.7.21 lib/puppet/indirector/report/processor.rb
puppet-parse-0.0.5 lib/vendor/puppet/indirector/report/processor.rb
puppet-parse-0.0.4 lib/vendor/puppet/indirector/report/processor.rb
puppet-parse-0.0.2 lib/vendor/puppet/indirector/report/processor.rb
puppet-2.7.20 lib/puppet/indirector/report/processor.rb
puppet-2.7.20.rc1 lib/puppet/indirector/report/processor.rb
librarian-puppet-0.9.4 vendor/gems/ruby/1.8/gems/puppet-2.7.18/lib/puppet/indirector/report/processor.rb
puppet-2.7.19 lib/puppet/indirector/report/processor.rb
supply_drop-0.11.0 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/indirector/report/processor.rb
librarian-puppet-0.9.3 vendor/gems/ruby/1.8/gems/puppet-2.7.18/lib/puppet/indirector/report/processor.rb
supply_drop-0.10.2 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/indirector/report/processor.rb
puppet-2.7.18 lib/puppet/indirector/report/processor.rb
supply_drop-0.10.1 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/indirector/report/processor.rb
supply_drop-0.10.0 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/indirector/report/processor.rb