Sha256: ee2ed9904423c4023098ec1e51744df1ac38480df3b011829a432e3e3eb44020

Contents?: true

Size: 1.27 KB

Versions: 20

Compression:

Stored size: 1.27 KB

Contents

module MCollective
  module Util
    class Playbook
      class TaskResult
        attr_accessor :success, :msg, :data, :ran, :task, :set, :start_time, :end_time, :description

        def initialize(task)
          @start_time = Time.now
          @end_time = @start_time
          @ran = false
          @task = task
          @description = task[:description]
        end

        def task_type
          @task[:type]
        end

        def run_time
          @end_time - @start_time
        end

        def success?
          !!success
        end

        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
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
choria-mcorpc-support-2.26.5 lib/mcollective/util/playbook/task_result.rb
choria-mcorpc-support-2.26.4 lib/mcollective/util/playbook/task_result.rb
choria-mcorpc-support-2.26.3 lib/mcollective/util/playbook/task_result.rb
choria-mcorpc-support-2.26.2 lib/mcollective/util/playbook/task_result.rb
choria-mcorpc-support-2.26.1 lib/mcollective/util/playbook/task_result.rb
choria-mcorpc-support-2.26.0 lib/mcollective/util/playbook/task_result.rb
choria-mcorpc-support-2.25.3 lib/mcollective/util/playbook/task_result.rb
choria-mcorpc-support-2.25.2 lib/mcollective/util/playbook/task_result.rb
choria-mcorpc-support-2.25.1 lib/mcollective/util/playbook/task_result.rb
choria-mcorpc-support-2.25.0 lib/mcollective/util/playbook/task_result.rb
choria-mcorpc-support-2.24.4 lib/mcollective/util/playbook/task_result.rb
choria-mcorpc-support-2.24.3 lib/mcollective/util/playbook/task_result.rb
choria-mcorpc-support-2.24.2 lib/mcollective/util/playbook/task_result.rb
choria-mcorpc-support-2.24.1 lib/mcollective/util/playbook/task_result.rb
choria-mcorpc-support-2.24.0 lib/mcollective/util/playbook/task_result.rb
choria-mcorpc-support-2.23.3 lib/mcollective/util/playbook/task_result.rb
choria-mcorpc-support-2.23.2 lib/mcollective/util/playbook/task_result.rb
choria-mcorpc-support-2.23.1 lib/mcollective/util/playbook/task_result.rb
choria-mcorpc-support-2.23.0 lib/mcollective/util/playbook/task_result.rb
choria-mcorpc-support-2.23.0.pre lib/mcollective/util/playbook/task_result.rb