Tracks various aspects of a Chef run, including the Node and RunContext, start and end time, and any Exception that stops the run. RunStatus objects are passed to any notification or exception handlers at the completion of a Chef run.
The list of all resources in the current run context’s resource_collection
# File lib/chef/run_status.rb, line 72 def all_resources @run_context && @run_context.resource_collection.all_resources end
The backtrace from exception, if any
# File lib/chef/run_status.rb, line 83 def backtrace @exception && @exception.backtrace end
The elapsed time between start_time and end_time. Returns nil if either value is not set.
# File lib/chef/run_status.rb, line 63 def elapsed_time if @start_time && @end_time @end_time - @start_time else nil end end
Did the Chef run fail?
# File lib/chef/run_status.rb, line 88 def failed? !success? end
Returns a string of the format “ExceptionClass: message” or nil if no exception is set.
# File lib/chef/run_status.rb, line 123 def formatted_exception @exception && "#{@exception.class.name}: #{@exception.message}" end
sets start_time to the current time.
# File lib/chef/run_status.rb, line 52 def start_clock @start_time = Time.now end
sets end_time to the current time
# File lib/chef/run_status.rb, line 57 def stop_clock @end_time = Time.now end
Did the chef run succeed? returns true if no exception has been set.
# File lib/chef/run_status.rb, line 93 def success? @exception.nil? end
A Hash representation of the RunStatus, with the following (Symbol) keys:
:node
:success
:exception
:backtrace
# File lib/chef/run_status.rb, line 107 def to_hash # use a flat hash here so we can't errors from intermediate values being nil { :node => node, :success => success?, :start_time => start_time, :end_time => end_time, :elapsed_time => elapsed_time, :all_resources => all_resources, :updated_resources => updated_resources, :exception => formatted_exception, :backtrace => backtrace, :run_id => run_id} end
Generated with the Darkfish Rdoc Generator 2.