Sha256: 0b72f2712aee5fae725009d27f89f996c684cafceed6d7d1d622e5e889835278

Contents?: true

Size: 1.19 KB

Versions: 45

Compression:

Stored size: 1.19 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 %s task") % candlepin
          else
            _("checking %s task status") % candlepin
          end
        when :suspended
          _("waiting for %s to finish the task") % candlepin
        else
          super
        end
      end

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

      def candlepin
        _("Candlepin")
      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

45 entries across 45 versions & 1 rubygems

Version Path
katello-4.14.2 app/lib/actions/candlepin/abstract_async_task.rb
katello-4.15.0 app/lib/actions/candlepin/abstract_async_task.rb
katello-4.15.0.rc2 app/lib/actions/candlepin/abstract_async_task.rb
katello-4.15.0.rc1 app/lib/actions/candlepin/abstract_async_task.rb
katello-4.14.1 app/lib/actions/candlepin/abstract_async_task.rb
katello-4.14.0 app/lib/actions/candlepin/abstract_async_task.rb
katello-4.14.0.rc3 app/lib/actions/candlepin/abstract_async_task.rb
katello-4.14.0.rc2 app/lib/actions/candlepin/abstract_async_task.rb
katello-4.14.0.rc1.1 app/lib/actions/candlepin/abstract_async_task.rb
katello-4.14.0.rc1 app/lib/actions/candlepin/abstract_async_task.rb
katello-4.13.1 app/lib/actions/candlepin/abstract_async_task.rb
katello-4.13.0 app/lib/actions/candlepin/abstract_async_task.rb
katello-4.12.1 app/lib/actions/candlepin/abstract_async_task.rb
katello-4.13.0.rc1 app/lib/actions/candlepin/abstract_async_task.rb
katello-4.12.0 app/lib/actions/candlepin/abstract_async_task.rb
katello-4.12.0.rc3 app/lib/actions/candlepin/abstract_async_task.rb
katello-4.12.0.rc2 app/lib/actions/candlepin/abstract_async_task.rb
katello-4.12.0.rc1 app/lib/actions/candlepin/abstract_async_task.rb
katello-4.11.1 app/lib/actions/candlepin/abstract_async_task.rb
katello-4.11.0 app/lib/actions/candlepin/abstract_async_task.rb