Class: Puppet::Reports

Inherits:
Object
  • Object
show all
Extended by:
Util::ClassGen
Defined in:
lib/puppet/reports.rb

Overview

This class is an implementation of a simple mechanism for loading and returning reports. The intent is that a user registers a report by calling Reports.register_report and providing a code block that performs setup, and defines a method called process. The setup, and the process method are called in the context where self is an instance of Transaction::Report which provides the actual data for the report via its methods.

Required configuration:

  • A .rb file that defines a new report should be placed in the master’s directory lib/puppet/reports
  • The puppet.conf file must have report = true in the [agent] section

Examples:

Minimal scaffolding for a report…

Puppet::Reports::.register_report(:myreport) do
  # do setup here
  def process
    if self.status == 'failed'
      msg = "failed puppet run for #{self.host} #{self.status}"
      . . . 
    else
      . . .
    end
  end 
end

See Also:

Class Attribute Summary (collapse)

Class Method Summary (collapse)

Methods included from Util

exit_on_fail, #exit_on_fail, which, #which

Methods included from Util::ClassGen

genconst_string, genthing, handleclassconst, initclass, is_constant_defined?, name2const, storeclass

Class Attribute Details

+ (Object) hooks (readonly) private

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



39
40
41
# File 'lib/puppet/reports.rb', line 39

def hooks
  @hooks
end

Class Method Details

+ (Object) reportdocs  private

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Collects the docs for all reports.



68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/puppet/reports.rb', line 68

def self.reportdocs
  docs = ""

  # Use this method so they all get loaded
  instance_loader(:report).loadall
  loaded_instances(:report).sort { |a,b| a.to_s <=> b.to_s }.each do |name|
    mod = self.report(name)
    docs += "#{name}\n#{"-" * name.to_s.length}\n"

    docs += Puppet::Util::Docs.scrub(mod.doc) + "\n\n"
  end

  docs
end

+ (Object) reports  private

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Lists each of the reports.



85
86
87
88
# File 'lib/puppet/reports.rb', line 85

def self.reports
  instance_loader(:report).loadall
  loaded_instances(:report)
end