Sha256: 27021a6969da97a96f4f321094363dc99864b7a5bc291460d5397ff89e9ab917

Contents?: true

Size: 1.17 KB

Versions: 2

Compression:

Stored size: 1.17 KB

Contents

module Actions
  module Katello
    module Host
      class GenerateApplicability < Actions::Base
        def queue
          ::Katello::HOST_TASKS_QUEUE
        end

        def plan(hosts, use_queue = true)
          if SETTINGS[:katello][:katello_applicability]
            plan_action(::Actions::Katello::Applicability::Hosts::Generate, host_ids: hosts.pluck(:id))
          else
            uuids = hosts.map { |host| host.content_facet.try(:uuid) }.compact
            unless uuids.empty?
              plan_action(Pulp::Consumer::GenerateApplicability, :uuids => uuids)
              plan_self(:host_ids => hosts.map(&:id), :use_queue => use_queue)
            end
          end
        end

        def finalize
          unless SETTINGS[:katello][:katello_applicability]
            input[:host_ids].each do |host_id|
              if input[:use_queue]
                ::Katello::EventQueue.push_event(::Katello::Events::ImportHostApplicability::EVENT_TYPE, host_id)
              else
                host = ::Host.find(host_id)
                host.content_facet.try(:import_applicability, true) if host
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
katello-3.16.0.rc1.1 app/lib/actions/katello/host/generate_applicability.rb
katello-3.16.0.rc1 app/lib/actions/katello/host/generate_applicability.rb