diff options
author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-09-20 22:38:46 +0000 |
---|---|---|
committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-09-20 22:38:46 +0000 |
commit | dc8fb0a30154258084c39d62c9ee2fdf6d9c48a6 (patch) | |
tree | d067a3e5ba5267041d78cd071c6c04b5de68425d /lib/puppet | |
parent | afed9a17224ab28788b3f64008c13ce18c1ca914 (diff) | |
download | puppet-dc8fb0a30154258084c39d62c9ee2fdf6d9c48a6.tar.gz puppet-dc8fb0a30154258084c39d62c9ee2fdf6d9c48a6.tar.xz puppet-dc8fb0a30154258084c39d62c9ee2fdf6d9c48a6.zip |
Fixing #292 (A bug in tagmail that causes any tag other than 'all' to fail)
and #277 (tagmail report missing To: header).
#292 was weird because the messages just didn't have the tags at all.
The problem was that states didn't have tags, yet states were the source
of nearly all messages. So, I added tags to the states, and included
the state name in the tag list. Also, types were not including the type
name in the tag list, so I added that. And, of course, a few unit tests
to check it all.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1638 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet')
-rw-r--r-- | lib/puppet/log.rb | 3 | ||||
-rw-r--r-- | lib/puppet/reports/tagmail.rb | 5 | ||||
-rw-r--r-- | lib/puppet/type.rb | 2 | ||||
-rw-r--r-- | lib/puppet/type/state.rb | 13 |
4 files changed, 22 insertions, 1 deletions
diff --git a/lib/puppet/log.rb b/lib/puppet/log.rb index 7a08ba57d..ee825e406 100644 --- a/lib/puppet/log.rb +++ b/lib/puppet/log.rb @@ -5,6 +5,7 @@ module Puppet # expected that that will be the most common log destination. Supports # multiple destinations, one of which is a remote server. class Log + include Puppet::Util PINK="[0;31m" GREEN="[0;32m" YELLOW="[0;33m" @@ -501,7 +502,7 @@ module Puppet end def tagged?(tag) - @tags.include?(tag) + @tags.detect { |t| t.to_s == tag.to_s } end def to_report diff --git a/lib/puppet/reports/tagmail.rb b/lib/puppet/reports/tagmail.rb index ba929b7fc..477246e0b 100644 --- a/lib/puppet/reports/tagmail.rb +++ b/lib/puppet/reports/tagmail.rb @@ -20,6 +20,8 @@ Puppet::Server::Report.newreport(:tagmail) do |report| return end + p report + # Load the config file tags = {} File.readlines(Puppet[:tagmap]).each do |line| @@ -83,6 +85,7 @@ Puppet::Server::Report.newreport(:tagmail) do |report| # We need to open a separate process for every set of email addresses IO.popen(Puppet[:sendmail] + " " + emails.join(" "), "w") do |p| p.puts "From: #{Puppet[:reportfrom]}" + p.puts "To: %s" % emails.join(', ') p.puts "Subject: Puppet Report for %s" % report.host p.puts messages @@ -100,3 +103,5 @@ Puppet::Server::Report.newreport(:tagmail) do |report| end end end + +# $Id$ diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb index 1f8af8e82..0e0628202 100644 --- a/lib/puppet/type.rb +++ b/lib/puppet/type.rb @@ -1766,6 +1766,8 @@ class Type < Puppet::Element self.warning "Ignoring tag %s of type %s" % [tag.inspect, tag.class] end end + + @tags << self.class.name unless @tags.include?(self.class.name) end # Figure out of any of the specified tags apply to this object. This is an diff --git a/lib/puppet/type/state.rb b/lib/puppet/type/state.rb index e372db6db..e5aa3b1b6 100644 --- a/lib/puppet/type/state.rb +++ b/lib/puppet/type/state.rb @@ -363,6 +363,19 @@ class State < Puppet::Parameter self.set end + # The states need to return tags so that logs correctly collect them. + def tags + unless defined? @tags + @tags = [] + # This might not be true in testing + if @parent.respond_to? :tags + @tags = @parent.tags + end + @tags << self.name + end + @tags + end + def to_s return "%s(%s)" % [@parent.name,self.name] end |