summaryrefslogtreecommitdiffstats
path: root/lib/puppet/network
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2007-10-13 14:07:24 -0500
committerLuke Kanies <luke@madstop.com>2007-10-13 14:07:24 -0500
commit29feac0cecddc910b74601d0914fa2c83757b10c (patch)
tree888305ecde1e4a488304f7e2e169bf1ca38e6d19 /lib/puppet/network
parent74d77f76a012d523430e43f1092609a4ca584cc7 (diff)
downloadpuppet-29feac0cecddc910b74601d0914fa2c83757b10c.tar.gz
puppet-29feac0cecddc910b74601d0914fa2c83757b10c.tar.xz
puppet-29feac0cecddc910b74601d0914fa2c83757b10c.zip
Translating the report handler to an indirected model.
I've provided backward compatibility with the old handler. The only terminus type that currently exists for reports is the 'code' terminus, which is used to process reports in the style of the old handler. At some point, we should likely switch at least some of these report types (e.g., 'store') to terminus types.
Diffstat (limited to 'lib/puppet/network')
-rwxr-xr-xlib/puppet/network/handler/report.rb70
1 files changed, 6 insertions, 64 deletions
diff --git a/lib/puppet/network/handler/report.rb b/lib/puppet/network/handler/report.rb
index e202d4e2a..12abc9b15 100755
--- a/lib/puppet/network/handler/report.rb
+++ b/lib/puppet/network/handler/report.rb
@@ -1,78 +1,24 @@
require 'puppet/util/instance_loader'
+require 'puppet/reports'
# A simple server for triggering a new run on a Puppet client.
class Puppet::Network::Handler
class Report < Handler
desc "Accepts a Puppet transaction report and processes it."
- extend Puppet::Util::ClassGen
- extend Puppet::Util::InstanceLoader
-
- module ReportBase
- include Puppet::Util::Docs
- attr_writer :useyaml
-
- def useyaml?
- if defined? @useyaml
- @useyaml
- else
- false
- end
- end
- end
-
@interface = XMLRPC::Service::Interface.new("puppetreports") { |iface|
iface.add_method("string report(array)")
}
- # Set up autoloading and retrieving of reports.
- instance_load :report, 'puppet/reports'
-
- class << self
- attr_reader :hooks
- end
-
# Add a new report type.
def self.newreport(name, options = {}, &block)
- name = symbolize(name)
-
- mod = genmodule(name, :extend => ReportBase, :hash => instance_hash(:report), :block => block)
-
- if options[:useyaml]
- mod.useyaml = true
- end
-
- mod.send(:define_method, :report_name) do
- name
- end
- end
-
- # Collect the docs for all of our reports.
- 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 += "%s\n%s\n" % [name, "-" * name.to_s.length]
-
- docs += Puppet::Util::Docs.scrub(mod.doc) + "\n\n"
- end
-
- docs
- end
-
- # List each of the reports.
- def self.reports
- instance_loader(:report).loadall
- loaded_instances(:report)
+ Puppet.warning "The interface for registering report types has changed; use Puppet::Reports.register_report for report type %s" % name
+ Puppet::Reports.register_report(name, options, &block)
end
def initialize(*args)
super
- Puppet.settings.use(:reporting)
- Puppet.settings.use(:metrics)
+ Puppet.settings.use(:reporting, :metrics)
end
# Accept a report from a client.
@@ -111,17 +57,13 @@ class Puppet::Network::Handler
client = report.host
reports().each do |name|
- if mod = self.class.report(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)
- if mod.useyaml?
- newrep.process(yaml)
- else
- newrep.process
- end
+ newrep.process
rescue => detail
if Puppet[:trace]
puts detail.backtrace