Sha256: c2b7401884afb52c0c79f62d3434bb845be42e645e6dee1e513e4d2cb2efcfa4

Contents?: true

Size: 1.3 KB

Versions: 13

Compression:

Stored size: 1.3 KB

Contents

module Actions
  module Katello
    module Host
      class AttachSubscriptions < Actions::EntryAction
        middleware.use Actions::Middleware::KeepCurrentUser

        def plan(host, pools_with_quantities)
          action_subject(host)

          sequence do
            pool_ids = []
            pools_with_quantities.each do |pool_with_quantities|
              pool_ids << pool_with_quantities.pool.id
              pool_with_quantities.quantities.each do |quantity|
                plan_action(::Actions::Candlepin::Consumer::AttachSubscription, :uuid => host.subscription_facet.uuid,
                            :pool_uuid => pool_with_quantities.pool.cp_id, :quantity => quantity)
              end
            end

            plan_self(:pool_ids => pool_ids, :host_name => host.name)
          end
        end

        def finalize
          ::Katello::Pool.where(:id => input[:pool_ids]).each(&:import_data)
        end

        def rescue_strategy
          Dynflow::Action::Rescue::Skip
        end

        def humanized_name
          if input.try(:[], :host_name)
            _('Attach subscriptions to %s') % (input[:host_name] || _('Unknown'))
          else
            _('Attach subscriptions')
          end
        end

        def resource_locks
          :link
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
katello-3.1.0.1 app/lib/actions/katello/host/attach_subscriptions.rb
katello-3.1.0 app/lib/actions/katello/host/attach_subscriptions.rb
katello-3.1.0.rc2.1 app/lib/actions/katello/host/attach_subscriptions.rb
katello-3.0.2 app/lib/actions/katello/host/attach_subscriptions.rb
katello-3.1.0.rc1 app/lib/actions/katello/host/attach_subscriptions.rb
katello-3.0.1 app/lib/actions/katello/host/attach_subscriptions.rb
katello-3.0.0 app/lib/actions/katello/host/attach_subscriptions.rb
katello-3.0.0.rc7 app/lib/actions/katello/host/attach_subscriptions.rb
katello-3.0.0.rc5 app/lib/actions/katello/host/attach_subscriptions.rb
katello-3.0.0.rc4 app/lib/actions/katello/host/attach_subscriptions.rb
katello-3.0.0.rc3 app/lib/actions/katello/host/attach_subscriptions.rb
katello-3.0.0.rc2 app/lib/actions/katello/host/attach_subscriptions.rb
katello-3.0.0.rc1 app/lib/actions/katello/host/attach_subscriptions.rb