Class: Actions::Pulp3::Repository::SaveArtifact
- Inherits:
-
AbstractAsyncTask
- Object
- EntryAction
- Abstract
- AbstractAsyncTask
- Actions::Pulp3::Repository::SaveArtifact
- Defined in:
- app/lib/actions/pulp3/repository/save_artifact.rb
Instance Method Summary collapse
- #fetch_artifact_href ⇒ Object
- #invoke_external_task ⇒ Object
-
#plan(file, repository, smart_proxy, tasks, unit_type_id, options = {}) ⇒ Object
This task creates a content unit and may or may not create a new repository version in the process.
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
Instance Method Details
#fetch_artifact_href ⇒ Object
37 38 39 40 |
# File 'app/lib/actions/pulp3/repository/save_artifact.rb', line 37 def fetch_artifact_href sha_artifact_list = ::Katello::Pulp3::Api::Core.new(smart_proxy).artifacts_api.list("sha256": input[:options][:sha256]) sha_artifact_list&.results&.first&.pulp_href end |
#invoke_external_task ⇒ 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 |
# File 'app/lib/actions/pulp3/repository/save_artifact.rb', line 12 def invoke_external_task repository = ::Katello::Repository.find(input[:repository_id]) artifact_href = input[:options][:artifact_href] || fetch_artifact_href fail _("Content not uploaded to pulp") unless artifact_href content_type = input[:unit_type_id] content_backend_service = SmartProxy.pulp_primary.content_service(content_type) existing_content = ::Katello::Pulp3::PulpContentUnit.find_duplicate_unit(repository, input[:unit_type_id], {filename: input[:options][:file_name]}, input[:options][:sha256]) existing_content_href = existing_content&.results&.first&.pulp_href if ::Katello::RepositoryTypeManager.find_content_type(input[:unit_type_id]).repository_import_on_upload output[:pulp_tasks] = [repository.backend_service(smart_proxy).repository_import_content(artifact_href, input[:options])] else if existing_content_href output[:content_unit_href] = existing_content_href [] else output[:pulp_tasks] = [content_backend_service.content_api_create(relative_path: input[:options][:file_name], repository_id: repository.id, artifact: artifact_href, content_type: content_type)] end end end |
#plan(file, repository, smart_proxy, tasks, unit_type_id, options = {}) ⇒ Object
This task creates a content unit and may or may not create a new repository version in the process
6 7 8 9 10 |
# File 'app/lib/actions/pulp3/repository/save_artifact.rb', line 6 def plan(file, repository, smart_proxy, tasks, unit_type_id, = {}) [:file_name] = file[:filename] [:sha256] = file[:sha256] || (Digest::SHA256.hexdigest(File.read(file[:path])) if file[:path].present?) plan_self(:repository_id => repository.id, :smart_proxy_id => smart_proxy.id, :tasks => tasks, :unit_type_id => unit_type_id, :options => ) end |