foreman_remote_execution 1.3.0 → 1.3.1
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 +28 -2
- data/.rubocop_todo.yml +0 -7
- data/Gemfile +1 -1
- data/app/controllers/api/v2/foreign_input_sets_controller.rb +1 -2
- data/app/controllers/api/v2/job_invocations_controller.rb +2 -2
- data/app/controllers/api/v2/job_templates_controller.rb +2 -3
- data/app/controllers/api/v2/remote_execution_features_controller.rb +1 -2
- data/app/controllers/api/v2/template_inputs_controller.rb +1 -2
- data/app/controllers/concerns/foreman/controller/parameters/job_template.rb +3 -3
- data/app/controllers/concerns/foreman/controller/parameters/template_input.rb +2 -2
- data/app/controllers/job_invocations_controller.rb +4 -7
- data/app/controllers/job_templates_controller.rb +2 -2
- data/app/controllers/remote_execution_features_controller.rb +1 -2
- data/app/helpers/remote_execution_helper.rb +22 -17
- data/app/lib/actions/remote_execution/run_host_job.rb +4 -10
- data/app/models/concerns/foreman_remote_execution/host_extensions.rb +29 -1
- data/app/models/host_status/execution_status.rb +1 -1
- data/app/models/input_template_renderer.rb +1 -1
- data/app/models/job_invocation.rb +12 -7
- data/app/models/job_invocation_composer.rb +15 -6
- data/app/models/job_invocation_task_group.rb +1 -1
- data/app/models/job_template.rb +45 -29
- data/app/models/job_template_importer.rb +21 -9
- data/app/models/remote_execution_feature.rb +4 -4
- data/app/models/setting/remote_execution.rb +7 -5
- data/app/models/ssh_execution_provider.rb +1 -3
- data/app/models/targeting.rb +6 -5
- data/app/models/template_invocation.rb +43 -1
- data/app/views/job_invocations/_form.html.erb +1 -1
- data/app/views/job_invocations/_tab_overview.html.erb +10 -1
- data/config/routes.rb +2 -2
- data/db/migrate/20150903192731_add_execution_to_interface.rb +6 -6
- data/db/migrate/20151215114631_add_host_id_to_template_invocation.rb +3 -2
- data/db/migrate/20160114120200_rename_job_categories.rb +1 -1
- data/db/migrate/20160127134031_add_advanced_to_template_input.rb +1 -1
- data/db/seeds.d/70-job_templates.rb +1 -1
- data/db/seeds.d/90-bookmarks.rb +1 -1
- data/doc/Gemfile +1 -1
- data/lib/foreman_remote_execution/engine.rb +1 -1
- data/lib/foreman_remote_execution/version.rb +1 -1
- data/lib/tasks/foreman_remote_execution_tasks.rake +1 -1
- data/locale/action_names.rb +1 -1
- data/locale/de/LC_MESSAGES/foreman_remote_execution.mo +0 -0
- data/locale/de/foreman_remote_execution.po +39 -12
- data/locale/en/foreman_remote_execution.po +38 -11
- data/locale/en_GB/foreman_remote_execution.po +38 -11
- data/locale/es/LC_MESSAGES/foreman_remote_execution.mo +0 -0
- data/locale/es/foreman_remote_execution.po +39 -12
- data/locale/foreman_remote_execution.pot +175 -141
- data/locale/fr/LC_MESSAGES/foreman_remote_execution.mo +0 -0
- data/locale/fr/foreman_remote_execution.po +39 -12
- data/locale/ja/LC_MESSAGES/foreman_remote_execution.mo +0 -0
- data/locale/ja/foreman_remote_execution.po +39 -12
- data/locale/ko/LC_MESSAGES/foreman_remote_execution.mo +0 -0
- data/locale/ko/foreman_remote_execution.po +39 -12
- data/locale/pt_BR/LC_MESSAGES/foreman_remote_execution.mo +0 -0
- data/locale/pt_BR/foreman_remote_execution.po +39 -12
- data/locale/ru/LC_MESSAGES/foreman_remote_execution.mo +0 -0
- data/locale/ru/foreman_remote_execution.po +39 -12
- data/locale/zh_CN/LC_MESSAGES/foreman_remote_execution.mo +0 -0
- data/locale/zh_CN/foreman_remote_execution.po +39 -12
- data/locale/zh_TW/LC_MESSAGES/foreman_remote_execution.mo +0 -0
- data/locale/zh_TW/foreman_remote_execution.po +39 -12
- data/test/benchmark/run_hosts_job_benchmark.rb +2 -2
- data/test/benchmark/targeting_benchmark.rb +2 -2
- data/test/factories/foreman_remote_execution_factories.rb +27 -2
- data/test/functional/api/v2/job_templates_controller_test.rb +1 -1
- data/test/test_plugin_helper.rb +2 -19
- data/test/unit/concerns/host_extensions_test.rb +54 -5
- data/test/unit/concerns/nic_extensions_test.rb +1 -1
- data/test/unit/execution_task_status_mapper_test.rb +1 -2
- data/test/unit/input_template_renderer_test.rb +1 -1
- data/test/unit/job_invocation_composer_test.rb +21 -29
- data/test/unit/job_invocation_test.rb +1 -2
- data/test/unit/job_template_effective_user_test.rb +1 -1
- data/test/unit/job_template_importer_test.rb +38 -20
- data/test/unit/job_template_test.rb +8 -8
- data/test/unit/remote_execution_feature_test.rb +6 -6
- data/test/unit/remote_execution_provider_test.rb +2 -1
- data/test/unit/targeting_test.rb +6 -6
- data/test/unit/template_input_test.rb +1 -1
- data/test/unit/template_invocation_input_value_test.rb +3 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e4de9b6ef4385fb25d736b6e2a3c79ad3d6240e6
|
4
|
+
data.tar.gz: de38d2967d75a10fa0d759d1927eb5a637c9a73a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91604a14604487b8d821e4e81991402c281c0cc342105de1b124bc4c4be18809414f54b9da28c92774c5bb5663c190c7775ed1d76341f5b2ce36e41388d5f7e4
|
7
|
+
data.tar.gz: 67cfafed4dc9d8a204d478781c227937a657a0134630739bb4670744c3c505f26b1d97e9777e9b9ed7e046729faa9ef8ce4f7f1a5e1dba3224be110876babbdf
|
data/.rubocop.yml
CHANGED
@@ -2,13 +2,18 @@ inherit_from:
|
|
2
2
|
- .rubocop_todo.yml
|
3
3
|
|
4
4
|
AllCops:
|
5
|
-
RunRailsCops: true # always run the rails cops
|
6
5
|
Exclude:
|
7
6
|
- 'doc/plugins/**'
|
8
7
|
|
8
|
+
Rails:
|
9
|
+
Enabled: true
|
10
|
+
|
9
11
|
Rails/Date:
|
10
12
|
Enabled: false
|
11
13
|
|
14
|
+
Rails/HttpPositionalArguments:
|
15
|
+
Enabled: false
|
16
|
+
|
12
17
|
# Don't enforce documentation
|
13
18
|
Style/Documentation:
|
14
19
|
Enabled: false
|
@@ -20,9 +25,12 @@ Rails/ActionFilter:
|
|
20
25
|
Metrics/MethodLength:
|
21
26
|
Max: 40
|
22
27
|
|
23
|
-
Style/
|
28
|
+
Style/TrailingCommaInLiteral:
|
24
29
|
Enabled: false
|
25
30
|
|
31
|
+
#Style/TrailingCommaInArguments:
|
32
|
+
#Enabled: false
|
33
|
+
|
26
34
|
Style/AccessorMethodName:
|
27
35
|
Enabled: false
|
28
36
|
|
@@ -31,6 +39,8 @@ Style/RedundantSelf:
|
|
31
39
|
|
32
40
|
Metrics/ClassLength:
|
33
41
|
Max: 500
|
42
|
+
Exclude:
|
43
|
+
- 'test/**/*'
|
34
44
|
|
35
45
|
Style/FileName:
|
36
46
|
Exclude:
|
@@ -51,5 +61,21 @@ Style/ClassAndModuleChildren:
|
|
51
61
|
Style/EachWithObject:
|
52
62
|
Enabled: false
|
53
63
|
|
64
|
+
Style/GuardClause:
|
65
|
+
Enabled: false
|
66
|
+
|
67
|
+
Metrics/BlockLength:
|
68
|
+
Exclude:
|
69
|
+
- 'config/routes.rb'
|
70
|
+
- 'lib/foreman_remote_execution/engine.rb'
|
71
|
+
- 'test/**/*'
|
72
|
+
|
54
73
|
Metrics/ParameterLists:
|
55
74
|
Enabled: false
|
75
|
+
|
76
|
+
Style/VariableNumber:
|
77
|
+
Enabled: false
|
78
|
+
|
79
|
+
# a == 0 is not the same as a.zero?, when a is not a number
|
80
|
+
Style/NumericPredicate:
|
81
|
+
Enabled: false
|
data/.rubocop_todo.yml
CHANGED
@@ -39,13 +39,6 @@ Metrics/LineLength:
|
|
39
39
|
Metrics/PerceivedComplexity:
|
40
40
|
Max: 8
|
41
41
|
|
42
|
-
# Offense count: 2
|
43
|
-
# Configuration parameters: Include.
|
44
|
-
Rails/DefaultScope:
|
45
|
-
Exclude:
|
46
|
-
- 'app/models/job_invocation.rb'
|
47
|
-
- 'app/models/job_template.rb'
|
48
|
-
|
49
42
|
# Offense count: 2
|
50
43
|
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
51
44
|
Rails/TimeZone:
|
data/Gemfile
CHANGED
@@ -18,8 +18,7 @@ module Api
|
|
18
18
|
api :GET, '/templates/:template_id/foreign_input_sets/:id', N_('Show foreign input set details')
|
19
19
|
param :template_id, :identifier, :required => true
|
20
20
|
param :id, :identifier, :required => true
|
21
|
-
def show
|
22
|
-
end
|
21
|
+
def show; end
|
23
22
|
|
24
23
|
def_param_group :foreign_input_set do
|
25
24
|
param :foreign_input_set, Hash, :required => true, :action_aware => true do
|
@@ -20,9 +20,9 @@ module Api
|
|
20
20
|
|
21
21
|
api :GET, '/job_invocations/:id', N_('Show job invocation')
|
22
22
|
param :id, :identifier, :required => true
|
23
|
-
def show
|
24
|
-
end
|
23
|
+
def show; end
|
25
24
|
|
25
|
+
# rubocop:disable Metrics/BlockLength
|
26
26
|
def_param_group :job_invocation do
|
27
27
|
param :job_invocation, Hash, :required => true, :action_aware => true do
|
28
28
|
param :job_template_id, String, :required => true, :desc => N_('The job template to use')
|
@@ -29,7 +29,7 @@ module Api
|
|
29
29
|
def import
|
30
30
|
options = params[:overwrite] ? { :update => true } : { :build_new => true }
|
31
31
|
|
32
|
-
@job_template = JobTemplate.
|
32
|
+
@job_template = JobTemplate.import_raw(params[:template], options)
|
33
33
|
@job_template ||= JobTemplate.new
|
34
34
|
process_response @job_template.save
|
35
35
|
end
|
@@ -43,8 +43,7 @@ module Api
|
|
43
43
|
|
44
44
|
api :GET, '/job_templates/:id', N_('Show job template details')
|
45
45
|
param :id, :identifier, :required => true
|
46
|
-
def show
|
47
|
-
end
|
46
|
+
def show; end
|
48
47
|
|
49
48
|
def_param_group :job_template do
|
50
49
|
param :job_template, Hash, :required => true, :action_aware => true do
|
@@ -13,8 +13,7 @@ module Api
|
|
13
13
|
|
14
14
|
api :GET, '/remote_execution_features/:id', N_('Show remote execution feature')
|
15
15
|
param :id, :identifier, :required => true
|
16
|
-
def show
|
17
|
-
end
|
16
|
+
def show; end
|
18
17
|
|
19
18
|
def_param_group :remote_execution_feature do
|
20
19
|
param :remote_execution_feature, Hash, :required => true, :action_aware => true do
|
@@ -19,8 +19,7 @@ module Api
|
|
19
19
|
api :GET, '/templates/:template_id/template_inputs/:id', N_('Show template input details')
|
20
20
|
param :template_id, :identifier, :required => true
|
21
21
|
param :id, :identifier, :required => true
|
22
|
-
def show
|
23
|
-
end
|
22
|
+
def show; end
|
24
23
|
|
25
24
|
def_param_group :template_input do
|
26
25
|
param :template_input, Hash, :required => true, :action_aware => true do
|
@@ -16,9 +16,9 @@ module Foreman::Controller::Parameters::JobTemplate
|
|
16
16
|
def job_template_params_filter
|
17
17
|
Foreman::ParameterFilter.new(::TemplateInput).tap do |filter|
|
18
18
|
filter.permit :job_category, :provider_type, :description_format,
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
:effective_user_attributes => [job_template_effective_user_filter],
|
20
|
+
:template_inputs_attributes => [template_input_params_filter],
|
21
|
+
:foreign_input_sets_attributes => [foreign_input_set_params_filter]
|
22
22
|
add_template_params_filter(filter)
|
23
23
|
add_taxonomix_params_filter(filter)
|
24
24
|
end
|
@@ -5,8 +5,8 @@ module Foreman::Controller::Parameters::TemplateInput
|
|
5
5
|
def template_input_params_filter
|
6
6
|
Foreman::ParameterFilter.new(::TemplateInput).tap do |filter|
|
7
7
|
filter.permit_by_context :id, :_destroy, :name, :required, :input_type, :fact_name,
|
8
|
-
|
9
|
-
|
8
|
+
:variable_name, :puppet_class_name, :puppet_parameter_name, :description, :template_id,
|
9
|
+
:options, :advanced, :nested => true
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
@@ -11,7 +11,7 @@ class JobInvocationsController < ApplicationController
|
|
11
11
|
}
|
12
12
|
}
|
13
13
|
|
14
|
-
if (template = JobTemplate.
|
14
|
+
if (template = JobTemplate.find_by(id: params[:template_id]))
|
15
15
|
ui_params[:job_invocation] = {
|
16
16
|
:job_category => template.job_category,
|
17
17
|
:providers => {
|
@@ -25,12 +25,7 @@ class JobInvocationsController < ApplicationController
|
|
25
25
|
|
26
26
|
def rerun
|
27
27
|
job_invocation = resource_base.find(params[:id])
|
28
|
-
@composer = JobInvocationComposer.from_job_invocation(job_invocation)
|
29
|
-
if params[:failed_only]
|
30
|
-
host_ids = job_invocation.failed_host_ids
|
31
|
-
@composer.search_query = Targeting.build_query_from_hosts(host_ids)
|
32
|
-
end
|
33
|
-
|
28
|
+
@composer = JobInvocationComposer.from_job_invocation(job_invocation, params)
|
34
29
|
render :action => 'new'
|
35
30
|
end
|
36
31
|
|
@@ -48,6 +43,8 @@ class JobInvocationsController < ApplicationController
|
|
48
43
|
@job_invocation = resource_base.includes(:template_invocations => :run_host_job_task).find(params[:id])
|
49
44
|
@auto_refresh = @job_invocation.task.try(:pending?)
|
50
45
|
hosts_base = @job_invocation.targeting.hosts.authorized(:view_hosts, Host)
|
46
|
+
.joins(:template_invocations)
|
47
|
+
.merge(TemplateInvocation.where(:job_invocation_id => @job_invocation.id))
|
51
48
|
@hosts = hosts_base.search_for(params[:search], :order => params[:order] || 'name ASC').paginate(:page => params[:page])
|
52
49
|
end
|
53
50
|
|
@@ -29,12 +29,12 @@ class JobTemplatesController < ::TemplatesController
|
|
29
29
|
def import
|
30
30
|
contents = params.fetch(:imported_template, {}).fetch(:template, nil).try(:read)
|
31
31
|
|
32
|
-
@template = JobTemplate.
|
32
|
+
@template = JobTemplate.import_raw(contents, :update => Foreman::Cast.to_bool(params[:imported_template][:overwrite]))
|
33
33
|
if @template && @template.save
|
34
34
|
flash[:notice] = _('Job template imported successfully.')
|
35
35
|
redirect_to job_templates_path(:search => "name = \"#{@template.name}\"")
|
36
36
|
else
|
37
|
-
@template ||= JobTemplate.
|
37
|
+
@template ||= JobTemplate.import_raw(contents, :build_new => true)
|
38
38
|
@template.valid?
|
39
39
|
flash[:warning] = _('Unable to save template. Correct highlighted errors')
|
40
40
|
render :action => 'new'
|
@@ -11,7 +11,7 @@ module RemoteExecutionHelper
|
|
11
11
|
def job_invocation_chart(invocation)
|
12
12
|
options = { :class => 'statistics-pie small', :expandable => true, :border => 0, :show_title => true }
|
13
13
|
|
14
|
-
if
|
14
|
+
if invocation.task
|
15
15
|
# Request precise subtask counts only if the task is stopped
|
16
16
|
report = invocation.progress_report
|
17
17
|
flot_pie_chart('status', job_invocation_status(invocation, report[:progress]),
|
@@ -29,10 +29,14 @@ module RemoteExecutionHelper
|
|
29
29
|
@job_hosts_authorizer ||= Authorizer.new(User.current, :collection => @hosts)
|
30
30
|
end
|
31
31
|
|
32
|
-
def job_invocation_status(invocation, percent = nil)
|
32
|
+
def job_invocation_status(invocation, percent = nil, verbose = true)
|
33
33
|
case invocation.status
|
34
34
|
when HostStatus::ExecutionStatus::QUEUED
|
35
|
-
|
35
|
+
if verbose && invocation.task
|
36
|
+
_('queued to start executing in %{time}') % {:time => time_ago_in_words(invocation.task.start_at) }
|
37
|
+
else
|
38
|
+
_('queued')
|
39
|
+
end
|
36
40
|
when HostStatus::ExecutionStatus::RUNNING
|
37
41
|
percent ||= invocation.progress_report[:progress]
|
38
42
|
_('running %{percent}%%') % {:percent => percent}
|
@@ -141,8 +145,9 @@ module RemoteExecutionHelper
|
|
141
145
|
end
|
142
146
|
|
143
147
|
def link_to_invocation_task_if_authorized(invocation)
|
148
|
+
status = job_invocation_status(invocation, nil, false)
|
144
149
|
if invocation.queued?
|
145
|
-
|
150
|
+
status
|
146
151
|
else
|
147
152
|
task_authorizer = Authorizer.new(User.current, :collection => [invocation.task])
|
148
153
|
link_to_if_authorized job_invocation_status(invocation),
|
@@ -166,7 +171,7 @@ module RemoteExecutionHelper
|
|
166
171
|
|
167
172
|
def invocation_result(invocation, key)
|
168
173
|
unknown = '—'
|
169
|
-
result = invocation_count(invocation, :output_key => key, :unknown_string => unknown.html_safe)
|
174
|
+
result = invocation_count(invocation, :output_key => key, :unknown_string => unknown.html_safe) # rubocop:disable Rails/OutputSafety
|
170
175
|
label = key == :failed_count ? 'danger' : 'info'
|
171
176
|
result == unknown ? result : report_event_column(result, "label-#{label}")
|
172
177
|
end
|
@@ -175,15 +180,13 @@ module RemoteExecutionHelper
|
|
175
180
|
renderer = InputTemplateRenderer.new(template_invocation.template, target, template_invocation)
|
176
181
|
if (preview = renderer.preview)
|
177
182
|
content_tag :pre, preview
|
183
|
+
elsif target.nil?
|
184
|
+
alert :text => _('Could not render the preview because no host matches the search query.'),
|
185
|
+
:class => 'alert alert-block alert-warning base',
|
186
|
+
:close => false
|
178
187
|
else
|
179
|
-
|
180
|
-
|
181
|
-
:class => 'alert alert-block alert-warning base',
|
182
|
-
:close => false
|
183
|
-
else
|
184
|
-
alert :class => 'alert-block alert-danger base in fade has-error',
|
185
|
-
:text => renderer.error_message.html_safe
|
186
|
-
end
|
188
|
+
alert :class => 'alert-block alert-danger base in fade has-error',
|
189
|
+
:text => renderer.error_message.html_safe # rubocop:disable Rails/OutputSafety
|
187
190
|
end
|
188
191
|
end
|
189
192
|
|
@@ -215,9 +218,11 @@ module RemoteExecutionHelper
|
|
215
218
|
|
216
219
|
def template_input_header(f, template)
|
217
220
|
header = _('Template input')
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
+
unless template.locked?
|
222
|
+
header += ' ' + remove_child_link('x', f, {:rel => 'twipsy', :'data-title' => _('remove template input'), :'data-placement' => 'left',
|
223
|
+
:class => 'fr badge badge-danger'})
|
224
|
+
end
|
225
|
+
header.html_safe # rubocop:disable Rails/OutputSafety
|
221
226
|
end
|
222
227
|
|
223
228
|
def description_checkbox_f(f, job_template, disabled)
|
@@ -245,7 +250,7 @@ module RemoteExecutionHelper
|
|
245
250
|
_('This template is used to generate the description.<br/>' +
|
246
251
|
'Input values can be used using the syntax %{package}.<br/>' +
|
247
252
|
'You may also include the job category and template<br/>' +
|
248
|
-
'name using %{job_category} and %{template_name}.').html_safe
|
253
|
+
'name using %{job_category} and %{template_name}.').html_safe # rubocop:disable Rails/OutputSafety
|
249
254
|
end
|
250
255
|
|
251
256
|
def advanced_switch_f(default_text, switch_text)
|
@@ -10,6 +10,7 @@ module Actions
|
|
10
10
|
:link
|
11
11
|
end
|
12
12
|
|
13
|
+
# rubocop:disable Metrics/AbcSize
|
13
14
|
def plan(job_invocation, host, template_invocation, proxy_selector = ::RemoteExecutionProxySelector.new, options = {})
|
14
15
|
action_subject(host, :job_category => job_invocation.job_category, :description => job_invocation.description)
|
15
16
|
|
@@ -57,9 +58,7 @@ module Actions
|
|
57
58
|
end
|
58
59
|
|
59
60
|
def check_exit_status
|
60
|
-
if
|
61
|
-
error! _('Playbook execution failed')
|
62
|
-
end
|
61
|
+
error! _('Job execution failed') if exit_status.to_s != '0'
|
63
62
|
end
|
64
63
|
|
65
64
|
def live_output
|
@@ -76,12 +75,6 @@ module Actions
|
|
76
75
|
N_('Remote action:')
|
77
76
|
end
|
78
77
|
|
79
|
-
def finalize
|
80
|
-
if exit_status.to_s != '0'
|
81
|
-
error! _('Job execution failed')
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
78
|
def rescue_strategy
|
86
79
|
::Dynflow::Action::Rescue::Fail
|
87
80
|
end
|
@@ -120,7 +113,8 @@ module Actions
|
|
120
113
|
super
|
121
114
|
elsif phase?(Present)
|
122
115
|
# for compatibility with old actions
|
123
|
-
|
116
|
+
old_action = all_planned_actions.first
|
117
|
+
if old_action
|
124
118
|
old_action.output.fetch('proxy_output', {})
|
125
119
|
else
|
126
120
|
{}
|
@@ -2,6 +2,7 @@ module ForemanRemoteExecution
|
|
2
2
|
module HostExtensions
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
|
+
# rubocop:disable Metrics/BlockLength
|
5
6
|
included do
|
6
7
|
alias_method_chain :build_required_interfaces, :remote_execution
|
7
8
|
alias_method_chain :reload, :remote_execution
|
@@ -11,10 +12,36 @@ module ForemanRemoteExecution
|
|
11
12
|
has_many :targeting_hosts, :dependent => :destroy, :foreign_key => 'host_id'
|
12
13
|
has_many :template_invocations, :dependent => :destroy, :foreign_key => 'host_id'
|
13
14
|
has_one :execution_status_object, :class_name => 'HostStatus::ExecutionStatus', :foreign_key => 'host_id'
|
15
|
+
has_many :run_host_job_tasks, :through => :template_invocations
|
16
|
+
|
17
|
+
scoped_search :relation => :run_host_job_tasks, :on => :result, :rename => 'job_invocation.result',
|
18
|
+
:ext_method => :search_by_job_invocation,
|
19
|
+
:only_explicit => true,
|
20
|
+
:complete_value => TemplateInvocation::TaskResultMap::REVERSE_MAP
|
21
|
+
|
22
|
+
scoped_search :relation => :template_invocations, :on => :job_invocation_id,
|
23
|
+
:rename => 'job_invocation.id', :only_explicit => true, :ext_method => :search_by_job_invocation
|
14
24
|
|
15
25
|
scoped_search :in => :execution_status_object, :on => :status, :rename => :execution_status,
|
16
26
|
:complete_value => { :ok => HostStatus::ExecutionStatus::OK, :error => HostStatus::ExecutionStatus::ERROR }
|
27
|
+
|
28
|
+
def self.search_by_job_invocation(key, operator, value)
|
29
|
+
if key == 'job_invocation.result'
|
30
|
+
operator = operator == '=' ? 'IN' : 'NOT IN'
|
31
|
+
value = TemplateInvocation::TaskResultMap.status_to_task_result(value)
|
32
|
+
end
|
33
|
+
|
34
|
+
mapping = {
|
35
|
+
'job_invocation.id' => %(#{TemplateInvocation.table_name}.job_invocation_id #{operator} ?),
|
36
|
+
'job_invocation.result' => %(#{ForemanTasks::Task.table_name}.result #{operator} (?))
|
37
|
+
}
|
38
|
+
{
|
39
|
+
:conditions => sanitize_sql_for_conditions([mapping[key], value_to_sql(operator, value)]),
|
40
|
+
:joins => { :template_invocations => [:run_host_job_task] }
|
41
|
+
}
|
42
|
+
end
|
17
43
|
end
|
44
|
+
# rubocop:enable Metrics/BlockLength
|
18
45
|
|
19
46
|
def execution_status(options = {})
|
20
47
|
@execution_status ||= get_status(HostStatus::ExecutionStatus).to_status(options)
|
@@ -39,6 +66,7 @@ module ForemanRemoteExecution
|
|
39
66
|
get_interface_by_flag(:execution)
|
40
67
|
end
|
41
68
|
|
69
|
+
# rubocop:disable Metrics/PerceivedComplexity
|
42
70
|
def remote_execution_proxies(provider, authorized = true)
|
43
71
|
proxies = {}
|
44
72
|
proxies[:subnet] = execution_interface.subnet.remote_execution_proxies.with_features(provider) if execution_interface && execution_interface.subnet
|
@@ -48,7 +76,7 @@ module ForemanRemoteExecution
|
|
48
76
|
proxy_scope = if Taxonomy.enabled_taxonomies.any? && User.current.present?
|
49
77
|
::SmartProxy.with_taxonomy_scope_override(location, organization)
|
50
78
|
else
|
51
|
-
|
79
|
+
::SmartProxy.unscoped
|
52
80
|
end
|
53
81
|
|
54
82
|
proxy_scope = proxy_scope.authorized if authorized
|
@@ -8,7 +8,7 @@ class HostStatus::ExecutionStatus < HostStatus::Status
|
|
8
8
|
# execution is in progress, dynflow task was created
|
9
9
|
RUNNING = 3
|
10
10
|
# mapping to string representation
|
11
|
-
STATUS_NAMES = { OK => 'succeeded', ERROR => 'failed', QUEUED => 'queued', RUNNING => 'running' }
|
11
|
+
STATUS_NAMES = { OK => 'succeeded', ERROR => 'failed', QUEUED => 'queued', RUNNING => 'running' }.freeze
|
12
12
|
|
13
13
|
def relevant?(*args)
|
14
14
|
execution_tasks.present?
|
@@ -42,7 +42,7 @@ class InputTemplateRenderer
|
|
42
42
|
|
43
43
|
def input(name)
|
44
44
|
return @input_values[name.to_s] if @input_values
|
45
|
-
input = find_by_name(@template.template_inputs_with_foreign, name)
|
45
|
+
input = find_by_name(@template.template_inputs_with_foreign, name) # rubocop:disable Rails/DynamicFindBy
|
46
46
|
if input
|
47
47
|
@preview ? input.preview(self) : input.value(self)
|
48
48
|
else
|