foreman_remote_execution 16.0.4 → 16.1.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.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/api/v2/job_invocations_controller.rb +33 -6
  3. data/app/controllers/job_invocations_controller.rb +28 -1
  4. data/app/controllers/template_invocations_controller.rb +1 -1
  5. data/app/helpers/remote_execution_helper.rb +1 -1
  6. data/config/routes.rb +4 -2
  7. data/lib/foreman_remote_execution/engine.rb +9 -256
  8. data/lib/foreman_remote_execution/plugin.rb +240 -0
  9. data/lib/foreman_remote_execution/version.rb +1 -1
  10. data/test/functional/api/v2/job_invocations_controller_test.rb +1 -1
  11. data/test/unit/job_invocation_report_template_test.rb +6 -6
  12. data/webpack/JobInvocationDetail/CheckboxesActions.js +327 -0
  13. data/webpack/JobInvocationDetail/{JobInvocationHostTableToolbar.js → DropdownFilter.js} +3 -6
  14. data/webpack/JobInvocationDetail/JobInvocationConstants.js +8 -9
  15. data/webpack/JobInvocationDetail/JobInvocationDetail.scss +18 -0
  16. data/webpack/JobInvocationDetail/JobInvocationHostTable.js +205 -89
  17. data/webpack/JobInvocationDetail/JobInvocationSelectors.js +30 -3
  18. data/webpack/JobInvocationDetail/JobInvocationToolbarButtons.js +23 -28
  19. data/webpack/JobInvocationDetail/OpenAllInvocationsModal.js +118 -0
  20. data/webpack/JobInvocationDetail/TemplateInvocation.js +54 -24
  21. data/webpack/JobInvocationDetail/TemplateInvocationComponents/TemplateActionButtons.js +8 -10
  22. data/webpack/JobInvocationDetail/TemplateInvocationPage.js +1 -1
  23. data/webpack/JobInvocationDetail/__tests__/MainInformation.test.js +2 -4
  24. data/webpack/JobInvocationDetail/__tests__/TableToolbarActions.test.js +204 -0
  25. data/webpack/JobInvocationDetail/__tests__/TemplateInvocation.test.js +34 -28
  26. data/webpack/JobInvocationDetail/index.js +71 -41
  27. data/webpack/JobWizard/steps/HostsAndInputs/buildHostQuery.js +26 -7
  28. data/webpack/Routes/routes.js +1 -1
  29. data/webpack/react_app/components/TargetingHosts/TargetingHostsLabelsRow.scss +1 -1
  30. metadata +8 -6
  31. data/webpack/JobInvocationDetail/OpenAlInvocations.js +0 -111
  32. data/webpack/JobInvocationDetail/__tests__/OpenAlInvocations.test.js +0 -110
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 263ac53880d0a4d4673659013457388598c58706f452a8f6db7c94df017ac634
4
- data.tar.gz: c7806ab71384b036d0ce50e2f8b55c0f9c13095fcfc455dd8057d28fabc74682
3
+ metadata.gz: 8150a0940b1cf9352e24f99f5083c36fb7bf42aefdfd99406eaeb191c109ec55
4
+ data.tar.gz: 673400df79bdee44cb8eccbcb72ce654963dca2f1e94f015d8ffcbdcb625a710
5
5
  SHA512:
6
- metadata.gz: 8c20ef4f8c84e5b57e3b1562dba4191d3552269d327de0ce51e7dd9d737db87a3e15a390abb60003568035e168adf2e3f3053fdbaf3f36a3f0e3282941081008
7
- data.tar.gz: 33c31c42d97a26a67331097c545e731c3b44a4430e6c8a2ce26f516b4296db78908639ab410b5959128f182d58d05681d4fc46e495c95c6cce120b2a2ff25e80
6
+ metadata.gz: f812d26367d5f24535531150d58aa224967f47db0651b6de2bb267ba5d037608665ec380e5b3d96003796a81f3b9f4c376d2e7de4365bdca4719ea012828a98b
7
+ data.tar.gz: 102ef1de3d1f874fb70ac04cde6fb1f91ecb4980198c25d29afb23a9e3f3e28a2b98ec5e1bbb69a7271e3639a31277e4dd1828848c322fc0989e69c4e263c17a
@@ -134,16 +134,43 @@ module Api
134
134
  render :json => host_output(@nested_obj, @host, :raw => true)
135
135
  end
136
136
 
137
- api :POST, '/job_invocations/:id/cancel', N_('Cancel job invocation')
137
+ api :POST, '/job_invocations/:id/cancel', N_('Cancel job invocation or matching tasks only')
138
138
  param :id, :identifier, :required => true
139
139
  param :force, :bool
140
+ param :search, String, :desc => N_('Search query to cancel tasks only on matching hosts. If not provided, the whole job invocation will be cancelled.')
140
141
  def cancel
141
- if @job_invocation.task.cancellable?
142
- result = @job_invocation.cancel(params.fetch('force', false))
143
- render :json => { :cancelled => result, :id => @job_invocation.id }
142
+ force = params.fetch('force', false)
143
+ search = params[:search]
144
+
145
+ if search.present?
146
+ begin
147
+ hosts_scope = @job_invocation.targeting.hosts.authorized(:view_hosts, Host)
148
+ matching_hosts = hosts_scope.search_for(search)
149
+ tasks_to_process = @job_invocation.template_invocations
150
+ .where(host_id: matching_hosts.select(:id))
151
+ .includes(:run_host_job_task)
152
+
153
+ cancelled, skipped = tasks_to_process.partition { |ti| ti.run_host_job_task&.cancellable? }
154
+ cancelled.each do |ti|
155
+ if force
156
+ ti.run_host_job_task.abort
157
+ else
158
+ ti.run_host_job_task.cancel
159
+ end
160
+ end
161
+ render json: {
162
+ total: tasks_to_process.size,
163
+ cancelled: cancelled.map(&:run_host_job_task_id),
164
+ skipped: skipped.map(&:run_host_job_task_id),
165
+ }
166
+ rescue StandardError => e
167
+ render json: { error: { message: "Failed to cancel tasks on hosts: #{e.message}" } }, status: :unprocessable_entity
168
+ end
169
+ elsif @job_invocation.task.cancellable?
170
+ result = @job_invocation.cancel(force)
171
+ render json: { cancelled: result, id: @job_invocation.id }
144
172
  else
145
- render :json => { :message => _('The job could not be cancelled.') },
146
- :status => :unprocessable_entity
173
+ render json: { message: _('The job could not be cancelled.') }, status: :unprocessable_entity
147
174
  end
148
175
  end
149
176
 
@@ -149,6 +149,33 @@ class JobInvocationsController < ApplicationController
149
149
  render :json => {:job_invocations => job_invocations}
150
150
  end
151
151
 
152
+ def list_jobs_hosts
153
+ @job_invocation = resource_base.find(params[:id])
154
+ hosts = @job_invocation.targeting.hosts.authorized(:view_hosts, Host)
155
+ hosts = hosts.search_for(params[:search])
156
+ template_invocations_task_by_hosts = {}
157
+ hosts.each do |host|
158
+ template_invocation = @job_invocation.template_invocations.find { |template_inv| template_inv.host_id == host.id }
159
+ next unless template_invocation
160
+ template_invocation_task = template_invocation.run_host_job_task
161
+ template_invocations_task_by_hosts[host.id] =
162
+ {
163
+ :host_name => host.name,
164
+ :id => host.id,
165
+ :task => template_invocation_task.attributes.merge({cancellable: template_invocation_task.cancellable? }),
166
+ :permissions => {
167
+ :view_foreman_tasks => authorized_for(:permission => :view_foreman_tasks, :auth_object => template_invocation_task),
168
+ :cancel_job_invocations => authorized_for(:permission => :cancel_job_invocations, :auth_object => @job_invocation),
169
+ :execute_jobs => authorized_for(controller: :job_invocations, action: :create) && (!host.infrastructure_host? || User.current.can?(:execute_jobs_on_infrastructure_hosts)),
170
+ },
171
+ }
172
+ end
173
+
174
+ render json: {
175
+ :template_invocations_task_by_hosts => template_invocations_task_by_hosts,
176
+ }
177
+ end
178
+
152
179
  private
153
180
 
154
181
  def action_permission
@@ -159,7 +186,7 @@ class JobInvocationsController < ApplicationController
159
186
  'create'
160
187
  when 'cancel'
161
188
  'cancel'
162
- when 'chart', 'preview_job_invocations_per_host'
189
+ when 'chart', 'preview_job_invocations_per_host', 'list_jobs_hosts'
163
190
  'view'
164
191
  else
165
192
  super
@@ -48,7 +48,7 @@ class TemplateInvocationsController < ApplicationController
48
48
 
49
49
  auto_refresh = @job_invocation.task.try(:pending?)
50
50
  finished = @job_invocation.status_label == 'failed' || @job_invocation.status_label == 'succeeded' || @job_invocation.status_label == 'cancelled'
51
- render :json => { :output => lines, :preview => template_invocation_preview(@template_invocation, @host), :proxy => proxy, :input_values => transformed_input_values, :job_invocation_description => @job_invocation.description, :task_id => @template_invocation_task.id, :task_cancellable => @template_invocation_task.cancellable?, :host_name => @host.name, :permissions => {
51
+ render :json => { :output => lines, :preview => template_invocation_preview(@template_invocation, @host), :proxy => proxy, :input_values => transformed_input_values, :job_invocation_description => @job_invocation.description, :task => @template_invocation_task.attributes.merge({cancellable: @template_invocation_task.cancellable? }), :host_name => @host.name, :permissions => {
52
52
  :view_foreman_tasks => User.current.allowed_to?(:view_foreman_tasks),
53
53
  :cancel_job_invocations => User.current.allowed_to?(:cancel_job_invocations),
54
54
  :execute_jobs => User.current.allowed_to?(:create_job_invocations) && (!@host.infrastructure_host? || User.current.can?(:execute_jobs_on_infrastructure_hosts)),
@@ -99,7 +99,7 @@ module RemoteExecutionHelper
99
99
  :disabled => !task.cancellable?,
100
100
  :method => :post)
101
101
  end
102
- buttons << link_to(_('New UI'), new_job_invocation_detail_path(:id => job_invocation.id),
102
+ buttons << link_to(_('New UI'), job_invocation_path(:id => job_invocation.id),
103
103
  class: 'btn btn-default',
104
104
  title: _('Switch to the new job invocation detail UI'))
105
105
 
data/config/routes.rb CHANGED
@@ -22,11 +22,12 @@ Rails.application.routes.draw do
22
22
  match 'job_invocations/:id/rerun', to: 'react#index', :via => [:get], as: 'rerun_job_invocation'
23
23
  match 'old/job_invocations/new', to: 'job_invocations#new', via: [:get], as: 'form_new_job_invocation'
24
24
  match 'old/job_invocations/:id/rerun', to: 'job_invocations#rerun', via: [:get, :post], as: 'form_rerun_job_invocation'
25
- match 'experimental/job_invocations_detail/:id', to: 'react#index', :via => [:get], as: 'new_job_invocation_detail'
25
+ get 'job_invocations/:id', to: 'react#index', as: 'job_invocation'
26
+ get 'legacy/job_invocations/:id', to: 'job_invocations#show', as: 'legacy_job_invocation'
26
27
  match 'job_invocations_detail/:id/host_invocation/:host_id', to: 'react#index', :via => [:get], as: 'new_job_invocation_detail_by_host'
27
28
  get 'show_template_invocation_by_host/:host_id/job_invocation/:id', to: 'template_invocations#show_template_invocation_by_host'
28
29
 
29
- resources :job_invocations, :only => [:create, :show, :index] do
30
+ resources :job_invocations, :only => [:create, :index] do
30
31
  collection do
31
32
  get 'preview_job_invocations_per_host'
32
33
  post 'refresh'
@@ -35,6 +36,7 @@ Rails.application.routes.draw do
35
36
  get 'auto_complete_search'
36
37
  end
37
38
  member do
39
+ get 'hosts', to: 'job_invocations#list_jobs_hosts'
38
40
  post 'cancel'
39
41
  end
40
42
  end
@@ -7,13 +7,14 @@ module ForemanRemoteExecution
7
7
  # Precompile any JS or CSS files under app/assets/
8
8
  # If requiring files from each other, list them explicitly here to avoid precompiling the same
9
9
  # content twice.
10
- assets_to_precompile =
11
- Dir.chdir(root) do
10
+ def self.assets_to_precompile
11
+ assets = Dir.chdir(root) do
12
12
  Dir['app/assets/javascripts/**/*'].map do |f|
13
13
  f.split(File::SEPARATOR, 4).last
14
14
  end
15
15
  end
16
- assets_to_precompile += %w(foreman_remote_execution/foreman_remote_execution.css)
16
+ assets << 'foreman_remote_execution/foreman_remote_execution.css'
17
+ end
17
18
 
18
19
  # Add any db migrations
19
20
  initializer 'foreman_remote_execution.load_app_instance_data' do |app|
@@ -34,260 +35,16 @@ module ForemanRemoteExecution
34
35
 
35
36
  initializer 'foreman_remote_execution.register_plugin', before: :finisher_hook do |app|
36
37
  app.reloader.to_prepare do
37
- Foreman::Plugin.register :foreman_remote_execution do
38
- requires_foreman '>= 3.15'
39
- register_global_js_file 'global'
40
- register_gettext
41
-
42
- apipie_documented_controllers ["#{ForemanRemoteExecution::Engine.root}/app/controllers/api/v2/*.rb"]
43
- ApipieDSL.configuration.dsl_classes_matchers += [
44
- "#{ForemanRemoteExecution::Engine.root}/app/lib/foreman_remote_execution/renderer/**/*.rb",
45
- ]
46
- automatic_assets(false)
47
- precompile_assets(*assets_to_precompile)
48
-
49
- # Add settings to a Remote Execution category
50
- settings do
51
- category :remote_execution, N_('Remote Execution') do
52
- setting 'remote_execution_fallback_proxy',
53
- type: :boolean,
54
- description: N_('Search the host for any proxy with Remote Execution, useful when the host has no subnet or the subnet does not have an execution proxy'),
55
- default: false,
56
- full_name: N_('Fallback to Any Proxy')
57
- setting 'remote_execution_global_proxy',
58
- type: :boolean,
59
- description: N_('Search for remote execution proxy outside of the proxies assigned to the host. The search will be limited to the host\'s organization and location.'),
60
- default: true,
61
- full_name: N_('Enable Global Proxy')
62
- setting 'remote_execution_ssh_user',
63
- type: :string,
64
- description: N_('Default user to use for SSH. You may override per host by setting a parameter called remote_execution_ssh_user.'),
65
- default: 'root',
66
- full_name: N_('SSH User')
67
- setting 'remote_execution_effective_user',
68
- type: :string,
69
- description: N_('Default user to use for executing the script. If the user differs from the SSH user, su or sudo is used to switch the user.'),
70
- default: 'root',
71
- full_name: N_('Effective User')
72
- setting 'remote_execution_effective_user_method',
73
- type: :string,
74
- description: N_('What command should be used to switch to the effective user. One of %s') % ::ScriptExecutionProvider::EFFECTIVE_USER_METHODS.inspect,
75
- default: 'sudo',
76
- full_name: N_('Effective User Method'),
77
- collection: proc { Hash[::ScriptExecutionProvider::EFFECTIVE_USER_METHODS.map { |method| [method, method] }] }
78
- setting 'remote_execution_effective_user_password',
79
- type: :string,
80
- description: N_('Effective user password'),
81
- default: '',
82
- full_name: N_('Effective user password'),
83
- encrypted: true
84
- setting 'remote_execution_sync_templates',
85
- type: :boolean,
86
- description: N_('Whether we should sync templates from disk when running db:seed.'),
87
- default: true,
88
- full_name: N_('Sync Job Templates')
89
- setting 'remote_execution_ssh_port',
90
- type: :integer,
91
- description: N_('Port to use for SSH communication. Default port 22. You may override per host by setting a parameter called remote_execution_ssh_port.'),
92
- default: 22,
93
- full_name: N_('SSH Port')
94
- setting 'remote_execution_connect_by_ip',
95
- type: :boolean,
96
- description: N_('Should the ip addresses on host interfaces be preferred over the fqdn? '\
97
- 'It is useful when DNS not resolving the fqdns properly. You may override this per host by setting a parameter called remote_execution_connect_by_ip. '\
98
- 'For dual-stacked hosts you should consider the remote_execution_connect_by_ip_prefer_ipv6 setting'),
99
- default: false,
100
- full_name: N_('Connect by IP')
101
- setting 'remote_execution_connect_by_ip_prefer_ipv6',
102
- type: :boolean,
103
- description: N_('When connecting using ip address, should the IPv6 addresses be preferred? '\
104
- 'If no IPv6 address is set, it falls back to IPv4 automatically. You may override this per host by setting a parameter called remote_execution_connect_by_ip_prefer_ipv6. '\
105
- 'By default and for compatibility, IPv4 will be preferred over IPv6 by default'),
106
- default: false,
107
- full_name: N_('Prefer IPv6 over IPv4')
108
- setting 'remote_execution_ssh_password',
109
- type: :string,
110
- description: N_('Default password to use for SSH. You may override per host by setting a parameter called remote_execution_ssh_password'),
111
- default: nil,
112
- full_name: N_('Default SSH password'),
113
- encrypted: true
114
- setting 'remote_execution_ssh_key_passphrase',
115
- type: :string,
116
- description: N_('Default key passphrase to use for SSH. You may override per host by setting a parameter called remote_execution_ssh_key_passphrase'),
117
- default: nil,
118
- full_name: N_('Default SSH key passphrase'),
119
- encrypted: true
120
- setting 'remote_execution_cleanup_working_dirs',
121
- type: :boolean,
122
- description: N_('When enabled, working directories will be removed after task completion. You may override this per host by setting a parameter called remote_execution_cleanup_working_dirs.'),
123
- default: true,
124
- full_name: N_('Cleanup working directories')
125
- setting 'remote_execution_cockpit_url',
126
- type: :string,
127
- description: N_('Where to find the Cockpit instance for the Web Console button. By default, no button is shown.'),
128
- default: nil,
129
- full_name: N_('Cockpit URL')
130
- setting 'remote_execution_form_job_template',
131
- type: :string,
132
- description: N_('Choose a job template that is pre-selected in job invocation form'),
133
- default: 'Run Command - Script Default',
134
- full_name: N_('Form Job Template'),
135
- collection: proc { Hash[JobTemplate.unscoped.map { |template| [template.name, template.name] }] }
136
- setting 'remote_execution_job_invocation_report_template',
137
- type: :string,
138
- description: N_('Select a report template used for generating a report for a particular remote execution job'),
139
- default: 'Job - Invocation Report',
140
- full_name: N_('Job Invocation Report Template'),
141
- collection: proc { ForemanRemoteExecution.job_invocation_report_templates_select }
142
- setting 'remote_execution_time_to_pickup',
143
- type: :integer,
144
- description: N_('Time in seconds within which the host has to pick up a job. If the job is not picked up within this limit, the job will be cancelled. Defaults to 1 day. Applies only to pull-mqtt based jobs.'),
145
- default: 24 * 60 * 60,
146
- full_name: N_('Time to pickup')
147
- end
148
- end
149
-
150
- # Add permissions
151
- security_block :foreman_remote_execution do
152
- permission :view_job_templates, { :job_templates => [:index, :show, :revision, :auto_complete_search, :auto_complete_job_category, :preview, :export],
153
- :'api/v2/job_templates' => [:index, :show, :revision, :export],
154
- :'api/v2/template_inputs' => [:index, :show],
155
- :'api/v2/foreign_input_sets' => [:index, :show],
156
- :ui_job_wizard => [:categories, :template, :resources, :job_invocation]}, :resource_type => 'JobTemplate'
157
- permission :create_job_templates, { :job_templates => [:new, :create, :clone_template, :import],
158
- :'api/v2/job_templates' => [:create, :clone, :import] }, :resource_type => 'JobTemplate'
159
- permission :edit_job_templates, { :job_templates => [:edit, :update],
160
- :'api/v2/job_templates' => [:update],
161
- :'api/v2/template_inputs' => [:create, :update, :destroy],
162
- :'api/v2/foreign_input_sets' => [:create, :update, :destroy]}, :resource_type => 'JobTemplate'
163
- permission :view_remote_execution_features, { :remote_execution_features => [:index, :show],
164
- :'api/v2/remote_execution_features' => [:index, :show, :available_remote_execution_features]},
165
- :resource_type => 'RemoteExecutionFeature'
166
- permission :edit_remote_execution_features, { :remote_execution_features => [:update],
167
- :'api/v2/remote_execution_features' => [:update ]}, :resource_type => 'RemoteExecutionFeature'
168
- permission :destroy_job_templates, { :job_templates => [:destroy],
169
- :'api/v2/job_templates' => [:destroy] }, :resource_type => 'JobTemplate'
170
- permission :lock_job_templates, { :job_templates => [:lock, :unlock] }, :resource_type => 'JobTemplate'
171
- permission :create_job_invocations, { :job_invocations => [:new, :create, :legacy_create, :refresh, :rerun, :preview_hosts],
172
- 'api/v2/job_invocations' => [:create, :rerun] }, :resource_type => 'JobInvocation'
173
- permission :view_job_invocations, { :job_invocations => [:index, :chart, :show, :auto_complete_search, :preview_job_invocations_per_host], :template_invocations => [:show, :show_template_invocation_by_host],
174
- 'api/v2/job_invocations' => [:index, :show, :output, :raw_output, :outputs, :hosts] }, :resource_type => 'JobInvocation'
175
- permission :view_template_invocations, { :template_invocations => [:show, :template_invocation_preview, :show_template_invocation_by_host],
176
- 'api/v2/template_invocations' => [:template_invocations], :ui_job_wizard => [:job_invocation] }, :resource_type => 'TemplateInvocation'
177
- permission :create_template_invocations, {}, :resource_type => 'TemplateInvocation'
178
- permission :execute_jobs_on_infrastructure_hosts, {}, :resource_type => 'JobInvocation'
179
- permission :cancel_job_invocations, { :job_invocations => [:cancel], 'api/v2/job_invocations' => [:cancel] }, :resource_type => 'JobInvocation'
180
- # this permissions grants user to get auto completion hints when setting up filters
181
- permission :filter_autocompletion_for_template_invocation, { :template_invocations => [ :auto_complete_search, :index ] },
182
- :resource_type => 'TemplateInvocation'
183
- permission :cockpit_hosts, { 'cockpit' => [:redirect, :host_ssh_params] }, :resource_type => 'Host'
184
- end
185
-
186
- USER_PERMISSIONS = [
187
- :view_job_templates,
188
- :view_job_invocations,
189
- :create_job_invocations,
190
- :create_template_invocations,
191
- :view_hosts,
192
- :view_smart_proxies,
193
- :view_remote_execution_features,
194
- ].freeze
195
- MANAGER_PERMISSIONS = USER_PERMISSIONS + [
196
- :cancel_job_invocations,
197
- :destroy_job_templates,
198
- :edit_job_templates,
199
- :create_job_templates,
200
- :lock_job_templates,
201
- :view_audit_logs,
202
- :filter_autocompletion_for_template_invocation,
203
- :edit_remote_execution_features,
204
- ]
205
-
206
- # Add a new role called 'Remote Execution User ' if it doesn't exist
207
- role 'Remote Execution User', USER_PERMISSIONS, 'Role with permissions to run remote execution jobs against hosts'
208
- role 'Remote Execution Manager', MANAGER_PERMISSIONS, 'Role with permissions to manage job templates, remote execution features, cancel jobs and view audit logs'
209
-
210
- add_all_permissions_to_default_roles(except: [:execute_jobs_on_infrastructure_hosts])
211
- add_permissions_to_default_roles({
212
- Role::MANAGER => [:execute_jobs_on_infrastructure_hosts],
213
- Role::SITE_MANAGER => USER_PERMISSIONS + [:execute_jobs_on_infrastructure_hosts],
214
- })
215
-
216
- # add menu entry
217
- menu :top_menu, :job_templates,
218
- url_hash: { controller: :job_templates, action: :index },
219
- caption: N_('Job Templates'),
220
- parent: :hosts_menu,
221
- after: :provisioning_templates
222
- menu :admin_menu, :remote_execution_features,
223
- url_hash: { controller: :remote_execution_features, action: :index },
224
- caption: N_('Remote Execution Features'),
225
- parent: :administer_menu,
226
- after: :bookmarks
227
-
228
- menu :top_menu, :job_invocations,
229
- url_hash: { controller: :job_invocations, action: :index },
230
- caption: N_('Jobs'),
231
- parent: :monitor_menu,
232
- after: :audits
233
-
234
- menu :labs_menu, :job_invocations_detail,
235
- url_hash: { controller: :job_invocations, action: :show },
236
- caption: N_('Job invocations detail'),
237
- parent: :lab_features_menu,
238
- url: '/experimental/job_invocations_detail/1'
239
-
240
- register_custom_status HostStatus::ExecutionStatus
241
- # add dashboard widget
242
- # widget 'foreman_remote_execution_widget', name: N_('Foreman plugin template widget'), sizex: 4, sizey: 1
243
- widget 'dashboard/latest-jobs', :name => N_('Latest Jobs'), :sizex => 6, :sizey => 1
244
-
245
- parameter_filter Subnet, :remote_execution_proxies, :remote_execution_proxy_ids => []
246
- parameter_filter Nic::Interface do |ctx|
247
- ctx.permit :execution
248
- end
249
-
250
- register_graphql_query_field :job_invocations, '::Types::JobInvocation', :collection_field
251
- register_graphql_query_field :job_invocation, '::Types::JobInvocation', :record_field
252
-
253
- register_graphql_mutation_field :create_job_invocation, ::Mutations::JobInvocations::Create
254
-
255
- extend_template_helpers ForemanRemoteExecution::RendererMethods
256
-
257
- extend_rabl_template 'api/v2/smart_proxies/main', 'api/v2/smart_proxies/pubkey'
258
- extend_rabl_template 'api/v2/interfaces/main', 'api/v2/interfaces/execution_flag'
259
- extend_rabl_template 'api/v2/subnets/show', 'api/v2/subnets/remote_execution_proxies'
260
- extend_rabl_template 'api/v2/hosts/main', 'api/v2/host/main'
261
- parameter_filter ::Subnet, :remote_execution_proxy_ids
262
-
263
- describe_host do
264
- multiple_actions_provider :rex_hosts_multiple_actions
265
- overview_buttons_provider :rex_host_overview_buttons
266
- end
267
-
268
- # Extend Registration module
269
- extend_allowed_registration_vars :remote_execution_interface
270
- extend_allowed_registration_vars :setup_remote_execution_pull
271
- ForemanTasks.dynflow.eager_load_actions!
272
- extend_observable_events(
273
- ::Dynflow::Action.descendants.select do |klass|
274
- klass <= ::Actions::ObservableAction
275
- end.map(&:namespaced_event_names) +
276
- RemoteExecutionFeature.all.pluck(:label).flat_map do |label|
277
- [::Actions::RemoteExecution::RunHostJob, ::Actions::RemoteExecution::RunHostsJob].map do |klass|
278
- klass.feature_job_event_names(label)
279
- end
280
- end
281
- )
282
- end
38
+ # Allow plugin registration to call application code once on boot
39
+ require_relative 'plugin'
283
40
  end
284
41
  end
285
42
 
286
43
  initializer 'foreman_remote_execution.assets.precompile' do |app|
287
- app.config.assets.precompile += assets_to_precompile
44
+ app.config.assets.precompile += Engine.assets_to_precompile
288
45
  end
289
46
  initializer 'foreman_remote_execution.configure_assets', group: :assets do
290
- SETTINGS[:foreman_remote_execution] = { assets: { precompile: assets_to_precompile } }
47
+ SETTINGS[:foreman_remote_execution] = { assets: { precompile: Engine.assets_to_precompile } }
291
48
  end
292
49
 
293
50
  # Include concerns in this config.to_prepare block
@@ -300,8 +57,7 @@ module ForemanRemoteExecution
300
57
  # e.g. having ProvisioningTemplate < Template, adding has_many :template_inputs to Template from concern
301
58
  # Template.reflect_on_association :template_inputs # => <#Association...
302
59
  # ProvisioningTemplate.reflect_on_association :template_inputs # => nil
303
- require_dependency 'job_template'
304
- (Template.descendants + [Template]).each { |klass| klass.send(:include, ForemanRemoteExecution::TemplateExtensions) }
60
+ (Template.descendants + [JobTemplate, Template]).each { |klass| klass.send(:include, ForemanRemoteExecution::TemplateExtensions) }
305
61
  Template.prepend ForemanRemoteExecution::TemplateOverrides
306
62
 
307
63
  (Taxonomy.descendants + [Taxonomy]).each { |klass| klass.send(:include, ForemanRemoteExecution::TaxonomyExtensions) }
@@ -323,9 +79,6 @@ module ForemanRemoteExecution
323
79
  Subnet.include ForemanRemoteExecution::SubnetExtensions
324
80
 
325
81
  ::Api::V2::InterfacesController.include Api::V2::InterfacesControllerExtensions
326
- # We need to explicitly force to load the Task model due to Rails loader
327
- # having issues with resolving it to Rake::Task otherwise
328
- require_dependency 'foreman_tasks/task'
329
82
  ForemanTasks::Task.include ForemanRemoteExecution::ForemanTasksTaskExtensions
330
83
  ForemanTasks::Cleaner.include ForemanRemoteExecution::ForemanTasksCleanerExtensions
331
84
  RemoteExecutionProvider.register(:SSH, ::ScriptExecutionProvider)