From 4d3030c6dd67dcb1f6116e7e3d09ddcd20ee726b Mon Sep 17 00:00:00 2001 From: Paul Berry Date: Thu, 16 Dec 2010 16:23:34 -0800 Subject: Modified the behavior of Puppet::Resource::Status as follows: - #change_count now only counts events that represent successful changes. It does not count failures, audits, or noops. - #changed is equivalent to #change_count > 0. - #out_of_sync_count (a new attribute) counts all events except audits. - #out_of_sync is equivalent to #out_of_sync_count > 0. This should hopefully make the summary statistics in reports more useful. --- lib/puppet/resource/status.rb | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/puppet/resource/status.rb b/lib/puppet/resource/status.rb index 9240a06d7..f34edc469 100644 --- a/lib/puppet/resource/status.rb +++ b/lib/puppet/resource/status.rb @@ -10,7 +10,7 @@ module Puppet attr_accessor *STATES attr_reader :source_description, :default_log_level, :time, :resource - attr_reader :change_count + attr_reader :change_count, :out_of_sync_count # Provide a boolean method for each of the states. STATES.each do |attr| @@ -28,10 +28,14 @@ module Puppet @events << event if event.status == 'failure' self.failed = true + elsif event.status == 'success' + @change_count += 1 + @changed = true + end + if event.status != 'audit' + @out_of_sync_count += 1 + @out_of_sync = true end - @change_count += 1 - @changed = true - @out_of_sync = true end def events @@ -42,6 +46,7 @@ module Puppet @source_description = resource.path @resource = resource.to_s @change_count = 0 + @out_of_sync_count = 0 [:file, :line, :version].each do |attr| send(attr.to_s + "=", resource.send(attr)) -- cgit