foreman-tasks 0.8.6 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +35 -0
- data/.rubocop_todo.yml +138 -0
- data/app/controllers/foreman_tasks/api/recurring_logics_controller.rb +3 -4
- data/app/controllers/foreman_tasks/api/tasks_controller.rb +56 -72
- data/app/controllers/foreman_tasks/concerns/hosts_controller_extension.rb +2 -4
- data/app/controllers/foreman_tasks/recurring_logics_controller.rb +2 -5
- data/app/controllers/foreman_tasks/tasks_controller.rb +7 -8
- data/app/helpers/foreman_tasks/foreman_tasks_helper.rb +44 -46
- data/app/helpers/foreman_tasks/tasks_helper.rb +1 -1
- data/app/lib/actions/action_with_sub_plans.rb +6 -8
- data/app/lib/actions/base.rb +6 -7
- data/app/lib/actions/bulk_action.rb +13 -9
- data/app/lib/actions/entry_action.rb +1 -3
- data/app/lib/actions/foreman/host/import_facts.rb +2 -5
- data/app/lib/actions/foreman/puppetclass/import.rb +1 -1
- data/app/lib/actions/helpers/args_serialization.rb +0 -1
- data/app/lib/actions/helpers/humanizer.rb +16 -21
- data/app/lib/actions/helpers/with_continuous_output.rb +0 -1
- data/app/lib/actions/helpers/with_delegated_action.rb +2 -2
- data/app/lib/actions/middleware/inherit_task_groups.rb +3 -5
- data/app/lib/actions/middleware/keep_current_user.rb +0 -3
- data/app/lib/actions/middleware/recurring_logic.rb +0 -1
- data/app/lib/actions/proxy_action.rb +8 -8
- data/app/lib/actions/serializers/active_record_serializer.rb +0 -3
- data/app/lib/proxy_api/foreman_dynflow/dynflow_proxy.rb +3 -3
- data/app/models/foreman_tasks/concerns/action_subject.rb +4 -6
- data/app/models/foreman_tasks/concerns/action_triggering.rb +20 -33
- data/app/models/foreman_tasks/concerns/host_action_subject.rb +5 -5
- data/app/models/foreman_tasks/lock.rb +29 -37
- data/app/models/foreman_tasks/recurring_logic.rb +23 -24
- data/app/models/foreman_tasks/task.rb +65 -39
- data/app/models/foreman_tasks/task/dynflow_task.rb +23 -24
- data/app/models/foreman_tasks/task/status_explicator.rb +3 -3
- data/app/models/foreman_tasks/task/summarizer.rb +3 -3
- data/app/models/foreman_tasks/task_group.rb +0 -2
- data/app/models/foreman_tasks/task_group_member.rb +0 -2
- data/app/models/foreman_tasks/task_groups/recurring_logic_task_group.rb +1 -4
- data/app/models/foreman_tasks/triggering.rb +19 -19
- data/app/models/setting/foreman_tasks.rb +8 -11
- data/app/services/foreman_tasks/proxy_selector.rb +4 -5
- data/app/views/foreman_tasks/tasks/_details.html.erb +1 -1
- data/bin/dynflow-executor +1 -1
- data/bin/foreman-tasks +1 -1
- data/config/routes.rb +1 -1
- data/db/migrate/20150814204140_add_task_type_value_index.rb +1 -1
- data/db/migrate/20160924213030_change_tasks_widget_names.rb +8 -8
- data/db/seeds.d/61-foreman_tasks_bookmarks.rb +3 -3
- data/deploy/foreman-tasks.sysconfig +6 -0
- data/extra/dynflow-debug.sh +12 -0
- data/foreman-tasks.gemspec +1 -1
- data/lib/foreman_tasks.rb +3 -3
- data/lib/foreman_tasks/authorizer_ext.rb +1 -1
- data/lib/foreman_tasks/cleaner.rb +14 -16
- data/lib/foreman_tasks/dynflow.rb +11 -9
- data/lib/foreman_tasks/dynflow/configuration.rb +8 -10
- data/lib/foreman_tasks/dynflow/console_authorizer.rb +4 -5
- data/lib/foreman_tasks/dynflow/daemon.rb +17 -19
- data/lib/foreman_tasks/dynflow/persistence.rb +5 -8
- data/lib/foreman_tasks/engine.rb +30 -31
- data/lib/foreman_tasks/task_error.rb +1 -3
- data/lib/foreman_tasks/tasks/cleanup.rake +7 -19
- data/lib/foreman_tasks/tasks/dynflow.rake +1 -1
- data/lib/foreman_tasks/tasks/export_tasks.rake +51 -59
- data/lib/foreman_tasks/test_extensions.rb +1 -1
- data/lib/foreman_tasks/version.rb +1 -1
- data/lib/tasks/gettext.rake +10 -7
- data/locale/action_names.rb +3 -6
- data/locale/en/foreman_tasks.po +189 -177
- data/locale/foreman_tasks.pot +177 -137
- data/test/controllers/api/recurring_logics_controller_test.rb +3 -5
- data/test/controllers/api/tasks_controller_test.rb +5 -7
- data/test/factories/task_factory.rb +8 -8
- data/test/factories/triggering_factory.rb +2 -3
- data/test/helpers/foreman_tasks/tasks_helper_test.rb +11 -11
- data/test/support/dummy_proxy_action.rb +3 -4
- data/test/unit/actions/action_with_sub_plans_test.rb +5 -6
- data/test/unit/actions/proxy_action_test.rb +5 -8
- data/test/unit/cleaner_test.rb +11 -12
- data/test/unit/dynflow_console_authorizer_test.rb +4 -4
- data/test/unit/proxy_selector_test.rb +3 -3
- data/test/unit/recurring_logic_test.rb +19 -17
- data/test/unit/task_groups_test.rb +3 -4
- data/test/unit/task_test.rb +72 -5
- data/test/unit/triggering_test.rb +0 -1
- metadata +7 -6
- data/app/controllers/foreman_tasks/concerns/environments_extension.rb +0 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f66037fda7e3529fd63392dcbc458f472077c81a
|
4
|
+
data.tar.gz: 539c7bee3ef29e07296f9d84fa846af50f4512d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7197ef1b6480a4242f9220b699916d49ceb435624ac6a00982e970447b427f8ced258cc8b7d1528ca86ee9bdedbde872b9d8fab222b7347756684df6c9322f61
|
7
|
+
data.tar.gz: 6274bccce4a943b22bb0b55e80f2bcd394899f59c3e5faf5869101e443428cbabd47bb75f4a12ca2686e2889a18afacfae71adc016b92d21ddbc303c146c6255
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# TODO: remove this file by either moving cops here or fixing code
|
2
|
+
inherit_from:
|
3
|
+
- .rubocop_todo.yml
|
4
|
+
|
5
|
+
AllCops:
|
6
|
+
Include:
|
7
|
+
- 'Rakefile'
|
8
|
+
- 'app/views/foreman_tasks/api/**/*.rabl'
|
9
|
+
- lib/**/*.rake
|
10
|
+
|
11
|
+
Lint/ShadowingOuterLocalVariable:
|
12
|
+
Enabled: false
|
13
|
+
|
14
|
+
Rails:
|
15
|
+
Enabled: true
|
16
|
+
|
17
|
+
# Don't prefer is_a? over kind_of?
|
18
|
+
Style/ClassCheck:
|
19
|
+
Enabled: false
|
20
|
+
|
21
|
+
# Don't enforce documentation
|
22
|
+
Style/Documentation:
|
23
|
+
Enabled: false
|
24
|
+
|
25
|
+
# Support both ruby19 and hash_rockets
|
26
|
+
Style/HashSyntax:
|
27
|
+
Enabled: false
|
28
|
+
|
29
|
+
# Both double and single quotes are OK
|
30
|
+
Style/StringLiterals:
|
31
|
+
Enabled: false
|
32
|
+
|
33
|
+
# Don't enforce frozen string literals
|
34
|
+
Style/FrozenStringLiteralComment:
|
35
|
+
Enabled: false
|
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,138 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2016-12-21 14:29:23 +0200 using RuboCop version 0.46.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
|
+
Lint/EmptyWhen:
|
10
|
+
Exclude:
|
11
|
+
- 'app/lib/actions/proxy_action.rb'
|
12
|
+
|
13
|
+
Lint/ShadowingOuterLocalVariable:
|
14
|
+
Exclude:
|
15
|
+
- 'bin/dynflow-executor'
|
16
|
+
|
17
|
+
Lint/UselessAssignment:
|
18
|
+
Exclude:
|
19
|
+
- 'lib/foreman_tasks/tasks/export_tasks.rake'
|
20
|
+
|
21
|
+
Metrics/AbcSize:
|
22
|
+
Max: 41
|
23
|
+
|
24
|
+
# Configuration parameters: CountComments.
|
25
|
+
Metrics/BlockLength:
|
26
|
+
Max: 105
|
27
|
+
|
28
|
+
# Configuration parameters: CountComments.
|
29
|
+
Metrics/ClassLength:
|
30
|
+
Max: 230
|
31
|
+
|
32
|
+
Metrics/CyclomaticComplexity:
|
33
|
+
Max: 10
|
34
|
+
|
35
|
+
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
36
|
+
# URISchemes: http, https
|
37
|
+
Metrics/LineLength:
|
38
|
+
Max: 244
|
39
|
+
|
40
|
+
# Configuration parameters: CountComments.
|
41
|
+
Metrics/MethodLength:
|
42
|
+
Max: 37
|
43
|
+
|
44
|
+
# Configuration parameters: CountComments.
|
45
|
+
Metrics/ModuleLength:
|
46
|
+
Max: 170
|
47
|
+
|
48
|
+
# Configuration parameters: CountKeywordArgs.
|
49
|
+
Metrics/ParameterLists:
|
50
|
+
Max: 6
|
51
|
+
|
52
|
+
Metrics/PerceivedComplexity:
|
53
|
+
Max: 10
|
54
|
+
|
55
|
+
# Configuration parameters: Include.
|
56
|
+
# Include: app/**/*.rb, config/**/*.rb, lib/**/*.rb
|
57
|
+
Rails/Exit:
|
58
|
+
Exclude:
|
59
|
+
- 'lib/**/*.rake'
|
60
|
+
- 'lib/foreman_tasks/dynflow/daemon.rb'
|
61
|
+
|
62
|
+
Rails/HttpPositionalArguments:
|
63
|
+
Enabled: false
|
64
|
+
|
65
|
+
# Configuration parameters: Include.
|
66
|
+
# Include: app/**/*.rb, config/**/*.rb, db/**/*.rb, lib/**/*.rb
|
67
|
+
Rails/Output:
|
68
|
+
Exclude:
|
69
|
+
- 'lib/foreman_tasks/cleaner.rb'
|
70
|
+
|
71
|
+
Rails/OutputSafety:
|
72
|
+
Exclude:
|
73
|
+
- 'app/helpers/foreman_tasks/foreman_tasks_helper.rb'
|
74
|
+
|
75
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
76
|
+
# SupportedStyles: nested, compact
|
77
|
+
Style/ClassAndModuleChildren:
|
78
|
+
Exclude:
|
79
|
+
- 'app/lib/actions/action_with_sub_plans.rb'
|
80
|
+
- 'app/models/foreman_tasks/task/dynflow_task.rb'
|
81
|
+
- 'app/models/foreman_tasks/task/status_explicator.rb'
|
82
|
+
- 'app/models/foreman_tasks/task/summarizer.rb'
|
83
|
+
- 'app/models/foreman_tasks/task/task_cancelled_exception.rb'
|
84
|
+
- 'app/models/setting/foreman_tasks.rb'
|
85
|
+
- 'lib/foreman_tasks/dynflow/configuration.rb'
|
86
|
+
- 'lib/foreman_tasks/dynflow/console_authorizer.rb'
|
87
|
+
- 'lib/foreman_tasks/dynflow/daemon.rb'
|
88
|
+
- 'lib/foreman_tasks/dynflow/persistence.rb'
|
89
|
+
- 'test/controllers/api/recurring_logics_controller_test.rb'
|
90
|
+
- 'test/controllers/api/tasks_controller_test.rb'
|
91
|
+
- 'test/unit/actions/action_with_sub_plans_test.rb'
|
92
|
+
|
93
|
+
Style/DoubleNegation:
|
94
|
+
Exclude:
|
95
|
+
- 'app/models/foreman_tasks/lock.rb'
|
96
|
+
- 'app/models/foreman_tasks/recurring_logic.rb'
|
97
|
+
|
98
|
+
# Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts.
|
99
|
+
Style/FileName:
|
100
|
+
Exclude:
|
101
|
+
- 'db/seeds.d/20-foreman_tasks_permissions.rb'
|
102
|
+
- 'db/seeds.d/60-dynflow_proxy_feature.rb'
|
103
|
+
- 'db/seeds.d/61-foreman_tasks_bookmarks.rb'
|
104
|
+
- 'lib/foreman-tasks.rb'
|
105
|
+
|
106
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
107
|
+
# SupportedStyles: format, sprintf, percent
|
108
|
+
Style/FormatString:
|
109
|
+
Exclude:
|
110
|
+
- 'app/models/foreman_tasks/task/dynflow_task.rb'
|
111
|
+
- 'lib/foreman_tasks/tasks/export_tasks.rake'
|
112
|
+
|
113
|
+
# Configuration parameters: MinBodyLength.
|
114
|
+
Style/GuardClause:
|
115
|
+
Enabled: false
|
116
|
+
|
117
|
+
# Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist.
|
118
|
+
# NamePrefix: is_, has_, have_
|
119
|
+
# NamePrefixBlacklist: is_, has_, have_
|
120
|
+
# NameWhitelist: is_a?
|
121
|
+
Style/PredicateName:
|
122
|
+
Exclude:
|
123
|
+
- 'spec/**/*'
|
124
|
+
- 'app/models/foreman_tasks/task/status_explicator.rb'
|
125
|
+
|
126
|
+
# Cop supports --auto-correct.
|
127
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerSlashes.
|
128
|
+
# SupportedStyles: slashes, percent_r, mixed
|
129
|
+
Style/RegexpLiteral:
|
130
|
+
Exclude:
|
131
|
+
- 'lib/foreman_tasks/dynflow/console_authorizer.rb'
|
132
|
+
|
133
|
+
# Configuration parameters: Methods.
|
134
|
+
# Methods: {"reduce"=>["acc", "elem"]}, {"inject"=>["acc", "elem"]}
|
135
|
+
Style/SingleLineBlockParams:
|
136
|
+
Exclude:
|
137
|
+
- 'app/models/foreman_tasks/concerns/action_subject.rb'
|
138
|
+
- 'app/models/foreman_tasks/lock.rb'
|
@@ -9,7 +9,7 @@ module ForemanTasks
|
|
9
9
|
api_base_url '/foreman_tasks/api'
|
10
10
|
end
|
11
11
|
|
12
|
-
|
12
|
+
before_action :find_resource, :only => %w(show cancel destroy)
|
13
13
|
|
14
14
|
api :GET, '/recurring_logics', N_('List recurring logics')
|
15
15
|
def index
|
@@ -17,9 +17,8 @@ module ForemanTasks
|
|
17
17
|
end
|
18
18
|
|
19
19
|
api :GET, '/recurring_logics/:id', N_('Show recurring logic details')
|
20
|
-
param :id, :identifier, desc:
|
21
|
-
def show
|
22
|
-
end
|
20
|
+
param :id, :identifier, desc: 'ID of the recurring logic', required: true
|
21
|
+
def show; end
|
23
22
|
|
24
23
|
api :POST, '/recurring_logics/:id/cancel', N_('Cancel recurring logic')
|
25
24
|
param :id, :identifier, desc: 'ID of the recurring logic', required: true
|
@@ -1,26 +1,13 @@
|
|
1
|
-
#
|
2
|
-
# Copyright 2013 Red Hat, Inc.
|
3
|
-
#
|
4
|
-
# This software is licensed to you under the GNU General Public
|
5
|
-
# License as published by the Free Software Foundation; either version
|
6
|
-
# 2 of the License (GPLv2) or (at your option) any later version.
|
7
|
-
# There is NO WARRANTY for this software, express or implied,
|
8
|
-
# including the implied warranties of MERCHANTABILITY,
|
9
|
-
# NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
|
10
|
-
# have received a copy of GPLv2 along with this software; if not, see
|
11
|
-
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
|
12
|
-
|
13
1
|
module ForemanTasks
|
14
2
|
module Api
|
15
3
|
class TasksController < ::Api::V2::BaseController
|
16
|
-
|
17
4
|
include ::Foreman::Controller::SmartProxyAuth
|
18
5
|
add_smart_proxy_filters :callback, :features => 'Dynflow'
|
19
6
|
|
20
7
|
resource_description do
|
21
8
|
resource_id 'foreman_tasks'
|
22
9
|
api_version 'v2'
|
23
|
-
api_base_url
|
10
|
+
api_base_url '/foreman_tasks/api'
|
24
11
|
end
|
25
12
|
|
26
13
|
# Foreman right now doesn't have mechanism to
|
@@ -29,25 +16,24 @@ module ForemanTasks
|
|
29
16
|
class BadRequest < Apipie::ParamError
|
30
17
|
end
|
31
18
|
|
32
|
-
|
19
|
+
before_action :find_task, :only => [:show]
|
33
20
|
|
34
|
-
api :GET,
|
21
|
+
api :GET, '/tasks/summary', 'Show task summary'
|
35
22
|
def summary
|
36
23
|
render :json => ForemanTasks::Task::Summarizer.new.summarize_by_status
|
37
24
|
end
|
38
25
|
|
39
|
-
api :GET,
|
40
|
-
param :id, :identifier, desc:
|
41
|
-
def show
|
42
|
-
end
|
26
|
+
api :GET, '/tasks/:id', 'Show task details'
|
27
|
+
param :id, :identifier, desc: 'UUID of the task'
|
28
|
+
def show; end
|
43
29
|
|
44
|
-
api :POST,
|
30
|
+
api :POST, '/tasks/bulk_search', 'List dynflow tasks for uuids'
|
45
31
|
param :searches, Array, :desc => 'List of uuids to fetch info about' do
|
46
32
|
param :search_id, String, :desc => <<-DESC
|
47
33
|
Arbitraty value for client to identify the the request parts with results.
|
48
34
|
It's passed in the results to be able to pair the requests and responses properly.
|
49
35
|
DESC
|
50
|
-
param :type, %w
|
36
|
+
param :type, %w(user resource task)
|
51
37
|
param :task_id, String, :desc => <<-DESC
|
52
38
|
In case :type = 'task', find the task by the uuid
|
53
39
|
DESC
|
@@ -104,8 +90,8 @@ module ForemanTasks
|
|
104
90
|
if task.resumable?
|
105
91
|
begin
|
106
92
|
ForemanTasks.dynflow.world.execute(task.execution_plan.id)
|
107
|
-
resumed
|
108
|
-
rescue RuntimeError
|
93
|
+
resumed << task_hash(task)
|
94
|
+
rescue RuntimeError
|
109
95
|
failed << task_hash(task)
|
110
96
|
end
|
111
97
|
else
|
@@ -114,59 +100,58 @@ module ForemanTasks
|
|
114
100
|
end
|
115
101
|
|
116
102
|
render :json => {
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
103
|
+
total: resumed.length + failed.length + skipped.length,
|
104
|
+
resumed: resumed,
|
105
|
+
failed: failed,
|
106
|
+
skipped: skipped
|
107
|
+
}
|
122
108
|
end
|
123
109
|
|
124
|
-
api :GET, '/tasks', N_(
|
125
|
-
param :search, String, :desc => N_(
|
126
|
-
param :page, :number, :desc => N_(
|
127
|
-
param :per_page,
|
110
|
+
api :GET, '/tasks', N_('List tasks')
|
111
|
+
param :search, String, :desc => N_('Search string')
|
112
|
+
param :page, :number, :desc => N_('Page number, starting at 1')
|
113
|
+
param :per_page, :number, :desc => N_('Number of results per page to return')
|
128
114
|
param :order, String, :desc => N_("Sort field and order, e.g. 'name DESC'")
|
129
115
|
param :sort, Hash, :desc => N_("Hash version of 'order' param") do
|
130
|
-
param :by, String, :desc => N_(
|
131
|
-
param :order, String, :desc => N_(
|
116
|
+
param :by, String, :desc => N_('Field to sort the results on')
|
117
|
+
param :order, String, :desc => N_('How to order the sorted results (e.g. ASC for ascending)')
|
132
118
|
end
|
133
119
|
def index
|
134
|
-
scope =resource_scope.search_for(params[:search]).select('DISTINCT foreman_tasks_tasks.*')
|
120
|
+
scope = resource_scope.search_for(params[:search]).select('DISTINCT foreman_tasks_tasks.*')
|
135
121
|
total = scope.count
|
136
122
|
|
137
|
-
ordering_params =
|
138
|
-
|
139
|
-
|
140
|
-
|
123
|
+
ordering_params = {
|
124
|
+
sort_by: params[:sort_by] || 'started_at',
|
125
|
+
sort_order: params[:sort_order] || 'DESC'
|
126
|
+
}
|
141
127
|
scope = ordering_scope(scope, ordering_params)
|
142
128
|
|
143
|
-
|
144
129
|
pagination_params = {
|
145
|
-
|
146
|
-
|
147
|
-
|
130
|
+
page: params[:page] || 1,
|
131
|
+
per_page: params[:per_page] || 20
|
132
|
+
}
|
148
133
|
scope = pagination_scope(scope, pagination_params)
|
149
134
|
results = scope.map { |task| task_hash(task) }
|
150
135
|
|
151
136
|
render :json => {
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
137
|
+
total: total,
|
138
|
+
subtotal: results.count,
|
139
|
+
page: pagination_params[:page],
|
140
|
+
per_page: pagination_params[:per_page],
|
141
|
+
sort: {
|
142
|
+
by: ordering_params[:sort_by],
|
143
|
+
order: ordering_params[:sort_order]
|
144
|
+
},
|
145
|
+
results: results
|
146
|
+
}
|
162
147
|
end
|
163
148
|
|
164
|
-
api :POST, '/tasks/callback', N_(
|
149
|
+
api :POST, '/tasks/callback', N_('Send data to the task from external executor (such as smart_proxy_dynflow)')
|
165
150
|
param :callback, Hash do
|
166
|
-
param :task_id, :identifier, :desc => N_(
|
167
|
-
param :step_id, String, :desc => N_(
|
151
|
+
param :task_id, :identifier, :desc => N_('UUID of the task')
|
152
|
+
param :step_id, String, :desc => N_('The ID of the step inside the execution plan to send the event to')
|
168
153
|
end
|
169
|
-
param :data, Hash, :desc => N_(
|
154
|
+
param :data, Hash, :desc => N_('Data to be sent to the action')
|
170
155
|
def callback
|
171
156
|
task = ForemanTasks::Task::DynflowTask.find(params[:callback][:task_id])
|
172
157
|
ForemanTasks.dynflow.world.event(task.external_id,
|
@@ -193,7 +178,7 @@ module ForemanTasks
|
|
193
178
|
scope
|
194
179
|
when 'user'
|
195
180
|
if search_params[:user_id].blank?
|
196
|
-
raise BadRequest, _(
|
181
|
+
raise BadRequest, _('User search_params requires user_id to be specified')
|
197
182
|
end
|
198
183
|
scope.joins(:locks).where(foreman_tasks_locks:
|
199
184
|
{ name: ::ForemanTasks::Lock::OWNER_LOCK_NAME,
|
@@ -202,18 +187,18 @@ module ForemanTasks
|
|
202
187
|
when 'resource'
|
203
188
|
if search_params[:resource_type].blank? || search_params[:resource_id].blank?
|
204
189
|
raise BadRequest,
|
205
|
-
_(
|
190
|
+
_('Resource search_params requires resource_type and resource_id to be specified')
|
206
191
|
end
|
207
192
|
scope.joins(:locks).where(foreman_tasks_locks:
|
208
193
|
{ resource_type: search_params[:resource_type],
|
209
194
|
resource_id: search_params[:resource_id] })
|
210
195
|
when 'task'
|
211
196
|
if search_params[:task_id].blank?
|
212
|
-
raise BadRequest, _(
|
197
|
+
raise BadRequest, _('Task search_params requires task_id to be specified')
|
213
198
|
end
|
214
199
|
scope.where(id: search_params[:task_id])
|
215
200
|
else
|
216
|
-
raise BadRequest, _(
|
201
|
+
raise BadRequest, _('Type %s for search_params is not supported') % search_params[:type]
|
217
202
|
end
|
218
203
|
end
|
219
204
|
|
@@ -237,7 +222,7 @@ module ForemanTasks
|
|
237
222
|
def pagination_scope(scope, search_params)
|
238
223
|
page = search_params[:page] || 1
|
239
224
|
per_page = search_params[:per_page] || 10
|
240
|
-
scope
|
225
|
+
scope.limit(per_page).offset((page.to_i - 1) * per_page.to_i)
|
241
226
|
end
|
242
227
|
|
243
228
|
def ordering_scope(scope, ordering_params)
|
@@ -248,22 +233,21 @@ module ForemanTasks
|
|
248
233
|
|
249
234
|
def task_hash(task)
|
250
235
|
return @tasks[task.id] if @tasks && @tasks[task.id]
|
251
|
-
task_hash
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
236
|
+
task_hash = Rabl.render(
|
237
|
+
task, 'show',
|
238
|
+
view_path: "#{ForemanTasks::Engine.root}/app/views/foreman_tasks/api/tasks",
|
239
|
+
format: :hash,
|
240
|
+
scope: self
|
241
|
+
)
|
256
242
|
@tasks[task.id] = task_hash if @tasks
|
257
|
-
|
243
|
+
task_hash
|
258
244
|
end
|
259
245
|
|
260
|
-
private
|
261
|
-
|
262
246
|
def find_task
|
263
247
|
@task = Task.find(params[:id])
|
264
248
|
end
|
265
249
|
|
266
|
-
def resource_scope(
|
250
|
+
def resource_scope(_options = {})
|
267
251
|
@resource_scope ||= ForemanTasks::Task.authorized("#{action_permission}_foreman_tasks")
|
268
252
|
end
|
269
253
|
|
@@ -15,12 +15,10 @@ module ForemanTasks
|
|
15
15
|
params[:certname],
|
16
16
|
detected_proxy.try(:id))
|
17
17
|
|
18
|
-
render :json => {:task_id => task.id}, :status => 202
|
18
|
+
render :json => { :task_id => task.id }, :status => 202
|
19
19
|
rescue ::Foreman::Exception => e
|
20
|
-
render :json => {'message'=>e.to_s}, :status => :unprocessable_entity
|
20
|
+
render :json => { 'message' => e.to_s }, :status => :unprocessable_entity
|
21
21
|
end
|
22
|
-
|
23
22
|
end
|
24
23
|
end
|
25
24
|
end
|
26
|
-
|