summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-06-29 16:05:52 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-06-29 16:05:52 +0000
commit56a28456c240bc25b89a4a6b02e39aaaef162391 (patch)
treec55f0f045f69ccd5ccd2cce74b330419636c6584
parentd2754895ead8e8b036e29a628e3de9fad1abba34 (diff)
Adding report collection to both statechange and transaction.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1336 980ebf18-57e1-0310-9a29-db15c13687c0
-rw-r--r--lib/puppet/statechange.rb5
-rw-r--r--lib/puppet/transaction.rb6
-rw-r--r--lib/puppet/type.rb7
-rw-r--r--test/other/transactions.rb29
4 files changed, 39 insertions, 8 deletions
diff --git a/lib/puppet/statechange.rb b/lib/puppet/statechange.rb
index d11cb6734..4884026fe 100644
--- a/lib/puppet/statechange.rb
+++ b/lib/puppet/statechange.rb
@@ -7,6 +7,9 @@ module Puppet
# including calling 'sync' on the states and producing events.
class StateChange
attr_accessor :is, :should, :type, :path, :state, :transaction, :changed
+
+ # The log file generated when this object was changed.
+ attr_reader :report
def initialize(state)
@state = state
@@ -68,7 +71,7 @@ module Puppet
# should basically point to that, right?
#:state => @state,
#:object => @state.parent,
- @state.log @state.change_to_s
+ @report = @state.log(@state.change_to_s)
Puppet::Event.new(
:event => event,
:change => self,
diff --git a/lib/puppet/transaction.rb b/lib/puppet/transaction.rb
index 20b65abed..0281f16ed 100644
--- a/lib/puppet/transaction.rb
+++ b/lib/puppet/transaction.rb
@@ -211,6 +211,12 @@ class Transaction
end
end
+ def report
+ @changes.collect do |change|
+ change.report
+ end
+ end
+
# Roll all completed changes back.
def rollback
@targets.clear
diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb
index b666317bb..06ebab9e7 100644
--- a/lib/puppet/type.rb
+++ b/lib/puppet/type.rb
@@ -1442,13 +1442,6 @@ class Type < Puppet::Element
if self.respond_to?(:validate)
self.validate
end
-
- # Ensure defaults to present for managed objects, but not otherwise.
- # Because of this complication, we can't use normal defaulting mechanisms
-# if ! @states.include?(:ensure) and self.managed? and
-# self.class.validstate?(:ensure)
-# self[:ensure] = :present
-# end
end
# Figure out of there are any objects we can automatically add as
diff --git a/test/other/transactions.rb b/test/other/transactions.rb
index 65e159f1b..cfb00eaeb 100644
--- a/test/other/transactions.rb
+++ b/test/other/transactions.rb
@@ -17,6 +17,35 @@ class TestTransactions < Test::Unit::TestCase
def test_nothing
end
+ def test_reports
+ path1 = tempfile()
+ path2 = tempfile()
+ objects = []
+ objects << Puppet::Type.newfile(
+ :path => path1,
+ :content => "yayness"
+ )
+ objects << Puppet::Type.newfile(
+ :path => path2,
+ :content => "booness"
+ )
+
+ trans = assert_events([:file_created, :file_created], *objects)
+
+ report = nil
+
+ assert_nothing_raised {
+ report = trans.report
+ }
+
+ assert_equal(2, report.length,
+ "Did not get the right number of log messages back")
+
+ report.each do |obj|
+ assert_instance_of(Puppet::Log, obj)
+ end
+ end
+
unless %x{groups}.chomp.split(/ /).length > 1
$stderr.puts "You must be a member of more than one group to test transactions"
else