Class: Katello::PulpSyncProgress

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(progress_attrs = {}) ⇒ PulpSyncProgress

Returns a new instance of PulpSyncProgress.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'app/models/katello/pulp_sync_status.rb', line 5

def initialize(progress_attrs = {})
  @total_size = @size_left = @total_count = @items_left = 0

  unless progress_attrs.nil?
    #depending on whether this is a history item, or current sync structure may be different
    ht = HashUtil.new

    details = ht.null_safe_get(progress_attrs, nil, %w(progress_report yum_importer content)) ||
              ht.null_safe_get(progress_attrs, nil, %w(progress_report puppet_importer modules)) ||
              ht.null_safe_get(progress_attrs, nil, %w(progress_report details packages sync_report)) ||
              ht.null_safe_get(progress_attrs, nil, %w(progress_report iso_importer))

    #if the task is waiting, it wont have a progress report
    progress_attrs['progress_report'] ||= {}

    if progress_attrs['progress_report']['iso_importer']
      @total_size  = ht.null_safe_get(details, 0, ['total_bytes'])
      @size_left   = @total_size - ht.null_safe_get(details, 0, ['finished_bytes'])
      @total_count = ht.null_safe_get(details, 0, ['num_isos'])
      @items_left  = @total_count - ht.null_safe_get(details, 0, ['num_isos_finished'])

    else
      @total_size  = ht.null_safe_get(details, 0, ['size_total'])
      @size_left   = ht.null_safe_get(details, 0, ['size_left'])

      if progress_attrs['progress_report']['puppet_importer']
        @total_count   = ht.null_safe_get(details, 0, ['total_count'])
        finished_count = ht.null_safe_get(details, 0, ['finished_count'])
        @items_left    = @total_count - finished_count
      else
        @total_count = ht.null_safe_get(details, 0, ['items_total'])
        @items_left  = ht.null_safe_get(details, 0, ['items_left'])
      end
    end

    @error_details = errors(progress_attrs['progress_report'])
    @step = ht.null_safe_get(progress_attrs, 0, ['step'])
  end
end

Instance Attribute Details

#error_detailsObject (readonly)

Returns the value of attribute error_details.



3
4
5
# File 'app/models/katello/pulp_sync_status.rb', line 3

def error_details
  @error_details
end

#items_leftObject (readonly)

Returns the value of attribute items_left.



3
4
5
# File 'app/models/katello/pulp_sync_status.rb', line 3

def items_left
  @items_left
end

#size_leftObject (readonly)

Returns the value of attribute size_left.



3
4
5
# File 'app/models/katello/pulp_sync_status.rb', line 3

def size_left
  @size_left
end

#stepObject (readonly)

Returns the value of attribute step.



3
4
5
# File 'app/models/katello/pulp_sync_status.rb', line 3

def step
  @step
end

#total_countObject (readonly)

Returns the value of attribute total_count.



3
4
5
# File 'app/models/katello/pulp_sync_status.rb', line 3

def total_count
  @total_count
end

#total_sizeObject (readonly)

Returns the value of attribute total_size.



3
4
5
# File 'app/models/katello/pulp_sync_status.rb', line 3

def total_size
  @total_size
end