foreman-tasks 0.5.3 → 0.5.4
Sign up to get free protection for your applications and to get access to all the features.
@@ -13,9 +13,50 @@ module ForemanTasks
|
|
13
13
|
paginate(:page => params[:page])
|
14
14
|
end
|
15
15
|
|
16
|
+
def resume
|
17
|
+
paused_task_action _('The execution was resumed.') do |task|
|
18
|
+
ForemanTasks.dynflow.world.execute(task.execution_plan.id)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def stop
|
23
|
+
paused_task_action _('The execution was stopped.') do |task|
|
24
|
+
# FIXME also stop dynflow execution plan
|
25
|
+
task.state = :stopped
|
26
|
+
task.save!
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def force_stop
|
31
|
+
task = find_task
|
32
|
+
task.state = :stopped
|
33
|
+
task.save!
|
34
|
+
flash[:notice] = _('The task was stopped with force.')
|
35
|
+
redirect_to foreman_tasks_task_path(task)
|
36
|
+
end
|
37
|
+
|
16
38
|
# we need do this to make the Foreman helpers working properly
|
17
39
|
def controller_name
|
18
40
|
'foreman_tasks_tasks'
|
19
41
|
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def paused_task_action(success_message)
|
46
|
+
task = find_task
|
47
|
+
if task.state != 'paused'
|
48
|
+
flash[:warning] = _('The execution has to be paused.')
|
49
|
+
else
|
50
|
+
yield task
|
51
|
+
flash[:notice] = success_message
|
52
|
+
end
|
53
|
+
|
54
|
+
redirect_to foreman_tasks_task_path(task)
|
55
|
+
end
|
56
|
+
|
57
|
+
def find_task
|
58
|
+
ForemanTasks::Task::DynflowTask.find(params[:id])
|
59
|
+
end
|
60
|
+
|
20
61
|
end
|
21
62
|
end
|
@@ -14,6 +14,8 @@ module Actions
|
|
14
14
|
# * `:exclusive`: same as `:all` + doesn't allow even linking to the resoruce.
|
15
15
|
# typical example is deleting a container, preventing all actions
|
16
16
|
# heppening on it's sub-resources (such a system).
|
17
|
+
# * `:link`: only link the task to the resource, not locking
|
18
|
+
# anything except exclusive locks
|
17
19
|
def resource_locks
|
18
20
|
:all
|
19
21
|
end
|
@@ -34,6 +36,8 @@ module Actions
|
|
34
36
|
if resource.is_a? ActiveRecord::Base
|
35
37
|
if resource_locks == :exclusive
|
36
38
|
exclusive_lock!(resource)
|
39
|
+
elsif resource_locks == :link
|
40
|
+
link!(resource)
|
37
41
|
else
|
38
42
|
lock!(resource, resource_locks)
|
39
43
|
end
|
@@ -14,7 +14,75 @@
|
|
14
14
|
</script>
|
15
15
|
|
16
16
|
<div class="task-details">
|
17
|
+
|
17
18
|
<%= form_for @task, :url => "#" do %>
|
19
|
+
|
20
|
+
<p>
|
21
|
+
<%= link_to(_('Dynflow console'),
|
22
|
+
format('/foreman_tasks/dynflow/%s', @task.external_id),
|
23
|
+
class: %w(btn btn-sm btn-info)) if Setting['dynflow_enable_console'] %>
|
24
|
+
|
25
|
+
<%= link_to(_('Resume'),
|
26
|
+
resume_foreman_tasks_task_path(@task),
|
27
|
+
class: ['btn', 'btn-sm', 'btn-primary', ('disabled' unless @task.state == 'paused')].compact,
|
28
|
+
method: :post) %>
|
29
|
+
|
30
|
+
<%= link_to(_('Stop'),
|
31
|
+
'',
|
32
|
+
class: ['btn', 'btn-sm', 'btn-warning', ('disabled' unless @task.state == 'paused')].compact,
|
33
|
+
:'data-toggle' => "modal",
|
34
|
+
:'data-target' => "#stop_modal") %>
|
35
|
+
|
36
|
+
<%= link_to(_('Force Stop'),
|
37
|
+
'',
|
38
|
+
class: %w(btn btn-sm btn-danger),
|
39
|
+
:'data-toggle' => "modal",
|
40
|
+
:'data-target' => "#force_stop_modal") %>
|
41
|
+
</p>
|
42
|
+
|
43
|
+
<div class="modal fade" id="stop_modal" tabindex="-1" role="dialog" aria-labelledby="Deploy" aria-hidden="true">
|
44
|
+
<div class="modal-dialog">
|
45
|
+
<div class="modal-content">
|
46
|
+
<div class="modal-header">
|
47
|
+
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
48
|
+
<h2 class="modal-title" id="deploy_modal_label">
|
49
|
+
<span class="glyphicon glyphicon-warning-sign"></span>
|
50
|
+
<%= _("Stop") %>
|
51
|
+
</h2>
|
52
|
+
</div>
|
53
|
+
<div class="modal-body">
|
54
|
+
<%= _("This will stop the task and unlock the resources. Please note that this might lead to inconsistent state and should be used with caution, after making sure that the task can't be resumed") %>
|
55
|
+
</div>
|
56
|
+
<div class="modal-footer">
|
57
|
+
<button type="button" class="btn btn-default" data-dismiss="modal"><%= _("Cancel") %></button>
|
58
|
+
<%= link_to(_("Stop"), stop_foreman_tasks_task_path(@task), method: :post, class: 'btn btn-warning') %>
|
59
|
+
</div>
|
60
|
+
</div>
|
61
|
+
</div>
|
62
|
+
</div>
|
63
|
+
|
64
|
+
<div class="modal fade" id="force_stop_modal" tabindex="-1" role="dialog" aria-labelledby="Deploy" aria-hidden="true">
|
65
|
+
<div class="modal-dialog">
|
66
|
+
<div class="modal-content">
|
67
|
+
<div class="modal-header">
|
68
|
+
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
69
|
+
<h2 class="modal-title" id="deploy_modal_label">
|
70
|
+
<span class="glyphicon glyphicon-exclamation-sign"></span>
|
71
|
+
<%= _("Force Stop") %>
|
72
|
+
</h2>
|
73
|
+
</div>
|
74
|
+
<div class="modal-body">
|
75
|
+
<%= _("Resources will be unlocked and will not prevent other tasks from being run. As the task might be still running, it should be avoided to use this unless you are really sure the task got stuck") %>
|
76
|
+
</div>
|
77
|
+
<div class="modal-footer">
|
78
|
+
<button type="button" class="btn btn-default" data-dismiss="modal"><%= _("Cancel") %></button>
|
79
|
+
<%= link_to(_("Force Stop"), force_stop_foreman_tasks_task_path(@task), method: :post, class: 'btn btn-danger') %>
|
80
|
+
</div>
|
81
|
+
</div>
|
82
|
+
</div>
|
83
|
+
</div>
|
84
|
+
|
85
|
+
|
18
86
|
<div>
|
19
87
|
<span class="param-name"><%= _("Id") %>:</span>
|
20
88
|
<span class="param-value"><%= @task.id %></span>
|
@@ -93,5 +161,21 @@
|
|
93
161
|
<span class="param-name"><%= _("External Id") %>:</span>
|
94
162
|
<span class="param-value"><%= @task.external_id %></span>
|
95
163
|
</div>
|
164
|
+
<div>
|
165
|
+
<span class="param-name"><%= _("Locks") %>:</span>
|
166
|
+
<span class="param-value">
|
167
|
+
<ul>
|
168
|
+
<% @task.locks.each do |lock| %>
|
169
|
+
<li>
|
170
|
+
name: <%= lock.name %>
|
171
|
+
<br/>
|
172
|
+
resource: <%= format('%s id:%s', lock.resource_type, lock.resource_id) %>
|
173
|
+
<br/>
|
174
|
+
exclusive: <%= lock.exclusive %>
|
175
|
+
</li>
|
176
|
+
<% end %>
|
177
|
+
</ul>
|
178
|
+
</span>
|
179
|
+
</div>
|
96
180
|
<% end %>
|
97
181
|
</div>
|
data/config/routes.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman-tasks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-05-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|