class ForemanMaintain::Runner::Execution
Class representing an execution of a single step in scenario
Attributes
ended_at[R]
Information about timings, collected automatically
output[RW]
Output of the execution, to be filled by execution step
reporter[R]
started_at[R]
Information about timings, collected automatically
status[RW]
One of :pending, :running, :success, :fail, :skipped
step[R]
Step performed as part of the execution
Public Class Methods
new(step, reporter, options = {})
click to toggle source
# File lib/foreman_maintain/runner/execution.rb, line 23 def initialize(step, reporter, options = {}) options.validate_options!(:whitelisted, :storage, :force) @step = step @reporter = reporter @status = :pending @output = '' @whitelisted = options[:whitelisted] @storage = options[:storage] @force = options[:force] end
Public Instance Methods
aborted?()
click to toggle source
# File lib/foreman_maintain/runner/execution.rb, line 50 def aborted? @status == :abort end
fail?()
click to toggle source
# File lib/foreman_maintain/runner/execution.rb, line 46 def fail? @status == :fail end
info_warning?()
click to toggle source
# File lib/foreman_maintain/runner/execution.rb, line 66 def info_warning? @status == :info_warning end
name()
click to toggle source
# File lib/foreman_maintain/runner/execution.rb, line 34 def name @step.description end
run()
click to toggle source
# File lib/foreman_maintain/runner/execution.rb, line 75 def run @reporter.before_execution_starts(self) if skip? @status = :already_run return end @status = whitelisted? ? :skipped : :running with_metadata_calculation do capture_errors do step.__run__(self) end end # change the state only when not modified @status = :success if @status == :running ensure @reporter.after_execution_finishes(self) end
skip?()
click to toggle source
# File lib/foreman_maintain/runner/execution.rb, line 58 def skip? !@force && step.run_once? && step.executed? && step.success? end
skipped?()
click to toggle source
# File lib/foreman_maintain/runner/execution.rb, line 54 def skipped? @status == :skipped end
storage()
click to toggle source
yaml storage to preserve key/value pairs between runs.
# File lib/foreman_maintain/runner/execution.rb, line 71 def storage @storage || ForemanMaintain.storage(:default) end
success?()
click to toggle source
# File lib/foreman_maintain/runner/execution.rb, line 42 def success? [:success, :already_run, :skipped].include?(@status) end
update(line)
click to toggle source
# File lib/foreman_maintain/runner/execution.rb, line 97 def update(line) @reporter.on_execution_update(self, line) end
warning?()
click to toggle source
# File lib/foreman_maintain/runner/execution.rb, line 62 def warning? @status == :warning end
whitelisted?()
click to toggle source
# File lib/foreman_maintain/runner/execution.rb, line 38 def whitelisted? @whitelisted end
Private Instance Methods
capture_errors() { || ... }
click to toggle source
# File lib/foreman_maintain/runner/execution.rb, line 110 def capture_errors yield rescue StandardError => e @status = :fail @output << e.message logger.error(e) end
with_metadata_calculation() { || ... }
click to toggle source
# File lib/foreman_maintain/runner/execution.rb, line 103 def with_metadata_calculation @started_at = Time.now yield ensure @ended_at = Time.now end