Class: Actions::Pulp3::Repository::Sync

Inherits:
AbstractAsyncTask show all
Includes:
Helpers::Presenter
Defined in:
app/lib/actions/pulp3/repository/sync.rb

Instance Method Summary collapse

Methods inherited from AbstractAsyncTask

#cancel, #cancel!, #combined_tasks, #done?, #external_task, #humanized_state, #new_or_existing_objects, #pulp_tasks, #rescue_external_task, #run, #task_groups

Methods inherited from Abstract

#smart_proxy

Instance Method Details

#check_error_detailsObject



25
26
27
28
29
30
31
32
# File 'app/lib/actions/pulp3/repository/sync.rb', line 25

def check_error_details
  output[:pulp_tasks].each do |pulp_task|
    error_details = pulp_task.try(:[], "error")
    if error_details && !error_details.nil?
      fail _("An error occurred during the sync \n%{error_message}") % {:error_message => error_details}
    end
  end
end

#external_task=(tasks) ⇒ Object



16
17
18
19
# File 'app/lib/actions/pulp3/repository/sync.rb', line 16

def external_task=(tasks)
  output[:create_version] = true
  super
end

#finalizeObject



21
22
23
# File 'app/lib/actions/pulp3/repository/sync.rb', line 21

def finalize
  check_error_details
end

#invoke_external_taskObject



11
12
13
14
# File 'app/lib/actions/pulp3/repository/sync.rb', line 11

def invoke_external_task
  repo = ::Katello::Repository.find(input[:repo_id])
  output[:pulp_tasks] = repo.backend_service(::SmartProxy.unscoped.find(input[:smart_proxy_id])).sync(input[:options])
end

#plan(repo, smart_proxy, options = {}) ⇒ Object



7
8
9
# File 'app/lib/actions/pulp3/repository/sync.rb', line 7

def plan(repo, smart_proxy, options = {})
  plan_self(:repo_id => repo.id, :smart_proxy_id => smart_proxy.id, :options => options)
end

#presenterObject



42
43
44
# File 'app/lib/actions/pulp3/repository/sync.rb', line 42

def presenter
  Presenters::ContentUnitPresenter.new(self)
end

#rescue_strategy_for_selfObject



46
47
48
49
50
51
# File 'app/lib/actions/pulp3/repository/sync.rb', line 46

def rescue_strategy_for_self
  # There are various reasons the syncing fails, not all of them are
  # fatal: when fail on syncing, we continue with the task ending up
  # in the warning state, but not locking further syncs
  Dynflow::Action::Rescue::Skip
end

#run_progressObject



34
35
36
# File 'app/lib/actions/pulp3/repository/sync.rb', line 34

def run_progress
  presenter.progress
end

#run_progress_weightObject



38
39
40
# File 'app/lib/actions/pulp3/repository/sync.rb', line 38

def run_progress_weight
  10
end