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

#humanized_nameObject



28
29
30
31
32
33
34
# File 'app/lib/actions/katello/host/destroy.rb', line 28

def humanized_name
  if input.try(:[], :hostname)
    _("Destroy Content Host %s") % input[:hostname]
  else
    _("Destroy Content Host")
  end
end

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



11
12
13
14
15
16
17
18
# File 'app/lib/actions/katello/host/destroy.rb', line 11

def plan(host, options = {})
  action_subject(host)
  # normalize options before passing through to run phase
  organization_destroy = options.fetch(:organization_destroy, false)
  unregistering = options.fetch(:unregistering, false)
  plan_self(:hostname => host.name, :host_id => host.id, :unregistering => unregistering,
            :organization_destroy => organization_destroy)
end

#queueObject



7
8
9
# File 'app/lib/actions/katello/host/destroy.rb', line 7

def queue
  ::Katello::HOST_TASKS_QUEUE
end

#runObject



20
21
22
23
24
25
26
# File 'app/lib/actions/katello/host/destroy.rb', line 20

def run
  host = ::Host.find(input[:host_id])
  ::Katello::RegistrationManager.unregister_host(host, :unregistering => input[:unregistering],
                                                 :organization_destroy => input[:organization_destroy])
rescue ActiveRecord::RecordNotFound
  Rails.logger.warn("Attempted to delete host %s in action, but host is already gone. Continuing." % input[:host_id])
end