Class: Katello::Pulp::PulpContentUnit

Inherits:
Object
  • Object
show all
Defined in:
app/services/katello/pulp/pulp_content_unit.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uuid) ⇒ PulpContentUnit

Returns a new instance of PulpContentUnit.



15
16
17
# File 'app/services/katello/pulp/pulp_content_unit.rb', line 15

def initialize(uuid)
  self.uuid = uuid
end

Instance Attribute Details

#uuidObject

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



13
14
15
# File 'app/services/katello/pulp/pulp_content_unit.rb', line 13

def uuid
  @uuid
end

Class Method Details

.fetch(offset, page_size, uuids = nil) ⇒ Object



44
45
46
47
48
49
50
# File 'app/services/katello/pulp/pulp_content_unit.rb', line 44

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

.fetch_allObject



27
28
29
30
31
32
33
34
# File 'app/services/katello/pulp/pulp_content_unit.rb', line 27

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

.fetch_by_uuids(uuids) ⇒ Object



36
37
38
39
40
41
42
# File 'app/services/katello/pulp/pulp_content_unit.rb', line 36

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

.pulp_data(uuid) ⇒ Object



19
20
21
# File 'app/services/katello/pulp/pulp_content_unit.rb', line 19

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

.unit_handlerObject



23
24
25
# File 'app/services/katello/pulp/pulp_content_unit.rb', line 23

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

Instance Method Details

#backend_dataObject



52
53
54
# File 'app/services/katello/pulp/pulp_content_unit.rb', line 52

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