Class: Actions::Katello::Repository::ImportUpload
- Inherits:
-
EntryAction
- Object
- EntryAction
- Actions::Katello::Repository::ImportUpload
- Defined in:
- app/lib/actions/katello/repository/import_upload.rb
Instance Method Summary collapse
- #humanized_name ⇒ Object
-
#plan(repository, uploads, options = {}) ⇒ Object
rubocop:disable Metrics/MethodLength.
- #rescue_strategy ⇒ Object
- #results_to_json(results) ⇒ Object
-
#run ⇒ Object
rubocop:enable Metrics/MethodLength.
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
#humanized_name ⇒ Object
76 77 78 |
# File 'app/lib/actions/katello/repository/import_upload.rb', line 76 def humanized_name _("Upload into") end |
#plan(repository, uploads, options = {}) ⇒ Object
rubocop:disable Metrics/MethodLength
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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'app/lib/actions/katello/repository/import_upload.rb', line 10 def plan(repository, uploads, = {}) action_subject(repository) repository.clear_smart_proxy_sync_histories repo_service = repository.backend_service(::SmartProxy.pulp_primary) upload_ids = uploads.pluck('id') unit_keys = repo_service.unit_keys(uploads) = .fetch(:generate_metadata, true) sync_capsule = .fetch(:sync_capsule, true) generate_applicability = .fetch(:generate_applicability, repository.yum?) [:content_type] ||= ::Katello::RepositoryTypeManager.find(repository.content_type).default_managed_content_type.label 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 content_type = ::Katello::RepositoryTypeManager.find_content_type([:content_type]) sequence do upload_results = concurrence do upload_ids.zip(unit_keys).collect do |upload_id, unit_key| = unit_key if unit_type_id == 'docker_tag' import_upload_args = { pulp_id: repository.pulp_id, unit_type_id: unit_type_id, unit_key: unit_key.with_indifferent_access, upload_id: upload_id, unit_metadata: , } import_upload_args.merge!() if content_type.repository_import_on_upload action_class = ::Actions::Pulp3::Orchestration::Repository::ImportRepositoryUpload else action_class = ::Actions::Pulp3::Orchestration::Repository::ImportUpload end import_upload = plan_action(action_class, repository, SmartProxy.pulp_primary, import_upload_args) plan_action(FinishUpload, repository, :import_upload_task => import_upload.output, generate_metadata: false, content_type: [:content_type]) import_upload.output end end plan_action(Katello::Repository::MetadataGenerate, repository, force_publication: true) if plan_action(Actions::Katello::Applicability::Repository::Regenerate, :repo_ids => [repository.id]) if generate_applicability plan_self(repository_id: repository.id, sync_capsule: sync_capsule, upload_results: upload_results) # Refresh rolling CVs that have this repository update_rolling_content_views(repository) end end |
#rescue_strategy ⇒ Object
72 73 74 |
# File 'app/lib/actions/katello/repository/import_upload.rb', line 72 def rescue_strategy Dynflow::Action::Rescue::Skip end |
#results_to_json(results) ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'app/lib/actions/katello/repository/import_upload.rb', line 80 def results_to_json(results) json_results = [] results.each do |result| result[:pulp_tasks]&.each do |task| details = task ? task.dig(:result, :details, :unit) : nil if details && details.dig('type_id') == 'docker_manifest' manifest = ::Katello::DockerManifest.find_by(:pulp_id => details.dig(:metadata, :id)) json_result = JSON.parse(::Rabl.render(manifest, '/katello/api/v2/docker_manifests/show')) json_result[:type] = 'docker_manifest' json_results << json_result elsif details && details.dig('type_id') == 'docker_tag' manifest = ::Katello::DockerTag.find_by(:pulp_id => details.dig(:metadata, :id)) json_result = JSON.parse(::Rabl.render(manifest, '/katello/api/v2/docker_tags/show')) json_result[:type] = 'docker_tag' json_results << json_result else json_results << {:type => 'file'} end end if !json_results.size && (result[:content_unit_href]) json_results << {:type => 'file'} end end json_results end |
#run ⇒ Object
rubocop:enable Metrics/MethodLength
65 66 67 68 69 70 |
# File 'app/lib/actions/katello/repository/import_upload.rb', line 65 def run repository = ::Katello::Repository.find(input[:repository_id]) schedule_async_repository_proxy_sync(repository) if input[:sync_capsule] output[:upload_results] = results_to_json(input[:upload_results]) rescue ::Katello::Errors::CapsuleCannotBeReached # skip any capsules that cannot be connected to end |