Class: Actions::Katello::Host::RemoveSubscriptions
- Inherits:
-
EntryAction
- Object
- EntryAction
- Actions::Katello::Host::RemoveSubscriptions
- Defined in:
- app/lib/actions/katello/host/remove_subscriptions.rb
Instance Method Summary collapse
- #finalize ⇒ Object
- #humanized_name ⇒ Object
- #plan(host, pools_with_quantities_params) ⇒ Object
- #rescue_strategy ⇒ Object
- #resource_locks ⇒ Object
Instance Method Details
#finalize ⇒ Object
26 27 28 29 30 |
# File 'app/lib/actions/katello/host/remove_subscriptions.rb', line 26 def finalize ::Katello::Pool.where(:cp_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
36 37 38 39 40 41 42 |
# File 'app/lib/actions/katello/host/remove_subscriptions.rb', line 36 def humanized_name if input.try(:[], :host_name) _('Remove subscriptions from %s') % (input[:host_name] || _('Unknown')) else _('Remove subscriptions') end end |
#plan(host, pools_with_quantities_params) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/lib/actions/katello/host/remove_subscriptions.rb', line 5 def plan(host, pools_with_quantities_params) action_subject(host) pool_ids = [] sequence do pools_with_quantities = pools_with_quantities_params.map do |pool_with_quantity| ::Katello::PoolWithQuantities.fetch(pool_with_quantity) end cp_consumer = host.subscription_facet.candlepin_consumer entitlements = pools_with_quantities.map do |pool_with_quantities| cp_consumer.filter_entitlements(pool_with_quantities.pool.cp_id) end entitlements.flatten.each do |entitlement| pool_ids << entitlement['pool']['id'] plan_action(::Actions::Candlepin::Consumer::RemoveSubscription, :uuid => host.subscription_facet.uuid, :entitlement_id => entitlement['id'], :pool_id => entitlement['pool']['id']) end end plan_self(:host_id => host.id, :host_name => host.name, :pool_ids => pool_ids) end |
#rescue_strategy ⇒ Object
32 33 34 |
# File 'app/lib/actions/katello/host/remove_subscriptions.rb', line 32 def rescue_strategy Dynflow::Action::Rescue::Skip end |
#resource_locks ⇒ Object
44 45 46 |
# File 'app/lib/actions/katello/host/remove_subscriptions.rb', line 44 def resource_locks :link end |