Sha256: b83c26d442e523772ed30b2c1b62999c0ee5612f3df6be73333cdea0e013c7ae

Contents?: true

Size: 1.69 KB

Versions: 29

Compression:

Stored size: 1.69 KB

Contents

require 'set'

module Katello
  module Pulp
    class PulpContentUnit
      # Any class that extends this class should define:
      # Class::CONTENT_TYPE

      # Any class that extends this class can define:
      # Class.unit_handler (optional)
      # Class::PULP_INDEXED_FIELDS (optional)

      attr_accessor :uuid

      def initialize(uuid)
        self.uuid = uuid
      end

      def self.pulp_data(uuid)
        unit_handler.find_by_unit_id(uuid)
      end

      def self.unit_handler
        Katello.pulp_server.extensions.send(self.name.demodulize.underscore)
      end

      def self.fetch_all
        all_items = items = fetch(0, SETTINGS[:katello][:pulp][:bulk_load_size])
        until items.empty? #we can't know how many there are, so we have to keep looping until we get nothing
          items = fetch(all_items.length, SETTINGS[:katello][:pulp][:bulk_load_size])
          all_items.concat(items)
        end
        all_items
      end

      def self.fetch_by_uuids(uuids)
        items = []
        uuids.each_slice(SETTINGS[:katello][:pulp][:bulk_load_size]) do |sub_list|
          items.concat(fetch(0, sub_list.length, sub_list))
        end
        items
      end

      def self.fetch(offset, page_size, uuids = nil)
        fields = self.const_get(:PULP_INDEXED_FIELDS) if self.constants.include?(:PULP_INDEXED_FIELDS)
        criteria = {:limit => page_size, :skip => offset}
        criteria[:fields] = fields if fields
        criteria[:filters] = {'_id' => {'$in' => uuids}} if uuids
        Katello.pulp_server.resources.unit.search(self::CONTENT_TYPE, criteria, :include_repos => true)
      end

      def backend_data
        self.class.pulp_data(self.uuid)
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
katello-3.2.1.1 app/services/katello/pulp/pulp_content_unit.rb
katello-3.2.1 app/services/katello/pulp/pulp_content_unit.rb
katello-3.2.0 app/services/katello/pulp/pulp_content_unit.rb
katello-3.2.0.rc3 app/services/katello/pulp/pulp_content_unit.rb
katello-3.2.0.rc2 app/services/katello/pulp/pulp_content_unit.rb
katello-3.2.0.rc1.1 app/services/katello/pulp/pulp_content_unit.rb
katello-3.2.0.rc1 app/services/katello/pulp/pulp_content_unit.rb
katello-3.1.0.1 app/services/katello/pulp/pulp_content_unit.rb
katello-3.1.0 app/services/katello/pulp/pulp_content_unit.rb
katello-3.1.0.rc2.1 app/services/katello/pulp/pulp_content_unit.rb
katello-3.0.2 app/services/katello/pulp/pulp_content_unit.rb
katello-2.4.5 app/services/katello/pulp/pulp_content_unit.rb
katello-3.1.0.rc1 app/services/katello/pulp/pulp_content_unit.rb
katello-3.0.1 app/services/katello/pulp/pulp_content_unit.rb
katello-2.4.4 app/services/katello/pulp/pulp_content_unit.rb
katello-3.0.0 app/services/katello/pulp/pulp_content_unit.rb
katello-2.4.3 app/services/katello/pulp/pulp_content_unit.rb
katello-3.0.0.rc7 app/services/katello/pulp/pulp_content_unit.rb
katello-3.0.0.rc5 app/services/katello/pulp/pulp_content_unit.rb
katello-2.4.2 app/services/katello/pulp/pulp_content_unit.rb