Class: Actions::Katello::Host::AttachSubscriptions
- Inherits:
-
EntryAction
- Object
- EntryAction
- Actions::Katello::Host::AttachSubscriptions
- Defined in:
- app/lib/actions/katello/host/attach_subscriptions.rb
Instance Method Summary collapse
- #finalize ⇒ Object
- #humanized_name ⇒ Object
- #plan(host, pools_with_quantities_params) ⇒ Object
- #queue ⇒ Object
- #rescue_strategy ⇒ Object
- #resource_locks ⇒ Object
Instance Method Details
#finalize ⇒ Object
35 36 37 38 39 |
# File 'app/lib/actions/katello/host/attach_subscriptions.rb', line 35 def finalize ::Katello::Pool.where(:id => input[:pool_ids]).map { |pool| pool.import_data(false) } host = ::Host.find_by(:id => input[:host_id]) host.subscription_facet.import_database_attributes end |
#humanized_name ⇒ Object
45 46 47 48 49 50 51 |
# File 'app/lib/actions/katello/host/attach_subscriptions.rb', line 45 def humanized_name if input.try(:[], :host_name) _('Attach subscriptions to %s') % (input[:host_name] || _('Unknown')) else _('Attach subscriptions') end end |
#plan(host, pools_with_quantities_params) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/lib/actions/katello/host/attach_subscriptions.rb', line 9 def plan(host, pools_with_quantities_params) action_subject(host) subscription_facet = host.subscription_facet fail _("Register host '%s' before attaching subscriptions") % host.name unless subscription_facet sequence do pool_ids = [] pools_with_quantities = pools_with_quantities_params.map do |pool_with_quantity| ::Katello::PoolWithQuantities.fetch(pool_with_quantity) end existing_pool_ids = subscription_facet.candlepin_consumer.pool_ids pools_with_quantities.each do |pool_with_quantities| unless existing_pool_ids.include?(pool_with_quantities.pool.cp_id.to_s) 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 end plan_self(:host_id => host.id, :pool_ids => pool_ids, :host_name => host.name) end end |
#queue ⇒ Object
5 6 7 |
# File 'app/lib/actions/katello/host/attach_subscriptions.rb', line 5 def queue ::Katello::HOST_TASKS_QUEUE end |
#rescue_strategy ⇒ Object
41 42 43 |
# File 'app/lib/actions/katello/host/attach_subscriptions.rb', line 41 def rescue_strategy Dynflow::Action::Rescue::Skip end |
#resource_locks ⇒ Object
53 54 55 |
# File 'app/lib/actions/katello/host/attach_subscriptions.rb', line 53 def resource_locks :link end |