foreman_remote_execution 8.3.1 → 9.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby_ci.yml +3 -1
  3. data/app/controllers/api/v2/job_invocations_controller.rb +0 -1
  4. data/app/controllers/job_invocations_controller.rb +1 -20
  5. data/app/controllers/ui_job_wizard_controller.rb +1 -3
  6. data/app/helpers/remote_execution_helper.rb +1 -1
  7. data/app/lib/actions/remote_execution/run_host_job.rb +1 -1
  8. data/app/views/api/v2/job_invocations/base.json.rabl +1 -1
  9. data/app/views/job_invocations/_form.html.erb +1 -1
  10. data/app/views/job_invocations/show.html.erb +1 -1
  11. data/app/views/job_invocations/welcome.html.erb +1 -1
  12. data/config/routes.rb +0 -1
  13. data/db/migrate/20210816100932_rex_setting_category_to_dsl.rb +1 -1
  14. data/extra/cockpit/foreman-cockpit-session +12 -29
  15. data/lib/foreman_remote_execution/engine.rb +2 -2
  16. data/lib/foreman_remote_execution/version.rb +1 -1
  17. data/locale/action_names.rb +2 -2
  18. data/locale/de/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  19. data/locale/de/foreman_remote_execution.po +154 -266
  20. data/locale/en/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  21. data/locale/en/foreman_remote_execution.po +24 -132
  22. data/locale/en_GB/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  23. data/locale/en_GB/foreman_remote_execution.po +41 -149
  24. data/locale/es/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  25. data/locale/es/foreman_remote_execution.po +210 -320
  26. data/locale/foreman_remote_execution.pot +211 -394
  27. data/locale/fr/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  28. data/locale/fr/foreman_remote_execution.po +241 -353
  29. data/locale/ja/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  30. data/locale/ja/foreman_remote_execution.po +261 -368
  31. data/locale/ko/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  32. data/locale/ko/foreman_remote_execution.po +53 -161
  33. data/locale/pt_BR/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  34. data/locale/pt_BR/foreman_remote_execution.po +225 -335
  35. data/locale/ru/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  36. data/locale/ru/foreman_remote_execution.po +53 -161
  37. data/locale/zh_CN/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  38. data/locale/zh_CN/foreman_remote_execution.po +359 -465
  39. data/locale/zh_TW/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  40. data/locale/zh_TW/foreman_remote_execution.po +54 -162
  41. data/webpack/JobWizard/JobWizard.js +10 -52
  42. data/webpack/JobWizard/JobWizard.scss +1 -5
  43. data/webpack/JobWizard/JobWizardConstants.js +1 -1
  44. data/webpack/JobWizard/__tests__/__snapshots__/integration.test.js.snap +0 -8
  45. data/webpack/JobWizard/__tests__/fixtures.js +0 -5
  46. data/webpack/JobWizard/__tests__/integration.test.js +0 -15
  47. data/webpack/JobWizard/__tests__/validation.test.js +0 -27
  48. data/webpack/JobWizard/autofill.js +2 -6
  49. data/webpack/JobWizard/steps/AdvancedFields/__tests__/AdvancedFields.test.js +0 -19
  50. data/webpack/JobWizard/steps/AdvancedFields/__tests__/__snapshots__/AdvancedFields.test.js.snap +1 -9
  51. data/webpack/JobWizard/steps/HostsAndInputs/HostPreviewModal.js +0 -3
  52. data/webpack/JobWizard/steps/HostsAndInputs/HostSearch.js +4 -28
  53. data/webpack/JobWizard/steps/HostsAndInputs/__tests__/HostsAndInputs.test.js +2 -32
  54. data/webpack/JobWizard/steps/HostsAndInputs/buildHostQuery.js +10 -16
  55. data/webpack/JobWizard/steps/HostsAndInputs/index.js +3 -55
  56. data/webpack/JobWizard/steps/Schedule/QueryType.js +1 -1
  57. data/webpack/JobWizard/steps/Schedule/RepeatHour.js +1 -0
  58. data/webpack/JobWizard/steps/Schedule/__tests__/Schedule.test.js +5 -25
  59. data/webpack/JobWizard/steps/form/DateTimePicker.js +1 -0
  60. data/webpack/JobWizard/steps/form/Formatter.js +8 -30
  61. data/webpack/JobWizard/steps/form/GroupedSelectField.js +1 -0
  62. data/webpack/JobWizard/steps/form/SelectField.js +1 -0
  63. data/webpack/JobWizard/submit.js +2 -13
  64. data/webpack/react_app/components/RecentJobsCard/RecentJobsCard.js +4 -4
  65. data/webpack/react_app/components/RecentJobsCard/RecentJobsTable.js +2 -2
  66. data/webpack/react_app/components/RecentJobsCard/constants.js +2 -2
  67. metadata +5 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bb6aa7e8d08233993c7f908975b7688460969ad1182b008ab8697767a772fffc
4
- data.tar.gz: 8e1096d3d25655600889f7abecd499f7157d344a82f8ead12fc226b4ba180eb4
3
+ metadata.gz: a4f0a9c455ec484caac7631cec3d1ed8eff22263c96036d7837fdbb86f3faab8
4
+ data.tar.gz: a73788ec230b20cfd6050733d40f27a59d7bf26d334ce51f0b422aae1a64a68e
5
5
  SHA512:
6
- metadata.gz: fa738c870c881c464e22ca4d59361e6ca8c28c878dfa368c09c3c31ea7766fabfe2ddfac585dfe1fdb401d16b56a80bf1a645d53d7df633a8a527b2bc56fec57
7
- data.tar.gz: 2db1f5515cc9b3570d629a0a9149883b7691d4bcd3ebfb8e7383604665bd424b78df968949848c661f5ab22350fc4769ceaa524e74550f6402c20c759ab9e212
6
+ metadata.gz: cb1ef923190e046bc4f9c688ac1040f26e521e7a96a7a154fd461a650d25b04875572e26b75f57dfb425401ae2bf8e82447eb01c635006eb9b51b36df168b999
7
+ data.tar.gz: 3e47f08ded8554ff2b38c50f7d16b8705441ece2753df227181d7782426c7c320476220f5b12dee496216cda119467ff3a0348f7821811dda702e8a9d852c1f3
@@ -13,6 +13,8 @@ jobs:
13
13
  runs-on: ubuntu-latest
14
14
  steps:
15
15
  - uses: actions/checkout@v2
16
+ - run: sudo apt-get update
17
+ - run: sudo apt-get install libyaml-dev
16
18
  - name: Setup Ruby
17
19
  uses: ruby/setup-ruby@v1
18
20
  with:
@@ -42,7 +44,7 @@ jobs:
42
44
  node-version: [12]
43
45
  steps:
44
46
  - run: sudo apt-get update
45
- - run: sudo apt-get install build-essential libcurl4-openssl-dev zlib1g-dev libpq-dev
47
+ - run: sudo apt-get install build-essential libcurl4-openssl-dev zlib1g-dev libpq-dev libyaml-dev
46
48
  - uses: actions/checkout@v2
47
49
  with:
48
50
  repository: theforeman/foreman
@@ -71,7 +71,6 @@ module Api
71
71
  param :description_format, String, :required => false, :desc => N_('Override the description format from the template for this invocation only')
72
72
  param :execution_timeout_interval, Integer, :required => false, :desc => N_('Override the timeout interval from the template for this invocation only')
73
73
  param :feature, String, :required => false, :desc => N_('Remote execution feature label that should be triggered, job template assigned to this feature will be used')
74
- param :time_to_pickup, Integer, :required => false, :desc => N_('Override the global time to pickup interval for this invocation only')
75
74
 
76
75
  RemoteExecutionProvider.providers.each_value do |provider|
77
76
  next if !provider.respond_to?(:provider_inputs_doc) || provider.provider_inputs_doc.empty?
@@ -120,25 +120,6 @@ class JobInvocationsController < ApplicationController
120
120
  redirect_back(:fallback_location => job_invocation_path(@job_invocation))
121
121
  end
122
122
 
123
- def preview_job_invocations_per_host
124
- job_invocations = resource_base.search_for("targeted_host_id = #{params[:host_id]} and (status=#{params[:status]})").limit(params[:limit] || 3)
125
-
126
- job_invocations = job_invocations.map do |job|
127
- @job_invocation = job
128
- template_invocation = job.template_invocations.find { |template_inv| template_inv.host_id == params[:host_id].to_i }
129
- task = template_invocation.try(:run_host_job_task)
130
- status_mapper = task ? HostStatus::ExecutionStatus::ExecutionTaskStatusMapper.new(task) : job
131
- {
132
- start_at: job.start_at,
133
- description: job.description,
134
- id: job.id,
135
- status: status_mapper.status,
136
- status_label: status_mapper.status_label,
137
- }
138
- end
139
- render :json => {:job_invocations => job_invocations}
140
- end
141
-
142
123
  private
143
124
 
144
125
  def action_permission
@@ -149,7 +130,7 @@ class JobInvocationsController < ApplicationController
149
130
  'create'
150
131
  when 'cancel'
151
132
  'cancel'
152
- when 'chart', 'preview_job_invocations_per_host'
133
+ when 'chart'
153
134
  'view'
154
135
  else
155
136
  super
@@ -13,13 +13,11 @@ class UiJobWizardController < ApplicationController
13
13
  def template
14
14
  job_template = JobTemplate.authorized.find(params[:id])
15
15
  advanced_template_inputs, template_inputs = map_template_inputs(job_template.template_inputs_with_foreign).partition { |x| x["advanced"] }
16
- provider_inputs = job_template.provider.provider_inputs.map { |input| input.instance_values.merge({:provider_input => true, default: input.value }) }
17
16
  render :json => {
18
17
  :job_template => job_template,
19
18
  :effective_user => job_template.effective_user,
20
19
  :template_inputs => template_inputs,
21
- :provider_name => job_template.provider.provider_input_namespace,
22
- :advanced_template_inputs => advanced_template_inputs+provider_inputs,
20
+ :advanced_template_inputs => advanced_template_inputs,
23
21
  }
24
22
  end
25
23
 
@@ -238,7 +238,7 @@ module RemoteExecutionHelper
238
238
 
239
239
  def load_template_from_task(template_invocation, target)
240
240
  task = template_invocation.job_invocation.sub_task_for_host(target)
241
- return if [nil, 'scheduled', 'planning'].include?(task&.state)
241
+ return if task.nil?
242
242
 
243
243
  task.execution_plan.actions[1].try(:input).try(:[], 'script')
244
244
  end
@@ -180,7 +180,7 @@ module Actions
180
180
  end
181
181
 
182
182
  def exit_status
183
- input[:with_event_logging] ? task.template_invocation.template_invocation_events.find_by(event_type: 'exit')&.event : delegated_output[:exit_status]
183
+ input[:with_event_logging] ? task.template_invocation.template_invocation_events.find_by(event_type: 'exit').event : delegated_output[:exit_status]
184
184
  end
185
185
 
186
186
  def host_id
@@ -1,6 +1,6 @@
1
1
  object @job_invocation
2
2
 
3
- attributes :id, :description, :job_category, :targeting_id, :status, :start_at, :status_label, :ssh_user, :time_to_pickup
3
+ attributes :id, :description, :job_category, :targeting_id, :status, :start_at, :status_label, :ssh_user
4
4
 
5
5
  node do |invocation|
6
6
  {
@@ -127,7 +127,7 @@
127
127
  </div>
128
128
 
129
129
  <div class="form-group">
130
- <%= add_label({ :label => _('Type of query'), :label_help => _("Type has impact on when is the query evaluated to hosts.<br><ul><li><b>Static</b> - evaluates just after you submit this form</li><li><b>Dynamic</b> - evaluates just before the execution is started, so if it's planned in future, targeted hosts set may change before it</li></ul>") }, f, :targetting_type) %>
130
+ <%= add_label({ :label => _('Type of query'), :label_help => _("Type has impact on when is the query evaluated to hosts.<br><ul><li><b>Static</b> - evaluates just after you submit this form</li><li><b>Dynamic</b> - evaluates just before the execution is started, so if it's planed in future, targeted hosts set may change before it</li></ul>") }, f, :targetting_type) %>
131
131
 
132
132
  <div class="col-md-4">
133
133
  <%= radio_button_f targeting_fields, :targeting_type, :value => Targeting::STATIC_TYPE, :text => _(Targeting::TYPES[Targeting::STATIC_TYPE]) %>
@@ -1,6 +1,6 @@
1
1
  <% title @job_invocation.description %>
2
2
  <% stylesheet 'foreman_remote_execution/foreman_remote_execution' %>
3
- <% javascript 'foreman_remote_execution/template_invocation' %>
3
+ <% javascript 'charts', 'foreman_remote_execution/template_invocation' %>
4
4
  <% javascript *webpack_asset_paths('foreman_remote_execution', :extension => 'js') %>
5
5
  <% content_for(:stylesheets) do %>
6
6
  <%= webpacked_plugins_css_for :foreman_remote_execution %>
@@ -9,6 +9,6 @@
9
9
  <p><%= link_to _('Learn more about this in the documentation.'),
10
10
  documentation_url('1.ForemanRemoteExecution1.3Manual', :root_url => 'https://www.theforeman.org/plugins/foreman_remote_execution/1.3/index.html#'), :rel => 'external' %></p>
11
11
  <div class="blank-slate-pf-main-action">
12
- <%= display_link_if_authorized(_("Run Job"), { :action => :create }, { :class => "btn btn-primary btn-lg" }) %>
12
+ <%= new_link(_("Run Job"), {}, { :class => "btn-lg" }) %>
13
13
  </div>
14
14
  </div>
data/config/routes.rb CHANGED
@@ -23,7 +23,6 @@ Rails.application.routes.draw do
23
23
  match 'old/job_invocations/:id/rerun', to: 'job_invocations#rerun', via: [:get, :post], as: 'form_rerun_job_invocation'
24
24
  resources :job_invocations, :only => [:create, :show, :index] do
25
25
  collection do
26
- get 'preview_job_invocations_per_host'
27
26
  post 'refresh'
28
27
  get 'chart'
29
28
  get 'preview_hosts'
@@ -1,5 +1,5 @@
1
1
  class RexSettingCategoryToDsl < ActiveRecord::Migration[6.0]
2
2
  def up
3
- Setting.where(category: 'Setting::RemoteExecution').update_all(category: 'Setting') if column_exists?(:settings, :category)
3
+ Setting.where(category: 'Setting::RemoteExecution').update_all(category: 'Setting')
4
4
  end
5
5
  end
@@ -170,41 +170,24 @@ class Relay
170
170
  def initialize(proxy, params)
171
171
  @proxy = proxy
172
172
  @params = params
173
- @inject_authorization = @params['ssh_user'] != 'root' && @params['effective_user_password']
174
173
  end
175
174
 
176
175
  def proxy_loop
177
176
  proxy1 = ProxyBuffer.new($stdin, @sock)
178
177
  proxy2 = ProxyBuffer.new(@sock, $stdout)
179
178
  proxy2.on_data do |data|
180
- if @inject_authorization
181
- sio = StringIO.new(data)
182
- begin
183
- message = Cockpit.read_control(sio)
184
- rescue StandardError
185
- # We're looking for one specific message, but the expectation that one
186
- # invocation of this callback processes one message doesn't really
187
- # hold. The message we're looking for is sent quite early in the
188
- # communication, if at all, so the chance that it will be aligned with
189
- # the beginning of the buffer is quite high. If we somehow fail to
190
- # process the contents of the buffer, we should just carry on.
191
- #
192
- # With the authorization injection check in place, this is more of a
193
- # precaution so that unexpectedly big message won't bring the entire
194
- # thing down.
195
- end
196
- if message.is_a?(Hash) && message['command'] == 'authorize'
197
- response = {
198
- 'command' => 'authorize',
199
- 'cookie' => message['cookie'],
200
- 'response' => @params['effective_user_password'],
201
- }
202
- proxy1.enqueue(Cockpit.encode_message(response))
203
- @inject_authorization = false
204
- data = sio.read # Return whatever was left unread after read_control
205
- end
179
+ message = Cockpit.read_control(StringIO.new(data))
180
+ if message.is_a?(Hash) && message['command'] == 'authorize'
181
+ response = {
182
+ 'command' => 'authorize',
183
+ 'cookie' => message['cookie'],
184
+ 'response' => @params['effective_user_password'],
185
+ }
186
+ proxy1.enqueue(Cockpit.encode_message(response))
187
+ ''
188
+ else
189
+ data
206
190
  end
207
- data
208
191
  end
209
192
 
210
193
  proxies = [proxy1, proxy2]
@@ -288,7 +271,7 @@ class Relay
288
271
  end
289
272
  raise AccessDeniedError, message
290
273
  else
291
- raise CockpitError, "Error talking to smart proxy: #{body}"
274
+ raise CockpitError, "Error talking to smart proxy: #{response}"
292
275
  end
293
276
  end
294
277
  end
@@ -47,7 +47,7 @@ module ForemanRemoteExecution
47
47
 
48
48
  initializer 'foreman_remote_execution.register_plugin', before: :finisher_hook do |_app|
49
49
  Foreman::Plugin.register :foreman_remote_execution do
50
- requires_foreman '>= 3.4'
50
+ requires_foreman '>= 3.6'
51
51
  register_global_js_file 'global'
52
52
 
53
53
  apipie_documented_controllers ["#{ForemanRemoteExecution::Engine.root}/app/controllers/api/v2/*.rb"]
@@ -183,7 +183,7 @@ module ForemanRemoteExecution
183
183
  permission :lock_job_templates, { :job_templates => [:lock, :unlock] }, :resource_type => 'JobTemplate'
184
184
  permission :create_job_invocations, { :job_invocations => [:new, :create, :refresh, :rerun, :preview_hosts],
185
185
  'api/v2/job_invocations' => [:create, :rerun] }, :resource_type => 'JobInvocation'
186
- permission :view_job_invocations, { :job_invocations => [:index, :chart, :show, :auto_complete_search, :preview_job_invocations_per_host], :template_invocations => [:show],
186
+ permission :view_job_invocations, { :job_invocations => [:index, :chart, :show, :auto_complete_search], :template_invocations => [:show],
187
187
  'api/v2/job_invocations' => [:index, :show, :output, :raw_output, :outputs] }, :resource_type => 'JobInvocation'
188
188
  permission :view_template_invocations, { :template_invocations => [:show],
189
189
  'api/v2/template_invocations' => [:template_invocations], :ui_job_wizard => [:job_invocation] }, :resource_type => 'TemplateInvocation'
@@ -1,3 +1,3 @@
1
1
  module ForemanRemoteExecution
2
- VERSION = '8.3.1'.freeze
2
+ VERSION = '9.0.0'.freeze
3
3
  end
@@ -1,5 +1,5 @@
1
1
  # Autogenerated!
2
- _("Action with sub plans")
2
+ _("Remote action:")
3
3
  _("Import Puppet classes")
4
4
  _("Import facts")
5
- _("Remote action:")
5
+ _("Action with sub plans")