Class: ManageIQ::Floe::Workflow::States::Task
- Inherits:
-
ManageIQ::Floe::Workflow::State
- Object
- ManageIQ::Floe::Workflow::State
- ManageIQ::Floe::Workflow::States::Task
- Defined in:
- lib/manageiq/floe/workflow/states/task.rb
Instance Attribute Summary collapse
-
#catch ⇒ Object
readonly
Returns the value of attribute catch.
-
#credentials ⇒ Object
readonly
Returns the value of attribute credentials.
-
#end ⇒ Object
readonly
Returns the value of attribute end.
-
#heartbeat_seconds ⇒ Object
readonly
Returns the value of attribute heartbeat_seconds.
-
#input_path ⇒ Object
readonly
Returns the value of attribute input_path.
-
#next ⇒ Object
readonly
Returns the value of attribute next.
-
#output_path ⇒ Object
readonly
Returns the value of attribute output_path.
-
#parameters ⇒ Object
readonly
Returns the value of attribute parameters.
-
#resource ⇒ Object
readonly
Returns the value of attribute resource.
-
#result_path ⇒ Object
readonly
Returns the value of attribute result_path.
-
#result_selector ⇒ Object
readonly
Returns the value of attribute result_selector.
-
#retry ⇒ Object
readonly
Returns the value of attribute retry.
-
#timeout_seconds ⇒ Object
readonly
Returns the value of attribute timeout_seconds.
Attributes inherited from ManageIQ::Floe::Workflow::State
#comment, #name, #payload, #type, #workflow
Instance Method Summary collapse
-
#initialize(workflow, name, payload) ⇒ Task
constructor
A new instance of Task.
- #run! ⇒ Object
Methods inherited from ManageIQ::Floe::Workflow::State
build!, #context, #end?, #to_dot, #to_dot_transitions
Methods included from Logging
Constructor Details
#initialize(workflow, name, payload) ⇒ Task
Returns a new instance of Task.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/manageiq/floe/workflow/states/task.rb', line 12 def initialize(workflow, name, payload) super @heartbeat_seconds = payload["HeartbeatSeconds"] @next = payload["Next"] @resource = payload["Resource"] @timeout_seconds = payload["TimeoutSeconds"] @retry = payload["Retry"].to_a.map { |retrier| Retrier.new(retrier) } @catch = payload["Catch"].to_a.map { |catcher| Catcher.new(catcher) } @input_path = Path.new(payload.fetch("InputPath", "$")) @output_path = Path.new(payload.fetch("OutputPath", "$")) @result_path = ReferencePath.new(payload.fetch("ResultPath", "$")) @parameters = PayloadTemplate.new(payload["Parameters"]) if payload["Parameters"] @result_selector = PayloadTemplate.new(payload["ResultSelector"]) if payload["ResultSelector"] @credentials = PayloadTemplate.new(payload["Credentials"]) if payload["Credentials"] end |
Instance Attribute Details
#catch ⇒ Object (readonly)
Returns the value of attribute catch.
8 9 10 |
# File 'lib/manageiq/floe/workflow/states/task.rb', line 8 def catch @catch end |
#credentials ⇒ Object (readonly)
Returns the value of attribute credentials.
8 9 10 |
# File 'lib/manageiq/floe/workflow/states/task.rb', line 8 def credentials @credentials end |
#end ⇒ Object (readonly)
Returns the value of attribute end.
8 9 10 |
# File 'lib/manageiq/floe/workflow/states/task.rb', line 8 def end @end end |
#heartbeat_seconds ⇒ Object (readonly)
Returns the value of attribute heartbeat_seconds.
8 9 10 |
# File 'lib/manageiq/floe/workflow/states/task.rb', line 8 def heartbeat_seconds @heartbeat_seconds end |
#input_path ⇒ Object (readonly)
Returns the value of attribute input_path.
8 9 10 |
# File 'lib/manageiq/floe/workflow/states/task.rb', line 8 def input_path @input_path end |
#next ⇒ Object (readonly)
Returns the value of attribute next.
8 9 10 |
# File 'lib/manageiq/floe/workflow/states/task.rb', line 8 def next @next end |
#output_path ⇒ Object (readonly)
Returns the value of attribute output_path.
8 9 10 |
# File 'lib/manageiq/floe/workflow/states/task.rb', line 8 def output_path @output_path end |
#parameters ⇒ Object (readonly)
Returns the value of attribute parameters.
8 9 10 |
# File 'lib/manageiq/floe/workflow/states/task.rb', line 8 def parameters @parameters end |
#resource ⇒ Object (readonly)
Returns the value of attribute resource.
8 9 10 |
# File 'lib/manageiq/floe/workflow/states/task.rb', line 8 def resource @resource end |
#result_path ⇒ Object (readonly)
Returns the value of attribute result_path.
8 9 10 |
# File 'lib/manageiq/floe/workflow/states/task.rb', line 8 def result_path @result_path end |
#result_selector ⇒ Object (readonly)
Returns the value of attribute result_selector.
8 9 10 |
# File 'lib/manageiq/floe/workflow/states/task.rb', line 8 def result_selector @result_selector end |
#retry ⇒ Object (readonly)
Returns the value of attribute retry.
8 9 10 |
# File 'lib/manageiq/floe/workflow/states/task.rb', line 8 def retry @retry end |
#timeout_seconds ⇒ Object (readonly)
Returns the value of attribute timeout_seconds.
8 9 10 |
# File 'lib/manageiq/floe/workflow/states/task.rb', line 8 def timeout_seconds @timeout_seconds end |
Instance Method Details
#run! ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/manageiq/floe/workflow/states/task.rb', line 29 def run!(*) super do |input| input = parameters.value(context, input) if parameters runner = ManageIQ::Floe::Workflow::Runner.for_resource(resource) _exit_status, results = runner.run!(resource, input, credentials&.value({}, workflow.credentials)) output = input process_output!(output, results) rescue => err retrier = self.retry.detect { |r| (r.error_equals & [err.to_s, "States.ALL"]).any? } retry if retry!(retrier) catcher = self.catch.detect { |c| (c.error_equals & [err.to_s, "States.ALL"]).any? } raise if catcher.nil? [output, workflow.states_by_name[catcher.next]] end end |