1
|
module Actions
|
2
|
module ForemanPipeline
|
3
|
module Job
|
4
|
class Redeploy < Actions::EntryAction
|
5
|
|
6
|
def plan(job)
|
7
|
sequence do
|
8
|
unique_hostname = "#{normalize_name job.name}-#{::Katello::Util::Model.uuid}"
|
9
|
|
10
|
create_candlepin_key = plan_action(::Actions::Candlepin::ActivationKey::Create, :organization_label => job.content_view.organization.name)
|
11
|
create_key = plan_action(CreateActivationKey, :name => unique_hostname,
|
12
|
:organization_id => job.content_view.organization.id,
|
13
|
:environment_id => job.environment_id,
|
14
|
:content_view_id => job.content_view.id,
|
15
|
:cp_id => create_candlepin_key.output[:response][:id])
|
16
|
|
17
|
create_host = plan_action(CreateHost, unique_hostname, job.hostgroup, job.compute_resource, {
|
18
|
:org_id => job.content_view.organization.id,
|
19
|
:content_view_id => job.content_view.id,
|
20
|
:activation_key => create_key.output[:new_key],
|
21
|
:jenkins_instance_id => job.jenkins_instance_id})
|
22
|
|
23
|
suspend_until = plan_action(SuspendUntilProvisioned, 'host_id' => create_host.output[:host][:id])
|
24
|
|
25
|
plan_self(:create_host => create_host.output[:host],
|
26
|
:installed_at => suspend_until.output[:object][:installed_at],
|
27
|
:new_key => create_key.output[:new_key])
|
28
|
|
29
|
end
|
30
|
end
|
31
|
|
32
|
def run
|
33
|
output[:host] = input[:create_host]
|
34
|
output[:activation_key] = input[:new_key]
|
35
|
end
|
36
|
|
37
|
private
|
38
|
|
39
|
def normalize_name(repo_name)
|
40
|
repo_name.gsub(/[^a-z0-9\-]/, '-')
|
41
|
end
|
42
|
end
|
43
|
end
|
44
|
end
|
45
|
end
|