From 70ea39af65f7e56ce151c9f9ca444261d0332454 Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Thu, 12 Feb 2009 16:00:29 -0600 Subject: Adding a post-processor for Nagios names. This is a brutal hack until Puppet correctly supports multiple primary keys. It basically just comments out _naginator_name before writing to disk, and uncomments it when reading. This allows Puppet to use it while Nagios ignores it. Yes, a stupid hack, but it appears to work. Signed-off-by: Luke Kanies --- lib/puppet/provider/naginator.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/puppet/provider/naginator.rb b/lib/puppet/provider/naginator.rb index 233d82eb6..5510eb9c8 100644 --- a/lib/puppet/provider/naginator.rb +++ b/lib/puppet/provider/naginator.rb @@ -7,6 +7,7 @@ require 'puppet/external/nagios' # The base class for all Naginator providers. class Puppet::Provider::Naginator < Puppet::Provider::ParsedFile + NAME_STRING = "## --PUPPET_NAME-- (called '_naginator_name' in the manifest)" # Retrieve the associated class from Nagios::Base. def self.nagios_type unless defined?(@nagios_type) and @nagios_type @@ -24,14 +25,14 @@ class Puppet::Provider::Naginator < Puppet::Provider::ParsedFile def self.parse(text) begin - Nagios::Parser.new.parse(text) + Nagios::Parser.new.parse(text.gsub(NAME_STRING, "_naginator_name")) rescue => detail raise Puppet::Error, "Could not parse configuration for %s: %s" % [resource_type.name, detail] end end def self.to_file(records) - header + records.collect { |record| record.to_s }.join("\n") + header + records.collect { |record| record.to_s }.join("\n").gsub("_naginator_name", NAME_STRING) end def self.skip_record?(record) -- cgit