foreman_remote_execution 4.0.0 → 4.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 93860edb8974a0691383b3a199a1a2d079d10401d7780b99aa6275b75125eb58
4
- data.tar.gz: d333f8eb85a42b36694dee932447d4364b57ed2c095ad5a055d1e7adf69a9866
3
+ metadata.gz: 1ed74f64c21956170e95cbab53cd7580205f0620166573980c12efe06e90b960
4
+ data.tar.gz: 6ca59984908170bc003eb797883bb37c53c5a01a9f5a7bb5a95db2c8242b1fb5
5
5
  SHA512:
6
- metadata.gz: 70c300e719d6587639719a4d95aa23da2d3f3a16d51692392c789b70cd381b31320789db0f45b57c129e4b90d36bd1a8ddadd29db4f38f2d9e40a39219b1d130
7
- data.tar.gz: 1feab0c5cfd3fee6054a004eba812b7257df80a2dce50aa200d15dd20797f24f8a614d802668ac6daf043c189b7caa8e8d5f0d4a997726764c80c91173d9437b
6
+ metadata.gz: '0588d33348d69b3ecae2b0c50c143f564a8f32fbff548e31b7da2a8b055b2e400784136f4eb98fc4d2d26740d907ced7cb27522856c6fcbf8736cf94fc5e2a93'
7
+ data.tar.gz: 1069f8025c92c09c3e9c780ae8b5040e8dd15c5a282d76a9195569226b18c0801e5dc533635c804d4f3e377bebcd48501de57abd9141040c6b46b13e7496415b
@@ -0,0 +1,21 @@
1
+ module ForemanRemoteExecution
2
+ module Concerns
3
+ module Api::V2::SubnetsControllerExtensions
4
+ module ApiPieExtensions
5
+ extend ::Apipie::DSL::Concern
6
+
7
+ update_api(:create, :update) do
8
+ param :subnet, Hash do
9
+ param :remote_execution_proxy_ids, Array, _('List of proxy IDs to be used for remote execution')
10
+ end
11
+ end
12
+ end
13
+
14
+ extend ActiveSupport::Concern
15
+
16
+ included do
17
+ include ApiPieExtensions
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,10 +1,11 @@
1
1
  # frozen_string_literal:true
2
2
 
3
3
  module JobInvocationsHelper
4
- def minicard(icon, number, text)
4
+ def minicard(icon, number, text, tooltip: nil)
5
+ tooltip_options = tooltip ? { :'data-original-title' => tooltip, :rel => 'twipsy' } : {}
5
6
  content_tag(:div, :class => 'card-pf card-pf-accented
6
7
  card-pf-aggregate-status card-pf-aggregate-status-mini') do
7
- content_tag(:h2, :class => 'card-pf-title', :style => 'line-height: 1.1') do
8
+ content_tag(:h2, { :class => 'card-pf-title', :style => 'line-height: 1.1' }.merge(tooltip_options)) do
8
9
  icon_text(icon, '', :kind => 'pficon') +
9
10
  content_tag(:span, number, :class =>'card-pf-aggregate-status-count') +
10
11
  text
@@ -57,7 +57,8 @@ module Actions
57
57
  end
58
58
 
59
59
  def job_invocation
60
- @job_invocation ||= JobInvocation.find(input[:job_invocation_id])
60
+ id = input[:job_invocation_id] || input.fetch(:job_invocation, {})[:id]
61
+ @job_invocation ||= JobInvocation.find(id)
61
62
  end
62
63
 
63
64
  def batch(from, size)
@@ -65,7 +66,7 @@ module Actions
65
66
  end
66
67
 
67
68
  def total_count
68
- hosts.count
69
+ output[:total_count] || hosts.count
69
70
  end
70
71
 
71
72
  def hosts
@@ -0,0 +1,13 @@
1
+ module Api
2
+ module V2
3
+ module InterfacesControllerExtensions
4
+ extend Apipie::DSL::Concern
5
+
6
+ update_api(:create, :update) do
7
+ param :interface, Hash do
8
+ param :execution, :bool, :desc => N_('Should this interface be used for remote execution?')
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -173,7 +173,7 @@ class JobInvocation < ApplicationRecord
173
173
 
174
174
  def total_hosts_count
175
175
  if targeting.resolved?
176
- targeting.hosts.count
176
+ task&.main_action&.total_count || targeting.hosts.count
177
177
  else
178
178
  _('N/A')
179
179
  end
@@ -243,6 +243,10 @@ class JobInvocation < ApplicationRecord
243
243
  !task.pending?
244
244
  end
245
245
 
246
+ def missing_hosts_count
247
+ targeting.resolved? ? total_hosts_count - targeting.hosts.count : 0
248
+ end
249
+
246
250
  private
247
251
 
248
252
  def failed_template_invocations
@@ -0,0 +1 @@
1
+ attributes :execution
@@ -8,6 +8,7 @@ node do |invocation|
8
8
  :failed => invocation_count(invocation, :output_key => :failed_count),
9
9
  :pending => invocation_count(invocation, :output_key => :pending_count),
10
10
  :total => invocation_count(invocation, :output_key => :total_count),
11
+ :missing => invocation.missing_hosts_count,
11
12
  }
12
13
  end
13
14
 
@@ -0,0 +1,3 @@
1
+ child :remote_execution_proxies => :remote_execution_proxies do
2
+ attributes :name, :id
3
+ end
@@ -9,7 +9,19 @@
9
9
  <% template_invocations.each do |template_invocation| %>
10
10
  <%= minicard('user', template_invocation.effective_user || Setting[:remote_execution_effective_user],
11
11
  template_invocation.template.name + ' ' + _('effective user')) %>
12
- <%= minicard('cluster', job_invocation.total_hosts_count, _('Total hosts')) %>
12
+ <div class="row">
13
+ <% missing = job_invocation.missing_hosts_count %>
14
+ <% size = missing.zero? ? 12 : 6 %>
15
+ <div class="col-xs-12 col-sm-<%= size %> col-md-<%= size %>" >
16
+ <%= minicard('cluster', job_invocation.total_hosts_count, _('Total hosts')) %>
17
+ </div>
18
+ <% unless missing.zero? %>
19
+ <div class="col-xs-12 col-sm-6 col-md-6" >
20
+ <%= minicard('warning-triangle-o', missing, _('Hosts gone missing'),
21
+ :tooltip => _('This can happen if the host is removed or moved to another organization or location after the job was started')) %>
22
+ </div>
23
+ <% end %>
24
+ </div>
13
25
  <% if template_invocation.input_values.present? %>
14
26
  <%= render :partial => 'card_user_input', :locals => { :template_invocation => template_invocation } %>
15
27
  <% end %>
@@ -32,6 +32,15 @@ module ForemanRemoteExecution
32
32
  end
33
33
  end
34
34
 
35
+ # A workaround for https://projects.theforeman.org/issues/30685
36
+ initializer 'foreman_remote_execution.rails_loading_workaround' do
37
+ # Without this, in production environment the module gets prepended too
38
+ # late and the extensions do not get applied
39
+ # TODO: Remove this and from config.to_prepare once there is an extension
40
+ # point in Foreman
41
+ ProvisioningTemplatesHelper.prepend ForemanRemoteExecution::JobTemplatesExtensions
42
+ end
43
+
35
44
  initializer 'foreman_remote_execution.apipie' do
36
45
  Apipie.configuration.checksum_path += ['/api/']
37
46
  end
@@ -138,6 +147,9 @@ module ForemanRemoteExecution
138
147
  end
139
148
 
140
149
  extend_rabl_template 'api/v2/smart_proxies/main', 'api/v2/smart_proxies/pubkey'
150
+ extend_rabl_template 'api/v2/interfaces/main', 'api/v2/interfaces/execution_flag'
151
+ extend_rabl_template 'api/v2/subnets/show', 'api/v2/subnets/remote_execution_proxies'
152
+ parameter_filter ::Subnet, :remote_execution_proxy_ids
141
153
  describe_host { overview_buttons_provider :host_overview_buttons }
142
154
  end
143
155
  end
@@ -184,6 +196,7 @@ module ForemanRemoteExecution
184
196
  SmartProxy.prepend ForemanRemoteExecution::SmartProxyExtensions
185
197
  Subnet.include ForemanRemoteExecution::SubnetExtensions
186
198
 
199
+ ::Api::V2::InterfacesController.include Api::V2::InterfacesControllerExtensions
187
200
  # We need to explicitly force to load the Task model due to Rails loader
188
201
  # having issues with resolving it to Rake::Task otherwise
189
202
  require_dependency 'foreman_tasks/task'
@@ -192,6 +205,8 @@ module ForemanRemoteExecution
192
205
  RemoteExecutionProvider.register(:SSH, SSHExecutionProvider)
193
206
 
194
207
  ForemanRemoteExecution.register_rex_feature
208
+
209
+ ::Api::V2::SubnetsController.include ::ForemanRemoteExecution::Concerns::Api::V2::SubnetsControllerExtensions
195
210
  end
196
211
 
197
212
  initializer 'foreman_remote_execution.register_gettext', after: :load_config_initializers do |_app|
@@ -1,3 +1,3 @@
1
1
  module ForemanRemoteExecution
2
- VERSION = '4.0.0'.freeze
2
+ VERSION = '4.1.0'.freeze
3
3
  end
@@ -73,7 +73,7 @@ module ForemanRemoteExecution
73
73
  end
74
74
 
75
75
  it 'triggers the RunHostJob actions on the resolved hosts in run phase' do
76
- planned.expects(:output).returns(:planned_count => 0)
76
+ planned.expects(:output).at_most(5).returns(:planned_count => 0)
77
77
  planned.expects(:trigger).with { |*args| args[0] == Actions::RemoteExecution::RunHostJob }
78
78
  planned.create_sub_plans
79
79
  end
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: 4.0.0
4
+ version: 4.1.0
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: 2020-08-13 00:00:00.000000000 Z
11
+ date: 2020-09-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: deface
@@ -154,6 +154,7 @@ files:
154
154
  - app/controllers/concerns/foreman/controller/parameters/job_template.rb
155
155
  - app/controllers/concerns/foreman/controller/parameters/remote_execution_feature.rb
156
156
  - app/controllers/concerns/foreman/controller/parameters/targeting.rb
157
+ - app/controllers/foreman_remote_execution/concerns/api/v2/subnets_controller_extensions.rb
157
158
  - app/controllers/job_invocations_controller.rb
158
159
  - app/controllers/job_templates_controller.rb
159
160
  - app/controllers/remote_execution_features_controller.rb
@@ -170,6 +171,7 @@ files:
170
171
  - app/lib/foreman_remote_execution/renderer/scope/input.rb
171
172
  - app/lib/proxy_api/remote_execution_ssh.rb
172
173
  - app/mailers/.gitkeep
174
+ - app/models/concerns/api/v2/interfaces_controller_extensions.rb
173
175
  - app/models/concerns/foreman_remote_execution/bookmark_extensions.rb
174
176
  - app/models/concerns/foreman_remote_execution/errors_flattener.rb
175
177
  - app/models/concerns/foreman_remote_execution/foreman_tasks_cleaner_extensions.rb
@@ -212,6 +214,7 @@ files:
212
214
  - app/views/api/v2/foreign_input_sets/index.json.rabl
213
215
  - app/views/api/v2/foreign_input_sets/main.json.rabl
214
216
  - app/views/api/v2/foreign_input_sets/show.json.rabl
217
+ - app/views/api/v2/interfaces/execution_flag.json.rabl
215
218
  - app/views/api/v2/job_invocations/base.json.rabl
216
219
  - app/views/api/v2/job_invocations/create.json.rabl
217
220
  - app/views/api/v2/job_invocations/index.json.rabl
@@ -228,6 +231,7 @@ files:
228
231
  - app/views/api/v2/remote_execution_features/main.json.rabl
229
232
  - app/views/api/v2/remote_execution_features/show.json.rabl
230
233
  - app/views/api/v2/smart_proxies/pubkey.json.rabl
234
+ - app/views/api/v2/subnets/remote_execution_proxies.json.rabl
231
235
  - app/views/api/v2/template_invocations/base.json.rabl
232
236
  - app/views/api/v2/template_invocations/template_invocations.json.rabl
233
237
  - app/views/dashboard/.gitkeep