Sha256: 95caae124d39a8347a97d696404590c906a3f61c6f08a67d462be0d5a68c6f2b

Contents?: true

Size: 1.94 KB

Versions: 71

Compression:

Stored size: 1.94 KB

Contents

module Katello
  module Agent
    class Dispatcher
      @supported_messages = {}

      def self.register_message(name, klass)
        @supported_messages[name] = klass
      end

      register_message(:install_package, Katello::Agent::InstallPackageMessage)
      register_message(:remove_package, Katello::Agent::RemovePackageMessage)
      register_message(:update_package, Katello::Agent::UpdatePackageMessage)
      register_message(:install_errata, Katello::Agent::InstallErrataMessage)
      register_message(:install_package_group, Katello::Agent::InstallPackageGroupMessage)
      register_message(:remove_package_group, Katello::Agent::RemovePackageGroupMessage)

      def self.dispatch(message_type, histories, args)
        message_class = @supported_messages[message_type]
        fail("Unsupported message type: #{message_type}") unless message_class

        messages = histories.map do |history|
          message = message_class.new(**args.merge(consumer_id: history.host.subscription_facet.uuid))
          message.dispatch_history_id = history.id
          message.recipient_address = settings[:client_queue_format] % history.host.subscription_facet.uuid
          message.reply_to = settings[:event_queue_name]
          message
        end

        connection = Connection.new
        connection.send_messages(messages)

        histories
      end

      def self.create_histories(host_ids:)
        histories = host_ids.map do |id|
          Katello::Agent::DispatchHistory.new(host_id: id)
        end

        Katello::Agent::DispatchHistory.import(histories)

        histories
      end

      def self.delete_client_queue(queue_name:)
        connection = Connection.new
        connection.delete_client_queue(queue_name)
      end

      def self.host_queue_name(host)
        uuid = host.content_facet.uuid
        settings[:client_queue_format] % uuid
      end

      def self.settings
        SETTINGS[:katello][:agent]
      end
    end
  end
end

Version data entries

71 entries across 71 versions & 1 rubygems

Version Path
katello-4.9.2 app/services/katello/agent/dispatcher.rb
katello-4.8.4 app/services/katello/agent/dispatcher.rb
katello-4.9.1 app/services/katello/agent/dispatcher.rb
katello-4.8.3 app/services/katello/agent/dispatcher.rb
katello-4.9.0 app/services/katello/agent/dispatcher.rb
katello-4.7.6 app/services/katello/agent/dispatcher.rb
katello-4.8.2 app/services/katello/agent/dispatcher.rb
katello-4.9.0.rc2 app/services/katello/agent/dispatcher.rb
katello-4.9.0.rc1 app/services/katello/agent/dispatcher.rb
katello-4.8.1 app/services/katello/agent/dispatcher.rb
katello-4.7.5 app/services/katello/agent/dispatcher.rb
katello-4.8.0 app/services/katello/agent/dispatcher.rb
katello-4.8.0.rc2 app/services/katello/agent/dispatcher.rb
katello-4.7.4 app/services/katello/agent/dispatcher.rb
katello-4.8.0.rc1 app/services/katello/agent/dispatcher.rb
katello-4.7.3 app/services/katello/agent/dispatcher.rb
katello-4.7.2 app/services/katello/agent/dispatcher.rb
katello-4.7.1 app/services/katello/agent/dispatcher.rb
katello-4.6.2.1 app/services/katello/agent/dispatcher.rb
katello-4.6.2 app/services/katello/agent/dispatcher.rb