foreman_remote_execution 13.2.6 → 14.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 58fef2321712f081b4f1048c6b17a9959949a40cb5f8da979d197113e3ef7b78
4
- data.tar.gz: 6f24b798e004c1ae1f7428dab56234faf1bb144f69f73b08038bffbb470be641
3
+ metadata.gz: a73b13cdd10e99e44456d4b8dc1bbf8fe654dd6b83eb929e657df49d44b75078
4
+ data.tar.gz: a09d30bd37238e0dadd1e8bb8b32d41292df56aea1a03f19fdd2ab6386664ab3
5
5
  SHA512:
6
- metadata.gz: 5154f85559c70289654cc377dc6f6bead34920675b4e32ebec8cde5cabcf0f468aedb33569bef56cd3a41e8b382b0c3dc45cae182e2d4bd80719582ecaa150ce
7
- data.tar.gz: 89906586bb2802ea2712663efa32dbed8b3eca5d88ab8a20f3e100f26d87b76b81efd1ebd5ba95252d21cf8e72918e069b8519a90a018041f951661ba5fa5ee7
6
+ metadata.gz: 6633435cacf5d2e835d8391bf2d035844d87db9be34c9fbd134d140a10559779b0f940109ba6feb8dfb0f35ab5b08accc5bec75c94e28ec12accc837c10c795c
7
+ data.tar.gz: 0e0417551e20786be7c7c87d1e694596ef8f118dbf303fece462810a6d4577f7bd99208dc6f8555cfb91b87a73914fc96a20185d9d7e2a3f6e76103cca5db31a
data/.gitignore CHANGED
@@ -16,3 +16,4 @@ node_modules/
16
16
  package-lock.json
17
17
  coverage/
18
18
  public/
19
+ locale/action_names.rb
data/.tx/config CHANGED
@@ -6,5 +6,5 @@ file_filter = locale/<lang>/foreman_remote_execution.edit.po
6
6
  source_file = locale/foreman_remote_execution.pot
7
7
  source_lang = en
8
8
  type = PO
9
- minimum_perc = 50
9
+ minimum_perc = 0
10
10
  resource_name = foreman_remote_execution
@@ -1,4 +1,4 @@
1
- class UiJobWizardController < Api::V2::BaseController
1
+ class UIJobWizardController < Api::V2::BaseController
2
2
  include FiltersHelper
3
3
  def categories
4
4
  job_categories = resource_scope(permission: action_permission)
@@ -33,7 +33,7 @@ module JobInvocationsHelper
33
33
  end
34
34
 
35
35
  def collapsed_preview(target)
36
- title = target || 'N/A'
36
+ title = (target || 'N/A').to_s
37
37
  content_tag(:h5,
38
38
  :class => "expander collapsed out",
39
39
  :data => { :toggle => 'collapse',
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ # macros to fetch information about invoked jobs
4
+ module ForemanRemoteExecution
5
+ module RendererMethods
6
+ extend ActiveSupport::Concern
7
+
8
+ def find_job_invocation_by_id(job_id, preload: nil)
9
+ JobInvocation.preload(preload).find_by(id: job_id)
10
+ rescue ActiveRecord::NotFound => _e
11
+ raise ::Foreman::Exception.new(N_("Can't find Job Invocation for an id %s"), job_id)
12
+ end
13
+ end
14
+ end
@@ -7,8 +7,8 @@ module ForemanRemoteExecution
7
7
  def flattened_errors
8
8
  errors = Hash.new { |h, k| h[k] = [] }
9
9
  # self.errors is ActiveModel::Errors, not Hash and doesn't have the #each_key method
10
- self.errors.keys.each do |key|
11
- messages = self.errors[key]
10
+ self.errors.attribute_names.each do |key|
11
+ messages = self.errors.messages_for(key)
12
12
  invalid_objects = invalid_objects_for_attribute(key)
13
13
  if invalid_objects.blank?
14
14
  errors[key] = messages
@@ -55,7 +55,7 @@ end
55
55
  </div>
56
56
 
57
57
  <script>
58
- <%= render :partial => 'refresh.js' %>
58
+ <%= render partial: 'refresh', formats: :js %>
59
59
  </script>
60
60
  <% else %>
61
61
  <%= _("Could not display data for job invocation.") %>
@@ -148,7 +148,7 @@ handle_zypp_res_codes () {
148
148
  end
149
149
  -%>
150
150
  zypper refresh
151
- zypper -n <%= action %> <%= input("options") %> <%= input("package") %>
151
+ zypper -n --gpg-auto-import-keys <%= action %> <%= input("options") %> <%= input("package") %>
152
152
  handle_zypp_res_codes $? "<%= action %>"
153
153
  <% end -%>
154
154
  RETVAL=$?
@@ -0,0 +1,6 @@
1
+ Rails.autoloaders.each do |autoloader|
2
+ autoloader.inflector.inflect(
3
+ 'ssh_execution_provider' => 'SSHExecutionProvider',
4
+ 'remote_execution_ssh' => 'RemoteExecutionSSH'
5
+ )
6
+ end
@@ -1,10 +1,13 @@
1
1
  class MigrateSmartProxyIdsToTemplateInvocations < ActiveRecord::Migration[6.0]
2
2
  def up
3
+ proxy_lookup_cache = {}
3
4
  ForemanTasks::Link.joins(:task)
4
5
  .where(resource_type: 'SmartProxy', task: { label: 'Actions::RemoteExecution::RunHostJob' })
5
6
  .where.not(resource_id: nil)
6
7
  .find_in_batches do |batch|
7
8
  batch.group_by(&:resource_id).each do |resource_id, links|
9
+ proxy_lookup_cache[resource_id] = SmartProxy.where(id: resource_id).exists? unless proxy_lookup_cache.key?(resource_id)
10
+ next unless proxy_lookup_cache[resource_id]
8
11
  template_invocation_ids = ForemanTasks::Link.where(resource_type: 'TemplateInvocation', task_id: links.map(&:task_id)).select(:resource_id)
9
12
  TemplateInvocation.where(id: template_invocation_ids).update_all(smart_proxy_id: resource_id)
10
13
  end
@@ -4,10 +4,6 @@ module ForemanRemoteExecution
4
4
  class Engine < ::Rails::Engine
5
5
  engine_name 'foreman_remote_execution'
6
6
 
7
- config.autoload_paths += Dir["#{config.root}/app/controllers/concerns"]
8
- config.autoload_paths += Dir["#{config.root}/app/helpers/concerns"]
9
- config.autoload_paths += Dir["#{config.root}/app/models/concerns"]
10
-
11
7
  # Precompile any JS or CSS files under app/assets/
12
8
  # If requiring files from each other, list them explicitly here to avoid precompiling the same
13
9
  # content twice.
@@ -26,15 +22,6 @@ module ForemanRemoteExecution
26
22
  end
27
23
  end
28
24
 
29
- # A workaround for https://projects.theforeman.org/issues/30685
30
- initializer 'foreman_remote_execution.rails_loading_workaround' do
31
- # Without this, in production environment the module gets prepended too
32
- # late and the extensions do not get applied
33
- # TODO: Remove this and from config.to_prepare once there is an extension
34
- # point in Foreman
35
- ProvisioningTemplatesHelper.prepend ForemanRemoteExecution::JobTemplatesExtensions
36
- end
37
-
38
25
  initializer 'foreman_remote_execution.apipie' do
39
26
  Apipie.configuration.checksum_path += ['/api/']
40
27
  end
@@ -45,257 +32,259 @@ module ForemanRemoteExecution
45
32
  ForemanTasks.dynflow.config.eager_load_paths << File.join(ForemanRemoteExecution::Engine.root, 'app/lib/actions')
46
33
  end
47
34
 
48
- initializer 'foreman_remote_execution.register_plugin', before: :finisher_hook do |_app|
49
- Foreman::Plugin.register :foreman_remote_execution do
50
- requires_foreman '>= 3.10'
51
- register_global_js_file 'global'
52
- register_gettext
53
-
54
- apipie_documented_controllers ["#{ForemanRemoteExecution::Engine.root}/app/controllers/api/v2/*.rb"]
55
- ApipieDSL.configuration.dsl_classes_matchers += [
56
- "#{ForemanRemoteExecution::Engine.root}/app/lib/foreman_remote_execution/renderer/**/*.rb",
57
- ]
58
- automatic_assets(false)
59
- precompile_assets(*assets_to_precompile)
60
-
61
- # Add settings to a Remote Execution category
62
- settings do
63
- category :remote_execution, N_('Remote Execution') do
64
- setting 'remote_execution_fallback_proxy',
65
- type: :boolean,
66
- 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'),
67
- default: false,
68
- full_name: N_('Fallback to Any Proxy')
69
- setting 'remote_execution_global_proxy',
70
- type: :boolean,
71
- 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.'),
72
- default: true,
73
- full_name: N_('Enable Global Proxy')
74
- setting 'remote_execution_ssh_user',
75
- type: :string,
76
- description: N_('Default user to use for SSH. You may override per host by setting a parameter called remote_execution_ssh_user.'),
77
- default: 'root',
78
- full_name: N_('SSH User')
79
- setting 'remote_execution_effective_user',
80
- type: :string,
81
- 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.'),
82
- default: 'root',
83
- full_name: N_('Effective User')
84
- setting 'remote_execution_effective_user_method',
85
- type: :string,
86
- description: N_('What command should be used to switch to the effective user. One of %s') % SSHExecutionProvider::EFFECTIVE_USER_METHODS.inspect,
87
- default: 'sudo',
88
- full_name: N_('Effective User Method'),
89
- collection: proc { Hash[SSHExecutionProvider::EFFECTIVE_USER_METHODS.map { |method| [method, method] }] }
90
- setting 'remote_execution_effective_user_password',
91
- type: :string,
92
- description: N_('Effective user password'),
93
- default: '',
94
- full_name: N_('Effective user password'),
95
- encrypted: true
96
- setting 'remote_execution_sync_templates',
97
- type: :boolean,
98
- description: N_('Whether we should sync templates from disk when running db:seed.'),
99
- default: true,
100
- full_name: N_('Sync Job Templates')
101
- setting 'remote_execution_ssh_port',
102
- type: :integer,
103
- 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.'),
104
- default: 22,
105
- full_name: N_('SSH Port')
106
- setting 'remote_execution_connect_by_ip',
107
- type: :boolean,
108
- description: N_('Should the ip addresses on host interfaces be preferred over the fqdn? '\
109
- '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. '\
110
- 'For dual-stacked hosts you should consider the remote_execution_connect_by_ip_prefer_ipv6 setting'),
111
- default: false,
112
- full_name: N_('Connect by IP')
113
- setting 'remote_execution_connect_by_ip_prefer_ipv6',
114
- type: :boolean,
115
- description: N_('When connecting using ip address, should the IPv6 addresses be preferred? '\
116
- '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. '\
117
- 'By default and for compatibility, IPv4 will be preferred over IPv6 by default'),
118
- default: false,
119
- full_name: N_('Prefer IPv6 over IPv4')
120
- setting 'remote_execution_ssh_password',
121
- type: :string,
122
- description: N_('Default password to use for SSH. You may override per host by setting a parameter called remote_execution_ssh_password'),
123
- default: nil,
124
- full_name: N_('Default SSH password'),
125
- encrypted: true
126
- setting 'remote_execution_ssh_key_passphrase',
127
- type: :string,
128
- description: N_('Default key passphrase to use for SSH. You may override per host by setting a parameter called remote_execution_ssh_key_passphrase'),
129
- default: nil,
130
- full_name: N_('Default SSH key passphrase'),
131
- encrypted: true
132
- setting 'remote_execution_workers_pool_size',
133
- type: :integer,
134
- description: N_('Amount of workers in the pool to handle the execution of the remote execution jobs. Restart of the dynflowd/foreman-tasks service is required.'),
135
- default: 5,
136
- full_name: N_('Workers pool size')
137
- setting 'remote_execution_cleanup_working_dirs',
138
- type: :boolean,
139
- 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.'),
140
- default: true,
141
- full_name: N_('Cleanup working directories')
142
- setting 'remote_execution_cockpit_url',
143
- type: :string,
144
- description: N_('Where to find the Cockpit instance for the Web Console button. By default, no button is shown.'),
145
- default: nil,
146
- full_name: N_('Cockpit URL')
147
- setting 'remote_execution_form_job_template',
148
- type: :string,
149
- description: N_('Choose a job template that is pre-selected in job invocation form'),
150
- default: 'Run Command - Script Default',
151
- full_name: N_('Form Job Template'),
152
- collection: proc { Hash[JobTemplate.unscoped.map { |template| [template.name, template.name] }] }
153
- setting 'remote_execution_job_invocation_report_template',
154
- type: :string,
155
- description: N_('Select a report template used for generating a report for a particular remote execution job'),
156
- default: 'Job - Invocation Report',
157
- full_name: N_('Job Invocation Report Template'),
158
- collection: proc { ForemanRemoteExecution.job_invocation_report_templates_select }
159
- setting 'remote_execution_time_to_pickup',
160
- type: :integer,
161
- 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.'),
162
- default: 24 * 60 * 60,
163
- full_name: N_('Time to pickup')
35
+ initializer 'foreman_remote_execution.register_plugin', before: :finisher_hook do |app|
36
+ app.reloader.to_prepare do
37
+ Foreman::Plugin.register :foreman_remote_execution do
38
+ requires_foreman '>= 3.13'
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') % ::SSHExecutionProvider::EFFECTIVE_USER_METHODS.inspect,
75
+ default: 'sudo',
76
+ full_name: N_('Effective User Method'),
77
+ collection: proc { Hash[::SSHExecutionProvider::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_workers_pool_size',
121
+ type: :integer,
122
+ description: N_('Amount of workers in the pool to handle the execution of the remote execution jobs. Restart of the dynflowd/foreman-tasks service is required.'),
123
+ default: 5,
124
+ full_name: N_('Workers pool size')
125
+ setting 'remote_execution_cleanup_working_dirs',
126
+ type: :boolean,
127
+ 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.'),
128
+ default: true,
129
+ full_name: N_('Cleanup working directories')
130
+ setting 'remote_execution_cockpit_url',
131
+ type: :string,
132
+ description: N_('Where to find the Cockpit instance for the Web Console button. By default, no button is shown.'),
133
+ default: nil,
134
+ full_name: N_('Cockpit URL')
135
+ setting 'remote_execution_form_job_template',
136
+ type: :string,
137
+ description: N_('Choose a job template that is pre-selected in job invocation form'),
138
+ default: 'Run Command - Script Default',
139
+ full_name: N_('Form Job Template'),
140
+ collection: proc { Hash[JobTemplate.unscoped.map { |template| [template.name, template.name] }] }
141
+ setting 'remote_execution_job_invocation_report_template',
142
+ type: :string,
143
+ description: N_('Select a report template used for generating a report for a particular remote execution job'),
144
+ default: 'Job - Invocation Report',
145
+ full_name: N_('Job Invocation Report Template'),
146
+ collection: proc { ForemanRemoteExecution.job_invocation_report_templates_select }
147
+ setting 'remote_execution_time_to_pickup',
148
+ type: :integer,
149
+ 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.'),
150
+ default: 24 * 60 * 60,
151
+ full_name: N_('Time to pickup')
152
+ end
164
153
  end
165
- end
166
154
 
167
- # Add permissions
168
- security_block :foreman_remote_execution do
169
- permission :view_job_templates, { :job_templates => [:index, :show, :revision, :auto_complete_search, :auto_complete_job_category, :preview, :export],
170
- :'api/v2/job_templates' => [:index, :show, :revision, :export],
171
- :'api/v2/template_inputs' => [:index, :show],
172
- :'api/v2/foreign_input_sets' => [:index, :show],
173
- :ui_job_wizard => [:categories, :template, :resources, :job_invocation]}, :resource_type => 'JobTemplate'
174
- permission :create_job_templates, { :job_templates => [:new, :create, :clone_template, :import],
175
- :'api/v2/job_templates' => [:create, :clone, :import] }, :resource_type => 'JobTemplate'
176
- permission :edit_job_templates, { :job_templates => [:edit, :update],
177
- :'api/v2/job_templates' => [:update],
178
- :'api/v2/template_inputs' => [:create, :update, :destroy],
179
- :'api/v2/foreign_input_sets' => [:create, :update, :destroy]}, :resource_type => 'JobTemplate'
180
- permission :view_remote_execution_features, { :remote_execution_features => [:index, :show],
181
- :'api/v2/remote_execution_features' => [:index, :show, :available_remote_execution_features]},
182
- :resource_type => 'RemoteExecutionFeature'
183
- permission :edit_remote_execution_features, { :remote_execution_features => [:update],
184
- :'api/v2/remote_execution_features' => [:update ]}, :resource_type => 'RemoteExecutionFeature'
185
- permission :destroy_job_templates, { :job_templates => [:destroy],
186
- :'api/v2/job_templates' => [:destroy] }, :resource_type => 'JobTemplate'
187
- permission :lock_job_templates, { :job_templates => [:lock, :unlock] }, :resource_type => 'JobTemplate'
188
- permission :create_job_invocations, { :job_invocations => [:new, :create, :legacy_create, :refresh, :rerun, :preview_hosts],
189
- 'api/v2/job_invocations' => [:create, :rerun] }, :resource_type => 'JobInvocation'
190
- permission :view_job_invocations, { :job_invocations => [:index, :chart, :show, :auto_complete_search, :preview_job_invocations_per_host], :template_invocations => [:show],
191
- 'api/v2/job_invocations' => [:index, :show, :output, :raw_output, :outputs] }, :resource_type => 'JobInvocation'
192
- permission :view_template_invocations, { :template_invocations => [:show],
193
- 'api/v2/template_invocations' => [:template_invocations], :ui_job_wizard => [:job_invocation] }, :resource_type => 'TemplateInvocation'
194
- permission :create_template_invocations, {}, :resource_type => 'TemplateInvocation'
195
- permission :execute_jobs_on_infrastructure_hosts, {}, :resource_type => 'JobInvocation'
196
- permission :cancel_job_invocations, { :job_invocations => [:cancel], 'api/v2/job_invocations' => [:cancel] }, :resource_type => 'JobInvocation'
197
- # this permissions grants user to get auto completion hints when setting up filters
198
- permission :filter_autocompletion_for_template_invocation, { :template_invocations => [ :auto_complete_search, :index ] },
199
- :resource_type => 'TemplateInvocation'
200
- permission :cockpit_hosts, { 'cockpit' => [:redirect, :host_ssh_params] }, :resource_type => 'Host'
201
- end
155
+ # Add permissions
156
+ security_block :foreman_remote_execution do
157
+ permission :view_job_templates, { :job_templates => [:index, :show, :revision, :auto_complete_search, :auto_complete_job_category, :preview, :export],
158
+ :'api/v2/job_templates' => [:index, :show, :revision, :export],
159
+ :'api/v2/template_inputs' => [:index, :show],
160
+ :'api/v2/foreign_input_sets' => [:index, :show],
161
+ :ui_job_wizard => [:categories, :template, :resources, :job_invocation]}, :resource_type => 'JobTemplate'
162
+ permission :create_job_templates, { :job_templates => [:new, :create, :clone_template, :import],
163
+ :'api/v2/job_templates' => [:create, :clone, :import] }, :resource_type => 'JobTemplate'
164
+ permission :edit_job_templates, { :job_templates => [:edit, :update],
165
+ :'api/v2/job_templates' => [:update],
166
+ :'api/v2/template_inputs' => [:create, :update, :destroy],
167
+ :'api/v2/foreign_input_sets' => [:create, :update, :destroy]}, :resource_type => 'JobTemplate'
168
+ permission :view_remote_execution_features, { :remote_execution_features => [:index, :show],
169
+ :'api/v2/remote_execution_features' => [:index, :show, :available_remote_execution_features]},
170
+ :resource_type => 'RemoteExecutionFeature'
171
+ permission :edit_remote_execution_features, { :remote_execution_features => [:update],
172
+ :'api/v2/remote_execution_features' => [:update ]}, :resource_type => 'RemoteExecutionFeature'
173
+ permission :destroy_job_templates, { :job_templates => [:destroy],
174
+ :'api/v2/job_templates' => [:destroy] }, :resource_type => 'JobTemplate'
175
+ permission :lock_job_templates, { :job_templates => [:lock, :unlock] }, :resource_type => 'JobTemplate'
176
+ permission :create_job_invocations, { :job_invocations => [:new, :create, :legacy_create, :refresh, :rerun, :preview_hosts],
177
+ 'api/v2/job_invocations' => [:create, :rerun] }, :resource_type => 'JobInvocation'
178
+ permission :view_job_invocations, { :job_invocations => [:index, :chart, :show, :auto_complete_search, :preview_job_invocations_per_host], :template_invocations => [:show],
179
+ 'api/v2/job_invocations' => [:index, :show, :output, :raw_output, :outputs] }, :resource_type => 'JobInvocation'
180
+ permission :view_template_invocations, { :template_invocations => [:show],
181
+ 'api/v2/template_invocations' => [:template_invocations], :ui_job_wizard => [:job_invocation] }, :resource_type => 'TemplateInvocation'
182
+ permission :create_template_invocations, {}, :resource_type => 'TemplateInvocation'
183
+ permission :execute_jobs_on_infrastructure_hosts, {}, :resource_type => 'JobInvocation'
184
+ permission :cancel_job_invocations, { :job_invocations => [:cancel], 'api/v2/job_invocations' => [:cancel] }, :resource_type => 'JobInvocation'
185
+ # this permissions grants user to get auto completion hints when setting up filters
186
+ permission :filter_autocompletion_for_template_invocation, { :template_invocations => [ :auto_complete_search, :index ] },
187
+ :resource_type => 'TemplateInvocation'
188
+ permission :cockpit_hosts, { 'cockpit' => [:redirect, :host_ssh_params] }, :resource_type => 'Host'
189
+ end
202
190
 
203
- USER_PERMISSIONS = [
204
- :view_job_templates,
205
- :view_job_invocations,
206
- :create_job_invocations,
207
- :create_template_invocations,
208
- :view_hosts,
209
- :view_smart_proxies,
210
- :view_remote_execution_features,
211
- ].freeze
212
- MANAGER_PERMISSIONS = USER_PERMISSIONS + [
213
- :cancel_job_invocations,
214
- :destroy_job_templates,
215
- :edit_job_templates,
216
- :create_job_templates,
217
- :lock_job_templates,
218
- :view_audit_logs,
219
- :filter_autocompletion_for_template_invocation,
220
- :edit_remote_execution_features,
221
- ]
222
-
223
- # Add a new role called 'Remote Execution User ' if it doesn't exist
224
- role 'Remote Execution User', USER_PERMISSIONS, 'Role with permissions to run remote execution jobs against hosts'
225
- role 'Remote Execution Manager', MANAGER_PERMISSIONS, 'Role with permissions to manage job templates, remote execution features, cancel jobs and view audit logs'
226
-
227
- add_all_permissions_to_default_roles(except: [:execute_jobs_on_infrastructure_hosts])
228
- add_permissions_to_default_roles({
229
- Role::MANAGER => [:execute_jobs_on_infrastructure_hosts],
230
- Role::SITE_MANAGER => USER_PERMISSIONS + [:execute_jobs_on_infrastructure_hosts],
231
- })
232
-
233
- # add menu entry
234
- menu :top_menu, :job_templates,
235
- url_hash: { controller: :job_templates, action: :index },
236
- caption: N_('Job templates'),
237
- parent: :hosts_menu,
238
- after: :provisioning_templates
239
- menu :admin_menu, :remote_execution_features,
240
- url_hash: { controller: :remote_execution_features, action: :index },
241
- caption: N_('Remote Execution Features'),
242
- parent: :administer_menu,
243
- after: :bookmarks
244
-
245
- menu :top_menu, :job_invocations,
246
- url_hash: { controller: :job_invocations, action: :index },
247
- caption: N_('Jobs'),
248
- parent: :monitor_menu,
249
- after: :audits
250
-
251
- menu :labs_menu, :job_invocations_detail,
252
- url_hash: { controller: :job_invocations, action: :show },
253
- caption: N_('Job invocations detail'),
254
- parent: :lab_features_menu,
255
- url: '/experimental/job_invocations_detail/1'
256
-
257
- register_custom_status HostStatus::ExecutionStatus
258
- # add dashboard widget
259
- # widget 'foreman_remote_execution_widget', name: N_('Foreman plugin template widget'), sizex: 4, sizey: 1
260
- widget 'dashboard/latest-jobs', :name => N_('Latest Jobs'), :sizex => 6, :sizey => 1
261
-
262
- parameter_filter Subnet, :remote_execution_proxies, :remote_execution_proxy_ids => []
263
- parameter_filter Nic::Interface do |ctx|
264
- ctx.permit :execution
265
- end
191
+ USER_PERMISSIONS = [
192
+ :view_job_templates,
193
+ :view_job_invocations,
194
+ :create_job_invocations,
195
+ :create_template_invocations,
196
+ :view_hosts,
197
+ :view_smart_proxies,
198
+ :view_remote_execution_features,
199
+ ].freeze
200
+ MANAGER_PERMISSIONS = USER_PERMISSIONS + [
201
+ :cancel_job_invocations,
202
+ :destroy_job_templates,
203
+ :edit_job_templates,
204
+ :create_job_templates,
205
+ :lock_job_templates,
206
+ :view_audit_logs,
207
+ :filter_autocompletion_for_template_invocation,
208
+ :edit_remote_execution_features,
209
+ ]
210
+
211
+ # Add a new role called 'Remote Execution User ' if it doesn't exist
212
+ role 'Remote Execution User', USER_PERMISSIONS, 'Role with permissions to run remote execution jobs against hosts'
213
+ role 'Remote Execution Manager', MANAGER_PERMISSIONS, 'Role with permissions to manage job templates, remote execution features, cancel jobs and view audit logs'
214
+
215
+ add_all_permissions_to_default_roles(except: [:execute_jobs_on_infrastructure_hosts])
216
+ add_permissions_to_default_roles({
217
+ Role::MANAGER => [:execute_jobs_on_infrastructure_hosts],
218
+ Role::SITE_MANAGER => USER_PERMISSIONS + [:execute_jobs_on_infrastructure_hosts],
219
+ })
220
+
221
+ # add menu entry
222
+ menu :top_menu, :job_templates,
223
+ url_hash: { controller: :job_templates, action: :index },
224
+ caption: N_('Job templates'),
225
+ parent: :hosts_menu,
226
+ after: :provisioning_templates
227
+ menu :admin_menu, :remote_execution_features,
228
+ url_hash: { controller: :remote_execution_features, action: :index },
229
+ caption: N_('Remote Execution Features'),
230
+ parent: :administer_menu,
231
+ after: :bookmarks
232
+
233
+ menu :top_menu, :job_invocations,
234
+ url_hash: { controller: :job_invocations, action: :index },
235
+ caption: N_('Jobs'),
236
+ parent: :monitor_menu,
237
+ after: :audits
238
+
239
+ menu :labs_menu, :job_invocations_detail,
240
+ url_hash: { controller: :job_invocations, action: :show },
241
+ caption: N_('Job invocations detail'),
242
+ parent: :lab_features_menu,
243
+ url: '/experimental/job_invocations_detail/1'
244
+
245
+ register_custom_status HostStatus::ExecutionStatus
246
+ # add dashboard widget
247
+ # widget 'foreman_remote_execution_widget', name: N_('Foreman plugin template widget'), sizex: 4, sizey: 1
248
+ widget 'dashboard/latest-jobs', :name => N_('Latest Jobs'), :sizex => 6, :sizey => 1
249
+
250
+ parameter_filter Subnet, :remote_execution_proxies, :remote_execution_proxy_ids => []
251
+ parameter_filter Nic::Interface do |ctx|
252
+ ctx.permit :execution
253
+ end
266
254
 
267
- register_graphql_query_field :job_invocations, '::Types::JobInvocation', :collection_field
268
- register_graphql_query_field :job_invocation, '::Types::JobInvocation', :record_field
255
+ register_graphql_query_field :job_invocations, '::Types::JobInvocation', :collection_field
256
+ register_graphql_query_field :job_invocation, '::Types::JobInvocation', :record_field
269
257
 
270
- register_graphql_mutation_field :create_job_invocation, ::Mutations::JobInvocations::Create
258
+ register_graphql_mutation_field :create_job_invocation, ::Mutations::JobInvocations::Create
271
259
 
272
- extend_template_helpers ForemanRemoteExecution::RendererMethods
260
+ extend_template_helpers ForemanRemoteExecution::RendererMethods
273
261
 
274
- extend_rabl_template 'api/v2/smart_proxies/main', 'api/v2/smart_proxies/pubkey'
275
- extend_rabl_template 'api/v2/interfaces/main', 'api/v2/interfaces/execution_flag'
276
- extend_rabl_template 'api/v2/subnets/show', 'api/v2/subnets/remote_execution_proxies'
277
- extend_rabl_template 'api/v2/hosts/main', 'api/v2/host/main'
278
- parameter_filter ::Subnet, :remote_execution_proxy_ids
262
+ extend_rabl_template 'api/v2/smart_proxies/main', 'api/v2/smart_proxies/pubkey'
263
+ extend_rabl_template 'api/v2/interfaces/main', 'api/v2/interfaces/execution_flag'
264
+ extend_rabl_template 'api/v2/subnets/show', 'api/v2/subnets/remote_execution_proxies'
265
+ extend_rabl_template 'api/v2/hosts/main', 'api/v2/host/main'
266
+ parameter_filter ::Subnet, :remote_execution_proxy_ids
279
267
 
280
- describe_host do
281
- multiple_actions_provider :rex_hosts_multiple_actions
282
- overview_buttons_provider :rex_host_overview_buttons
283
- end
268
+ describe_host do
269
+ multiple_actions_provider :rex_hosts_multiple_actions
270
+ overview_buttons_provider :rex_host_overview_buttons
271
+ end
284
272
 
285
- # Extend Registration module
286
- extend_allowed_registration_vars :remote_execution_interface
287
- extend_allowed_registration_vars :setup_remote_execution_pull
288
- ForemanTasks.dynflow.eager_load_actions!
289
- extend_observable_events(
290
- ::Dynflow::Action.descendants.select do |klass|
291
- klass <= ::Actions::ObservableAction
292
- end.map(&:namespaced_event_names) +
293
- RemoteExecutionFeature.all.pluck(:label).flat_map do |label|
294
- [::Actions::RemoteExecution::RunHostJob, ::Actions::RemoteExecution::RunHostsJob].map do |klass|
295
- klass.feature_job_event_names(label)
273
+ # Extend Registration module
274
+ extend_allowed_registration_vars :remote_execution_interface
275
+ extend_allowed_registration_vars :setup_remote_execution_pull
276
+ ForemanTasks.dynflow.eager_load_actions!
277
+ extend_observable_events(
278
+ ::Dynflow::Action.descendants.select do |klass|
279
+ klass <= ::Actions::ObservableAction
280
+ end.map(&:namespaced_event_names) +
281
+ RemoteExecutionFeature.all.pluck(:label).flat_map do |label|
282
+ [::Actions::RemoteExecution::RunHostJob, ::Actions::RemoteExecution::RunHostsJob].map do |klass|
283
+ klass.feature_job_event_names(label)
284
+ end
296
285
  end
297
- end
298
- )
286
+ )
287
+ end
299
288
  end
300
289
  end
301
290
 
@@ -1,3 +1,3 @@
1
1
  module ForemanRemoteExecution
2
- VERSION = '13.2.6'.freeze
2
+ VERSION = '14.0.2'.freeze
3
3
  end
data/locale/Makefile CHANGED
@@ -31,9 +31,16 @@ all-mo: $(MOFILES)
31
31
  cat $@
32
32
  ! grep -q msgid $@
33
33
 
34
- %.edit.po:
34
+ %.edit.po: %.po.time_stamp
35
35
  touch $@
36
36
 
37
+ # gettext will trash the .edit.po file if the time stamp doesn't exist or is older than the po file
38
+ %.po.time_stamp: %.po
39
+ touch --reference $< $@
40
+
41
+ # Prevent make from treating this as an intermediate file to be cleaned up
42
+ .PRECIOUS: %.po.time_stamp
43
+
37
44
  check: $(POXFILES)
38
45
 
39
46
  # Unify duplicate translations
@@ -43,7 +50,10 @@ uniq-po:
43
50
  done
44
51
 
45
52
  tx-pull: $(EDITFILES)
46
- cd .. && tx pull -f --all
53
+ # Initialize new languages
54
+ cd .. && tx pull -f --all --minimum-perc 50
55
+ # Force update all existing languages
56
+ cd .. && tx pull -f --minimum-perc 0
47
57
  for f in $(EDITFILES) ; do \
48
58
  sed -i 's/^\("Project-Id-Version: \).*$$/\1$(DOMAIN) $(VERSION)\\n"/' $$f; \
49
59
  done
@@ -1,6 +1,6 @@
1
1
  require 'test_plugin_helper'
2
2
 
3
- class UiJobWizardControllerTest < ActionController::TestCase
3
+ class UIJobWizardControllerTest < ActionController::TestCase
4
4
  def setup
5
5
  FactoryBot.create(:job_template, :job_category => 'cat1')
6
6
  FactoryBot.create(:job_template, :job_category => 'cat2')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_remote_execution
3
3
  version: !ruby/object:Gem::Version
4
- version: 13.2.6
4
+ version: 14.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Foreman Remote Execution team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-09-24 00:00:00.000000000 Z
11
+ date: 2024-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: deface
@@ -170,6 +170,7 @@ files:
170
170
  - app/lib/actions/remote_execution/template_invocation_progress_logging.rb
171
171
  - app/lib/foreman_remote_execution/provider_input.rb
172
172
  - app/lib/foreman_remote_execution/renderer/scope/input.rb
173
+ - app/lib/foreman_remote_execution/renderer_methods.rb
173
174
  - app/lib/proxy_api/remote_execution_ssh.rb
174
175
  - app/mailers/.gitkeep
175
176
  - app/mailers/rex_job_mailer.rb
@@ -213,7 +214,6 @@ files:
213
214
  - app/overrides/subnet_proxies.rb
214
215
  - app/services/default_proxy_proxy_selector.rb
215
216
  - app/services/remote_execution_proxy_selector.rb
216
- - app/services/renderer_methods.rb
217
217
  - app/services/ui_notifications/remote_execution_jobs/base_job_finish.rb
218
218
  - app/views/api/v2/foreign_input_sets/base.json.rabl
219
219
  - app/views/api/v2/foreign_input_sets/create.json.rabl
@@ -297,6 +297,7 @@ files:
297
297
  - app/views/templates/script/run_command.erb
298
298
  - app/views/templates/script/run_downloaded_script.erb
299
299
  - app/views/templates/script/service_action.erb
300
+ - config/initializers/inflections.rb
300
301
  - config/routes.rb
301
302
  - db/migrate/20150612121541_add_job_template_to_template.rb
302
303
  - db/migrate/20150708133241_add_targeting.rb
@@ -372,7 +373,6 @@ files:
372
373
  - lib/foreman_remote_execution/version.rb
373
374
  - lib/tasks/foreman_remote_execution_tasks.rake
374
375
  - locale/Makefile
375
- - locale/action_names.rb
376
376
  - locale/de/LC_MESSAGES/foreman_remote_execution.mo
377
377
  - locale/de/foreman_remote_execution.po
378
378
  - locale/en/LC_MESSAGES/foreman_remote_execution.mo
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # macros to fetch information about invoked jobs
4
- module RendererMethods
5
- extend ActiveSupport::Concern
6
-
7
- def find_job_invocation_by_id(job_id, preload: nil)
8
- JobInvocation.preload(preload).find_by(id: job_id)
9
- rescue ActiveRecord::NotFound => _e
10
- raise ::Foreman::Exception.new(N_("Can't find Job Invocation for an id %s"), job_id)
11
- end
12
- end
@@ -1,2 +0,0 @@
1
- # Autogenerated!
2
- _("Remote action:")