Class: ForemanMaintain::Runner::Execution
- Inherits:
-
Object
- Object
- ForemanMaintain::Runner::Execution
- Extended by:
- Forwardable
- Includes:
- Concerns::Logger
- Defined in:
- lib/foreman_maintain/runner/execution.rb
Overview
Class representing an execution of a single step in scenario
Direct Known Subclasses
Instance Attribute Summary collapse
-
#ended_at ⇒ Object
readonly
Information about timings, collected automatically.
-
#output ⇒ Object
Output of the execution, to be filled by execution step.
-
#reporter ⇒ Object
readonly
Returns the value of attribute reporter.
-
#started_at ⇒ Object
readonly
Information about timings, collected automatically.
-
#status ⇒ Object
One of :pending, :running, :success, :fail, :skipped.
-
#step ⇒ Object
readonly
Step performed as part of the execution.
Instance Method Summary collapse
- #aborted? ⇒ Boolean
- #fail? ⇒ Boolean
- #info_warning? ⇒ Boolean
-
#initialize(step, reporter, options = {}) ⇒ Execution
constructor
A new instance of Execution.
- #name ⇒ Object
- #run ⇒ Object
- #skip? ⇒ Boolean
- #skipped? ⇒ Boolean
-
#storage ⇒ Object
yaml storage to preserve key/value pairs between runs.
- #success? ⇒ Boolean
- #update(line) ⇒ Object
- #warning? ⇒ Boolean
- #whitelisted? ⇒ Boolean
Methods included from Concerns::Logger
Constructor Details
#initialize(step, reporter, options = {}) ⇒ Execution
Returns a new instance of Execution.
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/foreman_maintain/runner/execution.rb', line 23 def initialize(step, reporter, = {}) .(:whitelisted, :storage, :force) @step = step @reporter = reporter @status = :pending @output = '' @whitelisted = [:whitelisted] @storage = [:storage] @force = [:force] end |
Instance Attribute Details
#ended_at ⇒ Object (readonly)
Information about timings, collected automatically
13 14 15 |
# File 'lib/foreman_maintain/runner/execution.rb', line 13 def ended_at @ended_at end |
#output ⇒ Object
Output of the execution, to be filled by execution step
19 20 21 |
# File 'lib/foreman_maintain/runner/execution.rb', line 19 def output @output end |
#reporter ⇒ Object (readonly)
Returns the value of attribute reporter.
21 22 23 |
# File 'lib/foreman_maintain/runner/execution.rb', line 21 def reporter @reporter end |
#started_at ⇒ Object (readonly)
Information about timings, collected automatically
13 14 15 |
# File 'lib/foreman_maintain/runner/execution.rb', line 13 def started_at @started_at end |
#status ⇒ Object
One of :pending, :running, :success, :fail, :skipped
16 17 18 |
# File 'lib/foreman_maintain/runner/execution.rb', line 16 def status @status end |
#step ⇒ Object (readonly)
Step performed as part of the execution
10 11 12 |
# File 'lib/foreman_maintain/runner/execution.rb', line 10 def step @step end |
Instance Method Details
#aborted? ⇒ Boolean
50 51 52 |
# File 'lib/foreman_maintain/runner/execution.rb', line 50 def aborted? @status == :abort end |
#fail? ⇒ Boolean
46 47 48 |
# File 'lib/foreman_maintain/runner/execution.rb', line 46 def fail? @status == :fail end |
#info_warning? ⇒ Boolean
66 67 68 |
# File 'lib/foreman_maintain/runner/execution.rb', line 66 def info_warning? @status == :info_warning end |
#name ⇒ Object
34 35 36 |
# File 'lib/foreman_maintain/runner/execution.rb', line 34 def name @step.description end |
#run ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# 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 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? ⇒ Boolean
58 59 60 |
# File 'lib/foreman_maintain/runner/execution.rb', line 58 def skip? !@force && step.run_once? && step.executed? && step.success? end |
#skipped? ⇒ Boolean
54 55 56 |
# File 'lib/foreman_maintain/runner/execution.rb', line 54 def skipped? @status == :skipped end |
#storage ⇒ Object
yaml storage to preserve key/value pairs between runs.
71 72 73 |
# File 'lib/foreman_maintain/runner/execution.rb', line 71 def storage @storage || ForemanMaintain.storage(:default) end |
#success? ⇒ Boolean
42 43 44 |
# File 'lib/foreman_maintain/runner/execution.rb', line 42 def success? [:success, :already_run, :skipped].include?(@status) end |
#update(line) ⇒ Object
97 98 99 |
# File 'lib/foreman_maintain/runner/execution.rb', line 97 def update(line) @reporter.on_execution_update(self, line) end |
#warning? ⇒ Boolean
62 63 64 |
# File 'lib/foreman_maintain/runner/execution.rb', line 62 def warning? @status == :warning end |
#whitelisted? ⇒ Boolean
38 39 40 |
# File 'lib/foreman_maintain/runner/execution.rb', line 38 def whitelisted? @whitelisted end |