Class: Actions::Pulp3::CapsuleContent::ReclaimSpace

Inherits:
AbstractAsyncTask show all
Defined in:
app/lib/actions/pulp3/capsule_content/reclaim_space.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

#invoke_external_taskObject



19
20
21
22
# File 'app/lib/actions/pulp3/capsule_content/reclaim_space.rb', line 19

def invoke_external_task
  output[:pulp_tasks] = ::Katello::Pulp3::Api::Core.new(SmartProxy.find(input[:smart_proxy_id])).
    repositories_reclaim_space_api.reclaim(repo_hrefs: input[:repository_hrefs])
end

#plan(smart_proxy) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/lib/actions/pulp3/capsule_content/reclaim_space.rb', line 5

def plan(smart_proxy)
  if smart_proxy.pulp_primary?
    repository_hrefs = ::Katello::Pulp3::RepositoryReference.default_cv_repository_hrefs(::Katello::Repository.unscoped.on_demand, ::Organization.all)
    repository_hrefs.flatten!
  else
    if smart_proxy.download_policy != ::Katello::RootRepository::DOWNLOAD_ON_DEMAND
      fail _('Only On Demand smart proxies may have space reclaimed.')
    end
    repository_hrefs = ::Katello::Pulp3::Api::Core.new(smart_proxy).core_repositories_list_all(fields: 'pulp_href').map(&:pulp_href)
  end
  fail _('There is no downloaded content to clean.') if repository_hrefs.empty?
  plan_self(repository_hrefs: repository_hrefs, smart_proxy_id: smart_proxy.id)
end