Class: Actions::Katello::Host::Package::Remove

Inherits:
AgentAction
  • Object
show all
Defined in:
app/lib/actions/katello/host/package/remove.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from AgentAction

#accept_timeout, #dispatch_history, #dispatch_message, #fail_on_errors, #finish_timeout, #plan, #presenter, #process_timeout, #rescue_strategy, #run

Methods included from Helpers::Presenter

#presenter

Class Method Details

.agent_messageObject



6
7
8
# File 'app/lib/actions/katello/host/package/remove.rb', line 6

def self.agent_message
  :remove_package
end

Instance Method Details

#agent_action_typeObject



10
11
12
# File 'app/lib/actions/katello/host/package/remove.rb', line 10

def agent_action_type
  :content_uninstall
end

#finalizeObject



40
41
42
43
# File 'app/lib/actions/katello/host/package/remove.rb', line 40

def finalize
  host = ::Host.find_by(:id => input[:host_id])
  host.update(audit_comment: (_("Removal of package(s) requested: %{packages}") % {packages: input[:content].join(", ")}).truncate(255))
end

#humanized_inputObject



22
23
24
# File 'app/lib/actions/katello/host/package/remove.rb', line 22

def humanized_input
  [humanized_package_names.join(', ')] + super
end

#humanized_nameObject



14
15
16
17
18
19
20
# File 'app/lib/actions/katello/host/package/remove.rb', line 14

def humanized_name
  if input.try(:[], :hostname)
    _("Remove package for %s") % input[:hostname]
  else
    _("Remove package")
  end
end

#humanized_package_namesObject



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/lib/actions/katello/host/package/remove.rb', line 26

def humanized_package_names
  input[:content].inject([]) do |result, package|
    if package.is_a?(Hash)
      new_name = package.include?(:name) ? package[:name] : ""
      new_name += '-' + package[:version] if package.include?(:version)
      new_name += '.' + package[:release] if package.include?(:release)
      new_name += '.' + package[:arch] if package.include?(:arch)
      result << new_name
    else
      result << package
    end
  end
end