Class: MCollective::Util::Playbook::TaskResult
- Inherits:
-
Object
- Object
- MCollective::Util::Playbook::TaskResult
- Defined in:
- lib/mcollective/util/playbook/task_result.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#description ⇒ Object
Returns the value of attribute description.
-
#end_time ⇒ Object
Returns the value of attribute end_time.
-
#msg ⇒ Object
Returns the value of attribute msg.
-
#ran ⇒ Object
Returns the value of attribute ran.
-
#set ⇒ Object
Returns the value of attribute set.
-
#start_time ⇒ Object
Returns the value of attribute start_time.
-
#success ⇒ Object
Returns the value of attribute success.
-
#task ⇒ Object
Returns the value of attribute task.
Instance Method Summary collapse
-
#initialize(task) ⇒ TaskResult
constructor
A new instance of TaskResult.
- #run_time ⇒ Object
- #success? ⇒ Boolean
- #task_type ⇒ Object
- #timed_run(set) ⇒ Object
Constructor Details
#initialize(task) ⇒ TaskResult
Returns a new instance of TaskResult.
7 8 9 10 11 12 13 |
# File 'lib/mcollective/util/playbook/task_result.rb', line 7 def initialize(task) @start_time = Time.now @end_time = @start_time @ran = false @task = task @description = task[:description] end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
5 6 7 |
# File 'lib/mcollective/util/playbook/task_result.rb', line 5 def data @data end |
#description ⇒ Object
Returns the value of attribute description.
5 6 7 |
# File 'lib/mcollective/util/playbook/task_result.rb', line 5 def description @description end |
#end_time ⇒ Object
Returns the value of attribute end_time.
5 6 7 |
# File 'lib/mcollective/util/playbook/task_result.rb', line 5 def end_time @end_time end |
#msg ⇒ Object
Returns the value of attribute msg.
5 6 7 |
# File 'lib/mcollective/util/playbook/task_result.rb', line 5 def msg @msg end |
#ran ⇒ Object
Returns the value of attribute ran.
5 6 7 |
# File 'lib/mcollective/util/playbook/task_result.rb', line 5 def ran @ran end |
#set ⇒ Object
Returns the value of attribute set.
5 6 7 |
# File 'lib/mcollective/util/playbook/task_result.rb', line 5 def set @set end |
#start_time ⇒ Object
Returns the value of attribute start_time.
5 6 7 |
# File 'lib/mcollective/util/playbook/task_result.rb', line 5 def start_time @start_time end |
#success ⇒ Object
Returns the value of attribute success.
5 6 7 |
# File 'lib/mcollective/util/playbook/task_result.rb', line 5 def success @success end |
#task ⇒ Object
Returns the value of attribute task.
5 6 7 |
# File 'lib/mcollective/util/playbook/task_result.rb', line 5 def task @task end |
Instance Method Details
#run_time ⇒ Object
19 20 21 |
# File 'lib/mcollective/util/playbook/task_result.rb', line 19 def run_time @end_time - @start_time end |
#success? ⇒ Boolean
23 24 25 |
# File 'lib/mcollective/util/playbook/task_result.rb', line 23 def success? !!success end |
#task_type ⇒ Object
15 16 17 |
# File 'lib/mcollective/util/playbook/task_result.rb', line 15 def task_type @task[:type] end |
#timed_run(set) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/mcollective/util/playbook/task_result.rb', line 27 def timed_run(set) @start_time = Time.now @set = set begin @success, @msg, @data = task[:runner].run if !@success && task[:properties]["fail_ok"] && task[:properties]["tries"] == 1 Log.warn("Task failed but fail_ok is true, treating as success") @success = true end rescue @success = false @data = [$!] @msg = "Running task %s failed unexpectedly: %s: %s" % [task.to_s, $!.class, $!.to_s] Log.warn(@msg) Log.debug($!.backtrace.join("\n\t")) end @end_time = Time.now @ran = true self end |