summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2009-11-07 17:46:19 -0600
committertest branch <puppet-dev@googlegroups.com>2010-02-17 06:50:53 -0800
commite838bccaee658847e1b2dac5b7e2191a8148202c (patch)
tree2fcaa850dc2e0613a95201574daad24cc83f48bf /lib/puppet
parent977595bd712bfa25c176abb3983bc81df665ea7b (diff)
downloadpuppet-e838bccaee658847e1b2dac5b7e2191a8148202c.tar.gz
puppet-e838bccaee658847e1b2dac5b7e2191a8148202c.tar.xz
puppet-e838bccaee658847e1b2dac5b7e2191a8148202c.zip
Solidifying the RAL/Event integration.
This has two changes: * Clarifies how we get the property and resource name (we pass the instance, the event converts to a string) * Logs at the resource's loglevel when there's no error These are related, because the event creator (resource) was passing in a string rather than an instance. Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/parameter.rb2
-rw-r--r--lib/puppet/property.rb6
-rw-r--r--lib/puppet/transaction/event.rb12
-rw-r--r--lib/puppet/type.rb6
4 files changed, 18 insertions, 8 deletions
diff --git a/lib/puppet/parameter.rb b/lib/puppet/parameter.rb
index 285a205da..8ba19ff7c 100644
--- a/lib/puppet/parameter.rb
+++ b/lib/puppet/parameter.rb
@@ -331,6 +331,6 @@ class Puppet::Parameter
end
def to_s
- s = "Parameter(%s)" % self.name
+ name.to_s
end
end
diff --git a/lib/puppet/property.rb b/lib/puppet/property.rb
index ad8ea623f..b96f6d120 100644
--- a/lib/puppet/property.rb
+++ b/lib/puppet/property.rb
@@ -157,7 +157,7 @@ class Puppet::Property < Puppet::Parameter
# Return a modified form of the resource event.
def event
- resource.event :name => event_name, :desired_value => should, :property => name, :source_description => path
+ resource.event :name => event_name, :desired_value => should, :property => self, :source_description => path
end
attr_reader :shadow
@@ -323,10 +323,6 @@ class Puppet::Property < Puppet::Parameter
set(should)
end
- def to_s
- return "#{resource.name}(#{name})"
- end
-
# Verify that the passed value is valid.
# If the developer uses a 'validate' hook, this method will get overridden.
def unsafe_validate(value)
diff --git a/lib/puppet/transaction/event.rb b/lib/puppet/transaction/event.rb
index 41e1f5130..b962149cf 100644
--- a/lib/puppet/transaction/event.rb
+++ b/lib/puppet/transaction/event.rb
@@ -11,6 +11,7 @@ class Puppet::Transaction::Event
attr_accessor *ATTRIBUTES
attr_writer :tags
attr_accessor :time
+ attr_reader :default_log_level
EVENT_STATUSES = %w{noop success failure}
@@ -26,11 +27,14 @@ class Puppet::Transaction::Event
end
def resource=(res)
+ if res.respond_to?(:[]) and level = res[:loglevel]
+ @default_log_level = level
+ end
@resource = res.to_s
end
def send_log
- super(status == "failure" ? :err : :notice, message)
+ super(log_level, message)
end
def status=(value)
@@ -44,6 +48,12 @@ class Puppet::Transaction::Event
private
+ # If it's a failure, use 'err', else use either the resource's log level (if available)
+ # or 'notice'.
+ def log_level
+ status == "failure" ? :err : (@default_log_level || :notice)
+ end
+
# Used by the Logging module
def log_source
source_description || property || resource
diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb
index 2512c72d3..d17a56d67 100644
--- a/lib/puppet/type.rb
+++ b/lib/puppet/type.rb
@@ -487,7 +487,7 @@ class Type
# 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))
+ Puppet::Transaction::Event.new({:resource => self, :file => file, :line => line, :tags => tags, :version => version}.merge(options))
end
# Let the catalog determine whether a given cached value is
@@ -549,6 +549,10 @@ class Type
@parameters[name.to_sym]
end
+ def parameters
+ @parameters.dup
+ end
+
# Is the named property defined?
def propertydefined?(name)
unless name.is_a? Symbol