Class: Actions::Katello::Repository::UploadFiles

Inherits:
EntryAction
  • Object
show all
Includes:
Helpers::RollingCVRepos, Helpers::SmartProxySyncHelper
Defined in:
app/lib/actions/katello/repository/upload_files.rb

Instance Method Summary collapse

Methods included from Helpers::SmartProxySyncHelper

#schedule_async_repository_proxy_sync

Methods included from Helpers::RollingCVRepos

#find_related_rolling_repos, #update_rolling_content_views, #update_rolling_content_views_async

Instance Method Details

#finalizeObject



64
65
66
# File 'app/lib/actions/katello/repository/upload_files.rb', line 64

def finalize
  delete_tmp_files(input[:tmp_files])
end

#humanized_nameObject



60
61
62
# File 'app/lib/actions/katello/repository/upload_files.rb', line 60

def humanized_name
  _("Upload into")
end

#plan(repository, files, content_type = nil, options = {}) ⇒ Object



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
44
45
46
47
48
49
50
51
52
# File 'app/lib/actions/katello/repository/upload_files.rb', line 12

def plan(repository, files, content_type = nil, options = {})
  action_subject(repository)
  repository.check_ready_to_act!
  repository.clear_smart_proxy_sync_histories
  tmp_files = prepare_tmp_files(files)

  content_type ||= ::Katello::RepositoryTypeManager.find(repository.content_type).default_managed_content_type.label
  ::Katello::RepositoryTypeManager.check_content_matches_repo_type!(repository, content_type)

  if ::Katello::RepositoryTypeManager.generic_content_type?(content_type)
    unit_type_id = content_type
  else
    unit_type_id = SmartProxy.pulp_primary.content_service(content_type)::CONTENT_TYPE
  end

  upload_actions = []

  generate_applicability = options.fetch(:generate_applicability, repository.yum?)

  sequence do
    tmp_files.each do |file|
      sequence do
        upload_action = plan_action(Pulp3::Orchestration::Repository::UploadContent,
                                         repository, SmartProxy.pulp_primary!, file, unit_type_id)

        upload_actions << upload_action.output
      end
    end

    plan_action(FinishUpload, repository, content_type: content_type, upload_actions: upload_actions)
    plan_self(tmp_files: tmp_files)
    plan_action(Actions::Katello::Applicability::Repository::Regenerate, :repo_ids => [repository.id]) if generate_applicability

    # Refresh rolling CVs that have this repository
    update_rolling_content_views(repository)
  end
ensure
  # Delete tmp files when some exception occurred. Would be
  # nice to have other ways to do that: https://github.com/Dynflow/dynflow/issues/130
  delete_tmp_files(tmp_files) if $ERROR_INFO && tmp_files
end

#rescue_strategyObject



68
69
70
# File 'app/lib/actions/katello/repository/upload_files.rb', line 68

def rescue_strategy
  Dynflow::Action::Rescue::Skip
end

#runObject



54
55
56
57
58
# File 'app/lib/actions/katello/repository/upload_files.rb', line 54

def run
  repository = ::Katello::Repository.find(input[:repository][:id])
  schedule_async_repository_proxy_sync(repository)
rescue ::Katello::Errors::CapsuleCannotBeReached # skip any capsules that cannot be connected to
end