~ubuntu-branches/ubuntu/trusty/puppet/trusty

« back to all changes in this revision

Viewing changes to lib/puppet/indirector/report/processor.rb

  • Committer: Package Import Robot
  • Author(s): Stig Sandbeck Mathisen
  • Date: 2011-10-22 14:08:22 UTC
  • mfrom: (1.1.25) (3.1.32 sid)
  • Revision ID: package-import@ubuntu.com-20111022140822-odxde5lohc45yhuz
Tags: 2.7.6-1
* New upstream release (CVE-2011-3872)
* Remove cherry-picked "groupadd_aix_warning" patch
* Install all new manpages

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
    process(request.instance)
15
15
  end
16
16
 
 
17
  def destroy(request)
 
18
    processors do |mod|
 
19
      mod.destroy(request.key) if mod.respond_to?(:destroy)
 
20
    end
 
21
  end
 
22
 
17
23
  private
18
24
 
19
25
  # Process the report with each of the configured report types.
20
26
  # LAK:NOTE This isn't necessarily the best design, but it's backward
21
27
  # compatible and that's good enough for now.
22
28
  def process(report)
 
29
    Puppet.debug "Recieved 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
        puts detail.backtrace if Puppet[:trace]
 
40
        Puppet.err "Report #{name} failed: #{detail}"
 
41
      end
 
42
    end
 
43
  end
 
44
 
 
45
  # Handle the parsing of the reports attribute.
 
46
  def reports
 
47
    # LAK:NOTE See http://snurl.com/21zf8  [groups_google_com]
 
48
    x = Puppet[:reports].gsub(/(^\s+)|(\s+$)/, '').split(/\s*,\s*/)
 
49
  end
 
50
 
 
51
  def processors(&blk)
23
52
    return if Puppet[:reports] == "none"
24
 
 
25
53
    reports.each do |name|
26
54
      if mod = Puppet::Reports.report(name)
27
 
        # We have to use a dup because we're including a module in the
28
 
        # report.
29
 
        newrep = report.dup
30
 
        begin
31
 
          newrep.extend(mod)
32
 
          newrep.process
33
 
        rescue => detail
34
 
          puts detail.backtrace if Puppet[:trace]
35
 
          Puppet.err "Report #{name} failed: #{detail}"
36
 
        end
 
55
        yield(mod)
37
56
      else
38
57
        Puppet.warning "No report named '#{name}'"
39
58
      end
40
59
    end
41
60
  end
42
 
 
43
 
  # Handle the parsing of the reports attribute.
44
 
  def reports
45
 
    # LAK:NOTE See http://snurl.com/21zf8  [groups_google_com]
46
 
    x = Puppet[:reports].gsub(/(^\s+)|(\s+$)/, '').split(/\s*,\s*/)
47
 
  end
48
61
end