Class: Katello::Events::GenerateHostApplicability

Inherits:
Object
  • Object
show all
Defined in:
app/models/katello/events/generate_host_applicability.rb

Constant Summary collapse

EVENT_TYPE =
'generate_host_applicability'.freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object_id) ⇒ GenerateHostApplicability

Returns a new instance of GenerateHostApplicability.



10
11
# File 'app/models/katello/events/generate_host_applicability.rb', line 10

def initialize(object_id)
end

Class Method Details

.retry_secondsObject



6
7
8
# File 'app/models/katello/events/generate_host_applicability.rb', line 6

def self.retry_seconds
  180
end

Instance Method Details

#runObject



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/models/katello/events/generate_host_applicability.rb', line 13

def run
  return if ::Katello::ApplicableHostQueue.queue_depth == 0

  begin
    while ::Katello::ApplicableHostQueue.queue_depth != 0
      hosts = ::Katello::ApplicableHostQueue.pop_hosts
      ForemanTasks.async_task(::Actions::Katello::Applicability::Hosts::BulkGenerate, host_ids: hosts.map(&:host_id))
    end
  rescue => e
    self.retry = true if e.is_a?(ForemanTasks::Lock::LockConflict)
    raise e
  end
end