Sha256: 5ebb6a2ff39fe186e6b5dc7e4f3c01d4ff2c19997ad4440b13fe9d9ff8c7ba8b

Contents?: true

Size: 1.13 KB

Versions: 27

Compression:

Stored size: 1.13 KB

Contents

module Actions
  module Candlepin
    class AbstractAsyncTask < Candlepin::Abstract
      include Actions::Base::Polling

      def run(event = nil)
        # do nothing when the action is being skipped
        unless event == Dynflow::Action::Skip
          super
        end
      end

      def humanized_state
        case state
        when :running
          if self.external_task.nil?
            _("initiating Candlepin task")
          else
            _("checking Candlepin task status")
          end
        when :suspended
          _("waiting for Candlepin to finish the task")
        else
          super
        end
      end

      def done?
        check_for_errors!(external_task)
        !::Katello::Resources::Candlepin::Job.not_finished?(external_task)
      end

      private

      def job_poll_params
        {}
      end

      def poll_external_task
        ::Katello::Resources::Candlepin::Job.get(external_task[:id], job_poll_params)
      end

      def check_for_errors!(task)
        if task[:state] == 'FAILED'
          fail ::Katello::Errors::CandlepinError, task[:resultData]
        end
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
katello-4.6.2.1 app/lib/actions/candlepin/abstract_async_task.rb
katello-4.6.2 app/lib/actions/candlepin/abstract_async_task.rb
katello-4.6.1 app/lib/actions/candlepin/abstract_async_task.rb
katello-4.7.0.rc1 app/lib/actions/candlepin/abstract_async_task.rb
katello-4.4.2.2 app/lib/actions/candlepin/abstract_async_task.rb
katello-4.4.2.1 app/lib/actions/candlepin/abstract_async_task.rb
katello-4.4.2 app/lib/actions/candlepin/abstract_async_task.rb
katello-4.5.1 app/lib/actions/candlepin/abstract_async_task.rb
katello-4.6.0 app/lib/actions/candlepin/abstract_async_task.rb
katello-4.6.0.rc2 app/lib/actions/candlepin/abstract_async_task.rb
katello-4.6.0.rc1 app/lib/actions/candlepin/abstract_async_task.rb
katello-4.5.0 app/lib/actions/candlepin/abstract_async_task.rb
katello-4.5.0.rc2 app/lib/actions/candlepin/abstract_async_task.rb
katello-4.4.1 app/lib/actions/candlepin/abstract_async_task.rb
katello-4.5.0.rc1 app/lib/actions/candlepin/abstract_async_task.rb
katello-4.4.0.2 app/lib/actions/candlepin/abstract_async_task.rb
katello-4.4.0.1 app/lib/actions/candlepin/abstract_async_task.rb
katello-4.3.1 app/lib/actions/candlepin/abstract_async_task.rb
katello-4.4.0 app/lib/actions/candlepin/abstract_async_task.rb
katello-4.4.0.rc2 app/lib/actions/candlepin/abstract_async_task.rb