foreman-tasks 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +12 -12
- data/.rubocop_todo.yml +34 -116
- data/app/controllers/foreman_tasks/api/recurring_logics_controller.rb +20 -1
- data/app/controllers/foreman_tasks/api/tasks_controller.rb +29 -9
- data/app/controllers/foreman_tasks/concerns/hosts_controller_extension.rb +1 -1
- data/app/controllers/foreman_tasks/recurring_logics_controller.rb +19 -0
- data/app/helpers/foreman_tasks/foreman_tasks_helper.rb +1 -3
- data/app/lib/actions/helpers/humanizer.rb +1 -3
- data/app/lib/actions/proxy_action.rb +33 -12
- data/app/models/foreman_tasks/concerns/action_triggering.rb +1 -1
- data/app/models/foreman_tasks/recurring_logic.rb +1 -0
- data/app/models/foreman_tasks/remote_task.rb +1 -0
- data/app/models/foreman_tasks/task.rb +4 -0
- data/app/models/foreman_tasks/task/dynflow_task.rb +1 -1
- data/app/models/foreman_tasks/task/search.rb +11 -1
- data/app/services/foreman_tasks/troubleshooting_help_generator.rb +0 -4
- data/app/views/foreman_tasks/api/recurring_logics/base.json.rabl +2 -1
- data/app/views/foreman_tasks/api/tasks/details.json.rabl +1 -0
- data/app/views/foreman_tasks/api/tasks/show.json.rabl +1 -1
- data/app/views/foreman_tasks/recurring_logics/index.html.erb +30 -0
- data/app/views/foreman_tasks/tasks/show.html.erb +3 -0
- data/config/routes.rb +7 -0
- data/foreman-tasks.gemspec +4 -6
- data/lib/foreman_tasks/dynflow/console_authorizer.rb +2 -2
- data/lib/foreman_tasks/engine.rb +15 -13
- data/lib/foreman_tasks/tasks/cleanup.rake +1 -1
- data/lib/foreman_tasks/tasks/export_tasks.rake +2 -2
- data/lib/foreman_tasks/test_extensions.rb +1 -1
- data/lib/foreman_tasks/version.rb +1 -1
- data/locale/action_names.rb +1 -1
- data/package.json +1 -2
- data/script/rails +2 -2
- data/test/factories/task_factory.rb +34 -2
- data/test/foreman_tasks_test_helper.rb +4 -0
- data/test/unit/actions/action_with_sub_plans_test.rb +1 -1
- data/test/unit/task_test.rb +160 -74
- data/webpack/ForemanTasks/Components/TaskDetails/Components/Task.js +4 -0
- data/webpack/ForemanTasks/Components/TaskDetails/Components/TaskInfo.js +3 -12
- data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/Task.test.js +1 -0
- data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/__snapshots__/Task.test.js.snap +3 -1
- data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/__snapshots__/TaskInfo.test.js.snap +2 -6
- data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsSelectors.js +4 -1
- data/webpack/ForemanTasks/Components/TaskDetails/__tests__/__snapshots__/TaskDetails.test.js.snap +1 -0
- data/webpack/ForemanTasks/Components/TaskDetails/index.js +2 -0
- data/webpack/ForemanTasks/Components/TasksTable/SubTasksPage.js +3 -1
- data/webpack/ForemanTasks/Components/TasksTable/TasksTableActions.js +87 -21
- data/webpack/ForemanTasks/Components/TasksTable/TasksTableConstants.js +7 -7
- data/webpack/ForemanTasks/Components/TasksTable/TasksTablePage.js +31 -22
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTable.fixtures.js +2 -1
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableActions.test.js +44 -46
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/SubTasksPage.test.js.snap +3 -1
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksIndexPage.test.js.snap +2 -1
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksTableActions.test.js.snap +61 -5
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksTablePage.test.js.snap +6 -2
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 933e58fce5919b151351e1a148a2360faea964f688a79b5db85223dd62653f51
|
4
|
+
data.tar.gz: 53b98db8cf8f6dc19c489a78a4eb923389413464dcb9fa4ca732888a032063ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3a7334ab5a5efb4dd3957ead30a520836311def55777ffba66b60c272b93137ab1fbdad7a9c32ab70c23a9b5308442a6a0c1a48da00dc4d4eb8868cd9c931e9
|
7
|
+
data.tar.gz: df1a0dc013edb5c5baebb3e97a275b8ac9075963546cbb318743c368db9d373fc3277739a690a346b79db72397f437be86c1159cfd78cf2ae407ab7ecde8ee75
|
data/.rubocop.yml
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
-
require:
|
1
|
+
require:
|
2
|
+
- rubocop-minitest
|
3
|
+
- rubocop-performance
|
4
|
+
- rubocop-rails
|
2
5
|
|
3
|
-
|
4
|
-
inherit_from:
|
5
|
-
- .rubocop_todo.yml
|
6
|
+
inherit_from: .rubocop_todo.yml
|
6
7
|
|
7
8
|
AllCops:
|
8
9
|
Include:
|
@@ -55,12 +56,11 @@ Rails/FilePath:
|
|
55
56
|
Rails/ReversibleMigration:
|
56
57
|
Enabled: false
|
57
58
|
|
58
|
-
Metrics
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
- lib/foreman_tasks/tasks/**/*
|
59
|
+
Metrics:
|
60
|
+
Enabled: false
|
61
|
+
|
62
|
+
Layout/LineLength:
|
63
|
+
Enabled: false
|
64
64
|
|
65
65
|
Naming/FileName:
|
66
66
|
Exclude:
|
@@ -69,7 +69,7 @@ Naming/FileName:
|
|
69
69
|
- db/seeds.d/*
|
70
70
|
- lib/foreman-tasks.rb
|
71
71
|
|
72
|
-
Layout/
|
72
|
+
Layout/HeredocIndentation:
|
73
73
|
Exclude:
|
74
74
|
- '*.gemspec'
|
75
75
|
- bin/*
|
@@ -101,7 +101,7 @@ Style/FormatStringToken:
|
|
101
101
|
Style/RegexpLiteral:
|
102
102
|
Enabled: false
|
103
103
|
|
104
|
-
Layout/
|
104
|
+
Layout/HashAlignment:
|
105
105
|
Enabled: false
|
106
106
|
|
107
107
|
Metrics/ClassLength:
|
data/.rubocop_todo.yml
CHANGED
@@ -1,113 +1,49 @@
|
|
1
|
-
# This configuration was generated by
|
2
|
-
# `rubocop --auto-gen-config`
|
3
|
-
# on 2018-04-02 18:15:37 +0200 using RuboCop version 0.54.0.
|
4
|
-
# The point is for the user to remove these configuration records
|
5
|
-
# one by one as the offenses are removed from the code base.
|
6
|
-
# Note that changes in the inspected code, or installation of new
|
7
|
-
# versions of RuboCop, may require this file to be generated again.
|
8
|
-
|
9
|
-
# Offense count: 3
|
10
|
-
# Cop supports --auto-correct.
|
11
|
-
# Configuration parameters: Include, TreatCommentsAsGroupSeparators.
|
12
|
-
# Include: **/*.gemspec
|
13
|
-
Gemspec/OrderedDependencies:
|
14
|
-
Exclude:
|
15
|
-
- 'foreman-tasks.gemspec'
|
16
|
-
|
17
|
-
# Offense count: 1
|
18
|
-
# Cop supports --auto-correct.
|
19
|
-
# Configuration parameters: EnforcedStyle.
|
20
|
-
# SupportedStyles: final_newline, final_blank_line
|
21
|
-
Layout/TrailingBlankLines:
|
22
|
-
Exclude:
|
23
|
-
- 'locale/action_names.rb'
|
24
|
-
|
25
1
|
# Offense count: 1
|
26
2
|
Lint/EmptyWhen:
|
27
3
|
Exclude:
|
28
4
|
- 'app/lib/actions/proxy_action.rb'
|
29
5
|
|
30
|
-
# Offense count:
|
6
|
+
# Offense count: 1
|
31
7
|
Lint/UselessAssignment:
|
32
8
|
Exclude:
|
33
9
|
- 'lib/foreman_tasks/tasks/export_tasks.rake'
|
34
10
|
|
35
|
-
|
36
|
-
|
37
|
-
Max: 41
|
38
|
-
|
39
|
-
# Offense count: 2
|
40
|
-
# Configuration parameters: CountComments, ExcludedMethods.
|
41
|
-
Metrics/BlockLength:
|
42
|
-
Max: 32
|
43
|
-
|
44
|
-
# Offense count: 13
|
45
|
-
# Configuration parameters: CountComments.
|
46
|
-
Metrics/ClassLength:
|
47
|
-
Max: 230
|
48
|
-
|
49
|
-
# Offense count: 9
|
50
|
-
Metrics/CyclomaticComplexity:
|
51
|
-
Max: 9
|
52
|
-
|
53
|
-
# Offense count: 482
|
54
|
-
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
55
|
-
# URISchemes: http, https
|
56
|
-
Metrics/LineLength:
|
57
|
-
Max: 211
|
58
|
-
|
59
|
-
# Offense count: 54
|
60
|
-
# Configuration parameters: CountComments.
|
61
|
-
Metrics/MethodLength:
|
62
|
-
Max: 29
|
63
|
-
|
64
|
-
# Offense count: 2
|
65
|
-
# Configuration parameters: CountComments.
|
66
|
-
Metrics/ModuleLength:
|
67
|
-
Max: 167
|
11
|
+
Minitest/AssertEmpty:
|
12
|
+
Enabled: false
|
68
13
|
|
69
|
-
|
70
|
-
|
71
|
-
Metrics/ParameterLists:
|
72
|
-
Max: 6
|
14
|
+
Minitest/AssertEqual:
|
15
|
+
Enabled: false
|
73
16
|
|
74
|
-
|
75
|
-
|
76
|
-
Max: 9
|
17
|
+
Minitest/GlobalExpectations:
|
18
|
+
Enabled: false
|
77
19
|
|
78
20
|
# Offense count: 3
|
21
|
+
# Configuration parameters: EnforcedStyleForLeadingUnderscores.
|
22
|
+
# SupportedStylesForLeadingUnderscores: disallowed, required, optional
|
79
23
|
Naming/MemoizedInstanceVariableName:
|
80
24
|
Exclude:
|
81
25
|
- 'app/controllers/foreman_tasks/recurring_logics_controller.rb'
|
82
26
|
- 'app/lib/actions/recurring_action.rb'
|
83
27
|
- 'lib/foreman_tasks_core/otp_manager.rb'
|
84
28
|
|
29
|
+
# Offense count: 11
|
30
|
+
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
|
31
|
+
# AllowedNames: io, id, to, by, on, in, at, ip, db, os, pp
|
32
|
+
Naming/MethodParameterName:
|
33
|
+
Exclude:
|
34
|
+
- 'app/helpers/foreman_tasks/foreman_tasks_helper.rb'
|
35
|
+
|
85
36
|
# Offense count: 1
|
86
|
-
# Configuration parameters: NamePrefix,
|
37
|
+
# Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros.
|
87
38
|
# NamePrefix: is_, has_, have_
|
88
|
-
#
|
89
|
-
#
|
39
|
+
# ForbiddenPrefixes: is_, has_, have_
|
40
|
+
# AllowedMethods: is_a?
|
90
41
|
# MethodDefinitionMacros: define_method, define_singleton_method
|
91
42
|
Naming/PredicateName:
|
92
43
|
Exclude:
|
93
44
|
- 'spec/**/*'
|
94
45
|
- 'app/models/foreman_tasks/task/status_explicator.rb'
|
95
46
|
|
96
|
-
# Offense count: 12
|
97
|
-
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
|
98
|
-
# AllowedNames: io, id, to
|
99
|
-
Naming/UncommunicativeMethodParamName:
|
100
|
-
Exclude:
|
101
|
-
- 'app/helpers/foreman_tasks/foreman_tasks_helper.rb'
|
102
|
-
- 'app/models/foreman_tasks/recurring_logic.rb'
|
103
|
-
|
104
|
-
# Offense count: 3
|
105
|
-
# Cop supports --auto-correct.
|
106
|
-
Rails/ActiveRecordAliases:
|
107
|
-
Exclude:
|
108
|
-
- 'app/models/foreman_tasks/task/dynflow_task.rb'
|
109
|
-
- 'test/factories/task_factory.rb'
|
110
|
-
|
111
47
|
# Offense count: 6
|
112
48
|
# Configuration parameters: Include.
|
113
49
|
# Include: db/migrate/*.rb
|
@@ -119,14 +55,6 @@ Rails/CreateTableWithTimestamps:
|
|
119
55
|
- 'db/migrate/20150907131503_create_task_groups.rb'
|
120
56
|
- 'db/migrate/20151112152108_create_triggerings.rb'
|
121
57
|
|
122
|
-
# Offense count: 1
|
123
|
-
# Cop supports --auto-correct.
|
124
|
-
# Configuration parameters: EnforcedStyle.
|
125
|
-
# SupportedStyles: numeric, symbolic
|
126
|
-
Rails/HttpStatus:
|
127
|
-
Exclude:
|
128
|
-
- 'app/controllers/foreman_tasks/concerns/hosts_controller_extension.rb'
|
129
|
-
|
130
58
|
# Offense count: 1
|
131
59
|
# Configuration parameters: Include.
|
132
60
|
# Include: app/**/*.rb, config/**/*.rb, db/**/*.rb, lib/**/*.rb
|
@@ -139,7 +67,14 @@ Rails/OutputSafety:
|
|
139
67
|
Exclude:
|
140
68
|
- 'app/helpers/foreman_tasks/foreman_tasks_helper.rb'
|
141
69
|
|
142
|
-
# Offense count:
|
70
|
+
# Offense count: 1
|
71
|
+
# Configuration parameters: Include.
|
72
|
+
# Include: **/Rakefile, **/*.rake
|
73
|
+
Rails/RakeEnvironment:
|
74
|
+
Exclude:
|
75
|
+
- 'lib/foreman_tasks/tasks/test.rake'
|
76
|
+
|
77
|
+
# Offense count: 12
|
143
78
|
# Cop supports --auto-correct.
|
144
79
|
# Configuration parameters: AutoCorrect, EnforcedStyle.
|
145
80
|
# SupportedStyles: nested, compact
|
@@ -163,33 +98,16 @@ Style/DoubleNegation:
|
|
163
98
|
- 'app/models/foreman_tasks/lock.rb'
|
164
99
|
- 'app/models/foreman_tasks/recurring_logic.rb'
|
165
100
|
|
166
|
-
# Offense count:
|
167
|
-
# Cop supports --auto-correct.
|
168
|
-
Style/Encoding:
|
169
|
-
Exclude:
|
170
|
-
- 'foreman-tasks-core.gemspec'
|
171
|
-
- 'foreman-tasks.gemspec'
|
172
|
-
|
173
|
-
# Offense count: 6
|
174
|
-
# Cop supports --auto-correct.
|
175
|
-
Style/ExpandPathArguments:
|
176
|
-
Exclude:
|
177
|
-
- 'foreman-tasks-core.gemspec'
|
178
|
-
- 'foreman-tasks.gemspec'
|
179
|
-
- 'lib/foreman_tasks/engine.rb'
|
180
|
-
- 'script/rails'
|
181
|
-
|
182
|
-
# Offense count: 32
|
101
|
+
# Offense count: 36
|
183
102
|
# Configuration parameters: MinBodyLength.
|
184
103
|
Style/GuardClause:
|
185
104
|
Enabled: false
|
186
105
|
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
Style/
|
191
|
-
|
192
|
-
- 'app/models/foreman_tasks/concerns/action_triggering.rb'
|
106
|
+
Style/HashEachMethods:
|
107
|
+
Enabled: false
|
108
|
+
|
109
|
+
Style/HashTransformKeys:
|
110
|
+
Enabled: false
|
193
111
|
|
194
|
-
|
112
|
+
Style/HashTransformValues:
|
195
113
|
Enabled: false
|
@@ -10,6 +10,12 @@ module ForemanTasks
|
|
10
10
|
api_base_url '/foreman_tasks/api'
|
11
11
|
end
|
12
12
|
|
13
|
+
# Foreman right now doesn't have mechanism to
|
14
|
+
# cause general BadRequest handling, resuing the Apipie::ParamError
|
15
|
+
# for now http://projects.theforeman.org/issues/3957
|
16
|
+
class BadRequest < Apipie::ParamError
|
17
|
+
end
|
18
|
+
|
13
19
|
before_action :find_resource, :only => %w[show cancel update]
|
14
20
|
|
15
21
|
api :GET, '/recurring_logics', N_('List recurring logics')
|
@@ -39,9 +45,22 @@ module ForemanTasks
|
|
39
45
|
ForemanTasks::RecurringLogic
|
40
46
|
end
|
41
47
|
|
48
|
+
api :POST, '/recurring_logics/bulk_destroy', N_('Delete recurring logics by search query')
|
49
|
+
param :search, String, :desc => N_('Search query'), :required => true
|
50
|
+
def bulk_destroy
|
51
|
+
if params[:search].blank?
|
52
|
+
raise BadRequest, _('Please provide a search parameter in the request')
|
53
|
+
end
|
54
|
+
scope = resource_scope.search_for(params[:search])
|
55
|
+
scope.each(&:destroy!)
|
56
|
+
render json: { destroyed: scope }
|
57
|
+
rescue ActiveRecord::RecordNotDestroyed => error
|
58
|
+
render json: { error: error, scope: scope }, status: :bad_request
|
59
|
+
end
|
60
|
+
|
42
61
|
def action_permission
|
43
62
|
case params[:action]
|
44
|
-
when 'cancel'
|
63
|
+
when 'cancel', 'bulk_destroy'
|
45
64
|
'edit'
|
46
65
|
else
|
47
66
|
super
|
@@ -89,19 +89,13 @@ module ForemanTasks
|
|
89
89
|
param :search, String, :desc => N_('Resume tasks matching search string')
|
90
90
|
param :task_ids, Array, :desc => N_('Resume specific tasks by ID')
|
91
91
|
def bulk_resume
|
92
|
-
scope = resource_scope
|
93
|
-
scope = scope.search_for(params[:search]) if params[:search]
|
94
|
-
scope = scope.select('DISTINCT foreman_tasks_tasks.*')
|
95
92
|
if params[:search].nil? && params[:task_ids].nil?
|
96
|
-
|
97
|
-
scope = scope.where(:result => :error)
|
93
|
+
raise BadRequest, _('Please provide at least one of search or task_ids parameters in the request')
|
98
94
|
end
|
99
|
-
scope = scope.where(:id => params[:task_ids]) if params[:task_ids]
|
100
|
-
|
101
95
|
resumed = []
|
102
96
|
failed = []
|
103
97
|
skipped = []
|
104
|
-
|
98
|
+
bulk_scope.each do |task|
|
105
99
|
if task.resumable?
|
106
100
|
begin
|
107
101
|
ForemanTasks.dynflow.world.execute(task.execution_plan.id)
|
@@ -122,6 +116,24 @@ module ForemanTasks
|
|
122
116
|
}
|
123
117
|
end
|
124
118
|
|
119
|
+
api :POST, '/tasks/bulk_cancel', N_('Cancel all cancellable tasks')
|
120
|
+
param :search, String, :desc => N_('Cancel tasks matching search string')
|
121
|
+
param :task_ids, Array, :desc => N_('Cancel specific tasks by ID')
|
122
|
+
def bulk_cancel
|
123
|
+
if params[:search].nil? && params[:task_ids].nil?
|
124
|
+
raise BadRequest, _('Please provide at least one of search or task_ids parameters in the request')
|
125
|
+
end
|
126
|
+
|
127
|
+
cancelled, skipped = bulk_scope.partition(&:cancellable?)
|
128
|
+
|
129
|
+
cancelled.each(&:cancel)
|
130
|
+
render :json => {
|
131
|
+
total: cancelled.length + skipped.length,
|
132
|
+
cancelled: cancelled,
|
133
|
+
skipped: skipped
|
134
|
+
}
|
135
|
+
end
|
136
|
+
|
125
137
|
api :GET, '/tasks', N_('List tasks')
|
126
138
|
param :search, String, :desc => N_('Search string')
|
127
139
|
param :page, :number, :desc => N_('Page number, starting at 1')
|
@@ -272,7 +284,7 @@ module ForemanTasks
|
|
272
284
|
case params[:action]
|
273
285
|
when 'bulk_search', 'summary', 'details', 'sub_tasks'
|
274
286
|
:view
|
275
|
-
when 'bulk_resume'
|
287
|
+
when 'bulk_resume', 'bulk_cancel'
|
276
288
|
:edit
|
277
289
|
else
|
278
290
|
super
|
@@ -311,6 +323,14 @@ module ForemanTasks
|
|
311
323
|
results: results
|
312
324
|
}
|
313
325
|
end
|
326
|
+
|
327
|
+
def bulk_scope
|
328
|
+
scope = resource_scope
|
329
|
+
scope = scope.search_for(params[:search]) if params[:search]
|
330
|
+
scope = scope.select('DISTINCT foreman_tasks_tasks.*')
|
331
|
+
scope = scope.where(:id => params[:task_ids]) if params[:task_ids]
|
332
|
+
scope
|
333
|
+
end
|
314
334
|
end
|
315
335
|
end
|
316
336
|
end
|
@@ -9,7 +9,7 @@ module ForemanTasks
|
|
9
9
|
params[:certname],
|
10
10
|
detected_proxy.try(:id))
|
11
11
|
|
12
|
-
render :json => { :task_id => task.id }, :status =>
|
12
|
+
render :json => { :task_id => task.id }, :status => :accepted
|
13
13
|
rescue ::Foreman::Exception => e
|
14
14
|
render :json => { 'message' => e.to_s }, :status => :unprocessable_entity
|
15
15
|
end
|
@@ -22,6 +22,12 @@ module ForemanTasks
|
|
22
22
|
redirect_to :action => :index
|
23
23
|
end
|
24
24
|
|
25
|
+
def clear_cancelled
|
26
|
+
scope = resource_base.search_for('state=cancelled')
|
27
|
+
scope.destroy_all
|
28
|
+
redirect_to :action => :index
|
29
|
+
end
|
30
|
+
|
25
31
|
def controller_name
|
26
32
|
'foreman_tasks_recurring_logics'
|
27
33
|
end
|
@@ -49,5 +55,18 @@ module ForemanTasks
|
|
49
55
|
scope.search_for(params[:search])
|
50
56
|
.paginate(:page => params[:page], :per_page => params[:per_page])
|
51
57
|
end
|
58
|
+
|
59
|
+
def action_permission
|
60
|
+
case params[:action]
|
61
|
+
when 'clear_cancelled'
|
62
|
+
'edit'
|
63
|
+
else
|
64
|
+
super
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def controller_permission
|
69
|
+
'recurring_logics'
|
70
|
+
end
|
52
71
|
end
|
53
72
|
end
|
@@ -1,5 +1,4 @@
|
|
1
1
|
module ForemanTasks
|
2
|
-
# rubocop:disable Metrics/ModuleLength
|
3
2
|
module ForemanTasksHelper
|
4
3
|
def recurring_logic_state(recurring_logic)
|
5
4
|
icon, status = case recurring_logic.state
|
@@ -28,7 +27,7 @@ module ForemanTasks
|
|
28
27
|
def troubleshooting_info_text
|
29
28
|
return if @task.state != 'paused' || @task.main_action.nil?
|
30
29
|
helper = TroubleshootingHelpGenerator.new(@task.main_action)
|
31
|
-
helper.
|
30
|
+
helper.generate_html
|
32
31
|
end
|
33
32
|
|
34
33
|
def username_link_task(owner, username)
|
@@ -209,5 +208,4 @@ module ForemanTasks
|
|
209
208
|
tags.join.html_safe
|
210
209
|
end
|
211
210
|
end
|
212
|
-
# rubocop:enable Metrics/ModuleLength
|
213
211
|
end
|
@@ -41,12 +41,7 @@ module Actions
|
|
41
41
|
with_connection_error_handling(event) do |event|
|
42
42
|
case event
|
43
43
|
when nil
|
44
|
-
|
45
|
-
on_resume
|
46
|
-
else
|
47
|
-
trigger_proxy_task
|
48
|
-
end
|
49
|
-
suspend
|
44
|
+
start_or_resume
|
50
45
|
when ::Dynflow::Action::Skip
|
51
46
|
# do nothing
|
52
47
|
when ::Dynflow::Action::Cancellable::Cancel
|
@@ -77,6 +72,12 @@ module Actions
|
|
77
72
|
end
|
78
73
|
end
|
79
74
|
|
75
|
+
def trigger_remote_task
|
76
|
+
suspend do |_suspended_action|
|
77
|
+
ForemanTasks::RemoteTask.batch_trigger(remote_task.operation, [remote_task])
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
80
81
|
def proxy_input(task_id = task.id)
|
81
82
|
input.merge(:callback => { :task_id => task_id,
|
82
83
|
:step_id => run_step_id })
|
@@ -88,7 +89,7 @@ module Actions
|
|
88
89
|
if response['result'] == 'error'
|
89
90
|
raise ::Foreman::Exception, _('The smart proxy task %s failed.') % proxy_task_id
|
90
91
|
else
|
91
|
-
on_data(response
|
92
|
+
on_data(get_proxy_data(response))
|
92
93
|
end
|
93
94
|
else
|
94
95
|
suspend
|
@@ -154,10 +155,8 @@ module Actions
|
|
154
155
|
if output.key?(:proxy_output) || state == :error
|
155
156
|
output.fetch(:proxy_output, {})
|
156
157
|
elsif live && proxy_task_id
|
157
|
-
|
158
|
-
|
159
|
-
end
|
160
|
-
proxy_data.fetch('output', {})
|
158
|
+
response = proxy.status_of_task(proxy_task_id)
|
159
|
+
get_proxy_data(response)
|
161
160
|
else
|
162
161
|
{}
|
163
162
|
end
|
@@ -205,6 +204,26 @@ module Actions
|
|
205
204
|
|
206
205
|
private
|
207
206
|
|
207
|
+
def start_or_resume
|
208
|
+
if remote_task
|
209
|
+
if remote_task.state == 'external'
|
210
|
+
trigger_remote_task
|
211
|
+
else
|
212
|
+
on_resume
|
213
|
+
end
|
214
|
+
else
|
215
|
+
trigger_proxy_task
|
216
|
+
end
|
217
|
+
suspend
|
218
|
+
end
|
219
|
+
|
220
|
+
def get_proxy_data(response)
|
221
|
+
proxy_data = response['actions'].detect do |action|
|
222
|
+
action['class'] == proxy_action_name || action.fetch('input', {})['proxy_operation_name'] == proxy_operation_name
|
223
|
+
end
|
224
|
+
proxy_data.fetch('output', {})
|
225
|
+
end
|
226
|
+
|
208
227
|
def proxy_version(proxy)
|
209
228
|
match = proxy.statuses[:version].version['version'].match(/(\d+)\.(\d+)\.(\d+)/)
|
210
229
|
{ :major => match[1].to_i, :minor => match[2].to_i, :patch => match[3].to_i }
|
@@ -247,10 +266,12 @@ module Actions
|
|
247
266
|
end
|
248
267
|
|
249
268
|
def prepare_remote_task
|
269
|
+
state = input[:use_concurrency_control] ? 'external' : 'new'
|
250
270
|
::ForemanTasks::RemoteTask.new(:execution_plan_id => execution_plan_id,
|
251
271
|
:proxy_url => input[:proxy_url],
|
252
272
|
:step_id => run_step_id,
|
253
|
-
:operation => proxy_operation_name
|
273
|
+
:operation => proxy_operation_name,
|
274
|
+
:state => state)
|
254
275
|
end
|
255
276
|
|
256
277
|
def proxy_task_id
|