foreman_remote_execution 5.0.1 → 5.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/helpers/concerns/foreman_remote_execution/hosts_helper_extensions.rb +20 -9
- data/app/helpers/remote_execution_helper.rb +4 -3
- data/app/models/concerns/foreman_remote_execution/host_extensions.rb +4 -0
- data/app/models/concerns/foreman_remote_execution/nic_extensions.rb +6 -4
- data/app/models/targeting.rb +1 -1
- data/app/views/dashboard/_latest-jobs.html.erb +1 -1
- data/app/views/job_invocations/_preview_hosts_list.html.erb +1 -1
- data/app/views/template_invocations/show.html.erb +1 -1
- data/app/views/templates/ssh/package_action.erb +3 -0
- data/lib/foreman_remote_execution/engine.rb +5 -1
- data/lib/foreman_remote_execution/version.rb +1 -1
- data/test/unit/concerns/host_extensions_test.rb +2 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 59eae566c2961d0c2d5cca855d76ece120748f1c1f6303a5b2fca5928f1b4840
|
4
|
+
data.tar.gz: 1cbb8e8f418e8b8c5823b9b875eed46873735da31b5214601acc60f236d650b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77c04207ff68fc2cf97061b77b2d06c40b51f197d2cceb4fa803dc29e2e3512eb4b048131964414f2e29dbc23e2a460b1ff46566718b79e804f7632b375f12ea
|
7
|
+
data.tar.gz: d9bf1681d7e5834c3cc16941a90c4c4c73db3d1b4e812c91b88ffe866bcb27f52eae3841a49740f77c50d0f8fd570203ea7f4f5100cc855ea140403cd0bda49e
|
@@ -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
|
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(*
|
26
|
-
return unless
|
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 => [
|
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(*
|
33
|
-
return unless
|
34
|
-
link_to(_('Schedule Remote Job'), new_job_invocation_path(:host_ids => [
|
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
|
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:
|
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)
|
@@ -3,16 +3,18 @@ module ForemanRemoteExecution
|
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
5
|
included do
|
6
|
-
before_validation :set_execution_flag
|
7
6
|
validate :exclusive_execution_interface
|
7
|
+
before_validation :move_execution_flag
|
8
8
|
end
|
9
9
|
|
10
10
|
private
|
11
11
|
|
12
|
-
def
|
13
|
-
return unless
|
12
|
+
def move_execution_flag
|
13
|
+
return unless host && self.execution?
|
14
14
|
|
15
|
-
|
15
|
+
host.interfaces
|
16
|
+
.select { |i| i.execution? && i != self }
|
17
|
+
.each { |i| i.execution = false }
|
16
18
|
end
|
17
19
|
|
18
20
|
def exclusive_execution_interface
|
data/app/models/targeting.rb
CHANGED
@@ -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),
|
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,
|
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,
|
@@ -67,7 +67,8 @@ class ForemanRemoteExecutionHostExtensionsTest < ActiveSupport::TestCase
|
|
67
67
|
it 'should only have one execution interface' do
|
68
68
|
host.interfaces << FactoryBot.build(:nic_managed)
|
69
69
|
host.interfaces.each { |interface| interface.execution = true }
|
70
|
-
_(host).
|
70
|
+
_(host).must_be :valid?
|
71
|
+
_(host.interfaces.count(&:execution?)).must_equal 1
|
71
72
|
end
|
72
73
|
|
73
74
|
it 'returns the execution interface' do
|
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.
|
4
|
+
version: 5.0.4
|
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:
|
11
|
+
date: 2022-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: deface
|