summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2009-11-01 10:47:50 -0600
committertest branch <puppet-dev@googlegroups.com>2010-02-17 06:50:53 -0800
commitf8d7c44fea37dff3e9a86652699bffeab0fbe111 (patch)
tree8c5518e4fd9ba2ae5f20cf4c2b9cac21e21c4019 /lib/puppet
parentee9cff91e1a22a52162d0b8de2aba57f1bbb7e76 (diff)
downloadpuppet-f8d7c44fea37dff3e9a86652699bffeab0fbe111.tar.gz
puppet-f8d7c44fea37dff3e9a86652699bffeab0fbe111.tar.xz
puppet-f8d7c44fea37dff3e9a86652699bffeab0fbe111.zip
Moving event creation to the resource
This allows the Transaction class to reuse the event creation code when it creates noop and restart events. Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/property.rb5
-rw-r--r--lib/puppet/transaction.rb7
-rw-r--r--lib/puppet/type.rb6
3 files changed, 12 insertions, 6 deletions
diff --git a/lib/puppet/property.rb b/lib/puppet/property.rb
index bb58caf5e..9d50dcf6a 100644
--- a/lib/puppet/property.rb
+++ b/lib/puppet/property.rb
@@ -155,10 +155,9 @@ class Puppet::Property < Puppet::Parameter
end).to_sym
end
- # Create our event object.
+ # Return a modified form of the resource event.
def event
- Puppet::Transaction::Event.new(:name => event_name, :resource => resource.ref, :desired_value => should,
- :file => file, :line => line, :tags => tags, :property => name, :version => version)
+ resource.event :name => event_name, :desired_value => should, :property => name
end
attr_reader :shadow
diff --git a/lib/puppet/transaction.rb b/lib/puppet/transaction.rb
index a5feecbc2..0a26e33fe 100644
--- a/lib/puppet/transaction.rb
+++ b/lib/puppet/transaction.rb
@@ -409,7 +409,7 @@ class Puppet::Transaction
end
if restarted
- queue_event(resource, Puppet::Transaction::Event.new(:restarted, resource))
+ queue_event(resource, resource.event(:name => :restarted, :status => "success"))
@resourcemetrics[:restarted] += 1
end
@@ -544,7 +544,8 @@ class Puppet::Transaction
end
def process_callback(resource, callback, events)
- process_noop_events(resource, callback, events) and return false if events.detect { |e| e.name == :noop }
+ # XXX Should it be any event, or all events?
+ process_noop_events(resource, callback, events) and return false unless events.detect { |e| e.status != "noop" }
resource.send(callback)
resource.notice "Triggered '#{callback}' from #{events.length} events"
@@ -561,7 +562,7 @@ class Puppet::Transaction
resource.notice "Would have triggered '#{callback}' from #{events.length} events"
# And then add an event for it.
- queue_event(resource, Puppet::Transaction::Event.new(:noop, resource))
+ queue_event(resource, resource.event(:status => "noop", :name => :noop_restart))
true # so the 'and if' works
end
end
diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb
index 84f0b93d0..2512c72d3 100644
--- a/lib/puppet/type.rb
+++ b/lib/puppet/type.rb
@@ -484,6 +484,12 @@ class Type
}
end
+ # Create a transaction event. Called by Transaction or by
+ # a property.
+ def event(options = {})
+ Puppet::Transaction::Event.new({:resource => ref, :file => file, :line => line, :tags => tags, :version => version}.merge(options))
+ end
+
# Let the catalog determine whether a given cached value is
# still valid or has expired.
def expirer