Class: Actions::Pulp3::AbstractAsyncTask
- Inherits:
-
Abstract
- Object
- EntryAction
- Abstract
- Actions::Pulp3::AbstractAsyncTask
show all
- Includes:
- Base::Polling, Dynflow::Action::Cancellable
- Defined in:
- app/lib/actions/pulp3/abstract_async_task.rb
Direct Known Subclasses
Actions::Pulp3::AlternateContentSource::Delete, Actions::Pulp3::AlternateContentSource::DeleteRemote, Actions::Pulp3::AlternateContentSource::Refresh, Actions::Pulp3::AlternateContentSource::RefreshRemote, Actions::Pulp3::AlternateContentSource::Update, Actions::Pulp3::AlternateContentSource::UpdateRemote, CapsuleContent::GenerateMetadata, CapsuleContent::ReclaimSpace, CapsuleContent::RefreshDistribution, CapsuleContent::Sync, ContentView::DeleteRepositoryReferences, ContentViewVersion::CreateImport, ContentViewVersion::DestroyExporter, ContentViewVersion::Export, Orchestration::Repository::RefreshIfNeeded, Orchestration::Repository::RefreshRepos, OrphanCleanup::DeleteOrphanAlternateContentSources, OrphanCleanup::DeleteOrphanDistributions, OrphanCleanup::DeleteOrphanRemotes, OrphanCleanup::DeleteOrphanRepositoryVersions, OrphanCleanup::DeleteOrphanedMigratedRepositories, OrphanCleanup::RemoveOrphans, OrphanCleanup::RemoveUnneededRepos, Repository::CommitUpload, Repository::CopyContent, Repository::CopyVersion, Repository::CreatePublication, Repository::Delete, Repository::DeleteRemote, Repository::DeleteVersion, Repository::ImportUpload, Repository::MultiCopyContent, Repository::MultiCopyUnits, Repository::ReclaimSpace, Repository::RefreshDistribution, Repository::RefreshRemote, Repository::RemoveUnits, Repository::Repair, Repository::SaveArtifact, Repository::Sync, Repository::UpdateRemote, Repository::UploadFile, Repository::UploadTag
Instance Method Summary
collapse
Methods inherited from Abstract
#smart_proxy
Instance Method Details
#cancel ⇒ Object
81
82
83
84
|
# File 'app/lib/actions/pulp3/abstract_async_task.rb', line 81
def cancel
pulp_tasks.each { |task| task.cancel }
task_groups.each { |task_group| task_group.cancel }
end
|
#cancel! ⇒ Object
73
74
75
76
77
78
79
|
# File 'app/lib/actions/pulp3/abstract_async_task.rb', line 73
def cancel!
cancel
poll_external_task
suspend unless done?
end
|
#combined_tasks ⇒ Object
48
49
50
51
|
# File 'app/lib/actions/pulp3/abstract_async_task.rb', line 48
def combined_tasks
return nil if pulp_tasks.nil? && task_groups.nil?
pulp_tasks + task_groups
end
|
#done? ⇒ Boolean
39
40
41
|
# File 'app/lib/actions/pulp3/abstract_async_task.rb', line 39
def done?
combined_tasks&.all? { |task| task.done? }
end
|
#external_task ⇒ Object
43
44
45
46
|
# File 'app/lib/actions/pulp3/abstract_async_task.rb', line 43
def external_task
combined_tasks
end
|
#humanized_state ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'app/lib/actions/pulp3/abstract_async_task.rb', line 14
def humanized_state
case state
when :running
if self.combined_tasks.empty?
_("initiating Pulp task")
else
_("checking Pulp task status")
end
when :suspended
started_task = combined_tasks.find { |task| task&.started? && !task&.done? }&.pulp_data
if started_task
name = started_task[:name] || started_task[:description]
label = get_task_label(name, started_task[:pulp_href])
_("waiting for Pulp to finish the task %s" % label)
else
pending_task = combined_tasks.find { |task| !task&.started? }&.pulp_data
name = pending_task[:name] || pending_task[:description]
label = get_task_label(name, pending_task[:pulp_href])
_("waiting for Pulp to start the task %s" % label) if pending_task
end
else
super
end
end
|
#new_or_existing_objects(object_class, objects) ⇒ Object
63
64
65
66
67
68
69
70
71
|
# File 'app/lib/actions/pulp3/abstract_async_task.rb', line 63
def new_or_existing_objects(object_class, objects)
objects.map do |object|
if object.is_a?(object_class)
object
else
object_class.new(smart_proxy, object)
end
end
end
|
#pulp_tasks ⇒ Object
53
54
55
56
|
# File 'app/lib/actions/pulp3/abstract_async_task.rb', line 53
def pulp_tasks
return nil if output[:pulp_tasks].nil?
output[:pulp_tasks] = new_or_existing_objects(::Katello::Pulp3::Task, output[:pulp_tasks])
end
|
#rescue_external_task(error) ⇒ Object
86
87
88
89
90
91
92
|
# File 'app/lib/actions/pulp3/abstract_async_task.rb', line 86
def rescue_external_task(error)
if error.is_a?(::Katello::Errors::Pulp3Error)
fail error
else
super
end
end
|
#run(event = nil) ⇒ Object
7
8
9
10
11
12
|
# File 'app/lib/actions/pulp3/abstract_async_task.rb', line 7
def run(event = nil)
unless event == Dynflow::Action::Skip
super
end
end
|
#task_groups ⇒ Object
58
59
60
61
|
# File 'app/lib/actions/pulp3/abstract_async_task.rb', line 58
def task_groups
return nil if output[:task_groups].nil?
output[:task_groups] = new_or_existing_objects(::Katello::Pulp3::TaskGroup, output[:task_groups])
end
|