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
|