Class: Actions::Pulp::Consumer::AbstractContentAction

Inherits:
AbstractAsyncTask show all
Includes:
Helpers::Presenter, ExpectOneTask
Defined in:
app/lib/actions/pulp/consumer/abstract_content_action.rb

Direct Known Subclasses

ContentInstall, ContentUninstall, ContentUpdate

Constant Summary

Constants inherited from AbstractAsyncTask

AbstractAsyncTask::FINISHED_STATES

Instance Method Summary collapse

Methods inherited from AbstractAsyncTask

#cancel, #cancel!, #done?, #external_task, #humanized_state, #rescue_external_task, #run

Methods inherited from Abstract

#pulp_extensions, #pulp_resources

Instance Method Details

#external_task=(external_task_data) ⇒ Object



8
9
10
11
12
13
14
# File 'app/lib/actions/pulp/consumer/abstract_content_action.rb', line 8

def external_task=(external_task_data)
  super(external_task_data)
  task_errors = find_errors(output[:pulp_tasks])
  if task_errors.any?
    fail ::Katello::Errors::PulpError, task_errors.join("\n")
  end
end

#find_errors(tasks) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/lib/actions/pulp/consumer/abstract_content_action.rb', line 33

def find_errors(tasks)
  messages = []
  tasks.each do |pulp_task|
    if pulp_task[:result] && pulp_task[:result][:details]
      pulp_task[:result][:details].each do |_content_type, result|
        unless result[:succeeded]
          messages << result[:details][:message]
        end
      end
    end
  end
  messages
end

#presenterObject



47
48
49
# File 'app/lib/actions/pulp/consumer/abstract_content_action.rb', line 47

def presenter
  Consumer::ContentPresenter.new(self)
end

#process_timeoutObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/lib/actions/pulp/consumer/abstract_content_action.rb', line 16

def process_timeout
  accept_timeout = Setting['content_action_accept_timeout']
  finish_timeout = Setting['content_action_finish_timeout']
  pulp_state = output[:pulp_tasks][0][:state]

  if pulp_state == 'waiting'
    cancel
    fail _("Host did not respond within %s seconds. The task has been cancelled. Is katello-agent installed and goferd running on the Host?") % accept_timeout
  elsif output[:client_accepted].nil?
    output[:client_accepted] = Time.now.to_s
    schedule_timeout(finish_timeout)
  elsif pulp_state == 'running'
    cancel
    fail _("Host did not finish content action in %s seconds.  The task has been cancelled.") % finish_timeout
  end
end

#rescue_strategyObject



51
52
53
# File 'app/lib/actions/pulp/consumer/abstract_content_action.rb', line 51

def rescue_strategy
  Dynflow::Action::Rescue::Skip
end