Class: Actions::Katello::Host::Destroy

Inherits:
EntryAction
  • Object
show all
Defined in:
app/lib/actions/katello/host/destroy.rb

Instance Method Summary collapse

Instance Method Details

#finalizeObject



45
46
47
48
49
50
# File 'app/lib/actions/katello/host/destroy.rb', line 45

def finalize
  input[:pool_ids].each do |pool_id|
    pool = ::Katello::Pool.where(:cp_id => pool_id).first
    pool.import_data if pool
  end
end

#humanized_nameObject



52
53
54
# File 'app/lib/actions/katello/host/destroy.rb', line 52

def humanized_name
  _("Destroy Content Host")
end

#plan(host, options = {}) ⇒ Object



7
8
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
34
35
36
37
38
39
40
41
42
43
# File 'app/lib/actions/katello/host/destroy.rb', line 7

def plan(host, options = {})
  skip_candlepin = options.fetch(:skip_candlepin, false)
  unregistering = options.fetch(:unregistering, false)

  action_subject(host)

  concurrence do
    if !skip_candlepin && host.subscription_facet.try(:uuid)
      plan_action(Candlepin::Consumer::Destroy, uuid: host.subscription_facet.uuid)
    end
    plan_action(Pulp::Consumer::Destroy, uuid: host.content_facet.uuid) if host.content_facet.try(:uuid)
  end

  if host.content_host
    pool_ids = host.content_host.pools.map { |p| p["id"] }
    plan_self(:pool_ids => pool_ids)
    host.content_host.destroy!
  end

  host.subscription_facet.try(:destroy!)

  if unregistering
    if host.content_facet
      host.content_facet.uuid = nil
      host.content_facet.save!
    end

    host.get_status(::Katello::ErrataStatus).destroy
    host.get_status(::Katello::SubscriptionStatus).destroy
    host.installed_packages.destroy_all
  else
    host.content_facet.try(:destroy!)
    unless host.destroy
      fail host.errors.full_messages.join('; ')
    end
  end
end