foreman_remote_execution 5.0.0 → 5.0.3

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: 66efbd042b1d607eeaa4e72b07452ac00a4e68d28bf09e1fc496f26cae25f1e4
4
- data.tar.gz: 124621a113adab399e259ece92caad11fdf35da117da77dc512fc9e31e6ec66a
3
+ metadata.gz: b6101dc3457c93144c655cae80d5d7be64f420cb878166e025a527940d287a41
4
+ data.tar.gz: 1840f3bf32f56c644de27c082a18c3241b145e4ac3d1696e672ffaa2cffd4099
5
5
  SHA512:
6
- metadata.gz: 04ed33fb87e3b0830501f97b95ab62c129897e8510909b47163559854bb0b2b792ccab4035c5fc606a6a8d8e5ff8c084fcfd2109331dff8b4e7a6eac23c86825
7
- data.tar.gz: bca23be551bd1d8169c28a5a4e2d71079ea42cae3a11d6d289f40c9c862a2e7307b6c6e569ba79be7e743f729ef58a3ef72b027ee8735e9c448e4672a105db4b
6
+ metadata.gz: f8f65034a64aa88c9ca2565b8e6543735dd726974751c5adb0a848192fe1098aee310d31b81c6d64862c91120d21766a7b204fe3c6d8b629faa6fa3452e70f79
7
+ data.tar.gz: 5a440b76b2b4f7fd4f2dc5685e2e141fa9cf5811c271d1b067ab5b1d343826e97f6ce177f327cba9e2a4e76b53b7b1b50d1b2fa87873e782998d8aed0234a7e1
@@ -8,7 +8,7 @@ module ForemanRemoteExecution
8
8
 
9
9
  def multiple_actions
10
10
  res = super
11
- res += [ [_('Schedule Remote Job'), new_job_invocation_path, false] ] if authorized_for(controller: :job_invocations, action: :new)
11
+ res += [ [_('Schedule Remote Job'), new_job_invocation_path, false] ] if can_schedule_jobs?
12
12
  res
13
13
  end
14
14
 
@@ -22,20 +22,20 @@ module ForemanRemoteExecution
22
22
  end
23
23
  end
24
24
 
25
- def rex_host_features(*args)
26
- return unless authorized_for(controller: :job_invocations, action: :create)
25
+ def rex_host_features(host, *_rest)
26
+ return [] unless can_execute_on_host?(host)
27
27
  RemoteExecutionFeature.with_host_action_button.order(:label).map do |feature|
28
- link_to(_('%s') % feature.name, job_invocations_path(:host_ids => [args.first.id], :feature => feature.label), :method => :post)
28
+ link_to(_('%s') % feature.name, job_invocations_path(:host_ids => [host.id], :feature => feature.label), :method => :post)
29
29
  end
30
30
  end
31
31
 
32
- def schedule_job_button(*args)
33
- return unless authorized_for(controller: :job_invocations, action: :new)
34
- link_to(_('Schedule Remote Job'), new_job_invocation_path(:host_ids => [args.first.id]), :id => :run_button, :class => 'btn btn-default')
32
+ def schedule_job_button(host, *_rest)
33
+ return unless can_execute_on_host?(host)
34
+ link_to(_('Schedule Remote Job'), new_job_invocation_path(:host_ids => [host.id]), :id => :run_button, :class => 'btn btn-default')
35
35
  end
36
36
 
37
37
  def web_console_button(host, *args)
38
- return unless authorized_for(permission: 'cockpit_hosts', auth_object: host)
38
+ return if !authorized_for(permission: 'cockpit_hosts', auth_object: host) || !can_execute_on_infrastructure_host?(host)
39
39
 
40
40
  url = SSHExecutionProvider.cockpit_url_for_host(host.name)
41
41
  url ? link_to(_('Web Console'), url, :class => 'btn btn-default', :id => :'web-console-button', :target => '_new') : nil
@@ -46,6 +46,17 @@ module ForemanRemoteExecution
46
46
  button_group(web_console_button(*args)))
47
47
  super(*args)
48
48
  end
49
- end
50
49
 
50
+ def can_schedule_jobs?
51
+ authorized_for(controller: :job_invocations, action: :create)
52
+ end
53
+
54
+ def can_execute_on_host?(host)
55
+ can_schedule_jobs? && can_execute_on_infrastructure_host?(host)
56
+ end
57
+
58
+ def can_execute_on_infrastructure_host?(host)
59
+ !host.infrastructure_host? || User.current.can?(:execute_jobs_on_infrastructure_hosts)
60
+ end
61
+ end
51
62
  end
@@ -31,7 +31,7 @@ module RemoteExecutionHelper
31
31
 
32
32
  if authorized_for(hash_for_host_path(host).merge(auth_object: host, permission: :view_hosts, authorizer: job_hosts_authorizer))
33
33
  links << { title: _('Host detail'),
34
- action: { href: host_path(host), 'data-method': 'get', id: "#{host.name}-actions-detail" } }
34
+ action: { href: current_host_details_path(host), 'data-method': 'get', id: "#{host.name}-actions-detail" } }
35
35
  end
36
36
 
37
37
  if authorized_for(hash_for_rerun_job_invocation_path(id: job_invocation, host_ids: [ host.id ], authorizer: job_hosts_authorizer))
@@ -147,9 +147,10 @@ module RemoteExecutionHelper
147
147
  end
148
148
  end
149
149
 
150
- def invocation_description(invocation)
150
+ def invocation_description(invocation, keep_tooltip: true)
151
151
  description = invocation.description.try(:capitalize) || invocation.job_category
152
- trunc_with_tooltip(description, 80)
152
+ description = trunc_with_tooltip(description, 80) if keep_tooltip
153
+ description
153
154
  end
154
155
 
155
156
  def invocation_result(invocation, key)
@@ -121,6 +121,10 @@ module ForemanRemoteExecution
121
121
  @cached_rex_host_params_hash = nil
122
122
  end
123
123
 
124
+ def infrastructure_host?
125
+ infrastructure_facet&.foreman_instance || infrastructure_facet&.smart_proxy_id
126
+ end
127
+
124
128
  private
125
129
 
126
130
  def extend_host_params_hash(params)
@@ -67,7 +67,7 @@ class Targeting < ApplicationRecord
67
67
  return '' if ids.empty?
68
68
 
69
69
  hosts = Host.execution_scope.where(:id => ids).distinct.pluck(:name)
70
- "name ^ (#{hosts.join(', ')})"
70
+ hosts.any? ? "name ^ (#{hosts.join(', ')})" : ''
71
71
  end
72
72
 
73
73
  def resolved?
@@ -10,7 +10,7 @@
10
10
  </tr>
11
11
  <% JobInvocation.latest_jobs.each do |invocation| %>
12
12
  <tr>
13
- <td class="ellipsis"><%= link_to_if_authorized invocation_description(invocation), hash_for_job_invocation_path(invocation).merge(:auth_object => invocation, :permission => :view_job_invocations, :authorizer => authorizer) %></td>
13
+ <td class="ellipsis"><%= link_to_if_authorized invocation_description(invocation, keep_tooltip: false), hash_for_job_invocation_path(invocation).merge(:auth_object => invocation, :permission => :view_job_invocations, :authorizer => authorizer) %></td>
14
14
  <td><%= link_to_invocation_task_if_authorized(invocation) %></td>
15
15
  <td><%= time_in_words_span(invocation.start_at) %></td>
16
16
  </tr>
@@ -7,7 +7,7 @@
7
7
  <% if @hosts.any? -%>
8
8
  <ul>
9
9
  <% @hosts.each do |host| -%>
10
- <li><%= link_to h(host.name), host_path(host), :target => '_blank' %></li>
10
+ <li><%= link_to h(host.name), current_host_details_path(host), :target => '_blank' %></li>
11
11
  <% end -%>
12
12
 
13
13
  <% if @additional > 0 -%>
@@ -28,7 +28,7 @@ end
28
28
  </div>
29
29
  </div>
30
30
  <% if @host %>
31
- <h3><%= _('Target: ') %><%= link_to(@host.name, host_path(@host)) %></h3>
31
+ <h3><%= _('Target: ') %><%= link_to(@host.name, current_host_details_path(@host)) %></h3>
32
32
 
33
33
  <div class="preview hidden">
34
34
  <%= preview_box(@template_invocation, @host) %>
@@ -214,7 +214,11 @@ module ForemanRemoteExecution
214
214
  role 'Remote Execution User', USER_PERMISSIONS, 'Role with permissions to run remote execution jobs against hosts'
215
215
  role 'Remote Execution Manager', MANAGER_PERMISSIONS, 'Role with permissions to manage job templates, remote execution features, cancel jobs and view audit logs'
216
216
 
217
- add_all_permissions_to_default_roles
217
+ add_all_permissions_to_default_roles(except: [:execute_jobs_on_infrastructure_hosts])
218
+ add_permissions_to_default_roles({
219
+ Role::MANAGER => [:execute_jobs_on_infrastructure_hosts],
220
+ Role::SITE_MANAGER => USER_PERMISSIONS + [:execute_jobs_on_infrastructure_hosts],
221
+ })
218
222
 
219
223
  # add menu entry
220
224
  menu :top_menu, :job_templates,
@@ -1,3 +1,3 @@
1
1
  module ForemanRemoteExecution
2
- VERSION = '5.0.0'.freeze
2
+ VERSION = '5.0.3'.freeze
3
3
  end
data/package.json CHANGED
@@ -30,7 +30,9 @@
30
30
  "eslint": "^6.8.0",
31
31
  "prettier": "^1.19.1",
32
32
  "@patternfly/react-catalog-view-extension": "^4.8.126",
33
- "redux-mock-store": "^1.2.2"
33
+ "redux-mock-store": "^1.2.2",
34
+ "graphql-tag": "^2.11.0",
35
+ "graphql": "^15.5.0"
34
36
  },
35
37
  "peerDependencies": {
36
38
  "@theforeman/vendor": "^8.16.0"
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: 5.0.0
4
+ version: 5.0.3
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: 2021-11-16 00:00:00.000000000 Z
11
+ date: 2022-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: deface