foreman_remote_execution 1.4.3 → 1.4.4
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 +4 -4
- data/app/assets/javascripts/{execution_interface.js → foreman_remote_execution/execution_interface.js} +0 -0
- data/app/assets/javascripts/{job_templates.js → foreman_remote_execution/job_templates.js} +0 -0
- data/app/assets/javascripts/{template_input.js → foreman_remote_execution/template_input.js} +0 -0
- data/app/assets/javascripts/{template_invocation.js → foreman_remote_execution/template_invocation.js} +0 -0
- data/app/assets/stylesheets/{job_invocations.css.scss → foreman_remote_execution/job_invocations.css.scss} +0 -0
- data/app/assets/stylesheets/{modal_window.css.scss → foreman_remote_execution/modal_window.css.scss} +0 -0
- data/app/assets/stylesheets/{template_invocation.css.scss → foreman_remote_execution/template_invocation.css.scss} +0 -0
- data/app/helpers/job_invocation_output_helper.rb +41 -0
- data/app/lib/actions/remote_execution/run_hosts_job.rb +6 -0
- data/app/models/job_invocation.rb +8 -0
- data/app/services/ui_notifications/remote_execution_jobs/base_job_finish.rb +31 -0
- data/app/views/job_invocations/_preview_hosts_modal.html.erb +1 -1
- data/app/views/job_invocations/new.html.erb +2 -2
- data/app/views/job_invocations/show.html.erb +2 -2
- data/app/views/job_templates/_import_job_template_modal.html.erb +1 -1
- data/app/views/job_templates/edit.html.erb +1 -1
- data/app/views/job_templates/index.html.erb +2 -2
- data/app/views/job_templates/new.html.erb +1 -1
- data/app/views/template_invocations/_output_line_set.html.erb +1 -1
- data/app/views/template_invocations/show.html.erb +2 -2
- data/db/seeds.d/50-notification_blueprints.rb +18 -0
- data/lib/foreman_remote_execution/version.rb +1 -1
- data/test/unit/actions/run_hosts_job_test.rb +9 -0
- metadata +12 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e8f5aba0c8857327a44b058d06cb31e6c576de5
|
4
|
+
data.tar.gz: d2c6316d816a5db84313aa90067d87c40a66940c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4bd554adff07566ba0e32974f2de649cae60918660b725cb7bdbbebe41a5bf0fa2b8389f4801b121b585c68cc50db01715d787df1a87134551499d69e2c8989d
|
7
|
+
data.tar.gz: 4504b9532f5db6be4c371b435b5edbd230e080c15060d8706f50bc254421f435d244b57b1446220ea7516de1dc571e3b5eb2e7e0a3ff2089a9aecad5498c8842
|
File without changes
|
File without changes
|
data/app/assets/javascripts/{template_input.js → foreman_remote_execution/template_input.js}
RENAMED
File without changes
|
File without changes
|
File without changes
|
data/app/assets/stylesheets/{modal_window.css.scss → foreman_remote_execution/modal_window.css.scss}
RENAMED
File without changes
|
File without changes
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module JobInvocationOutputHelper
|
2
|
+
CONSOLE_COLOR = {
|
3
|
+
'31' => 'red',
|
4
|
+
'32' => 'lightgreen',
|
5
|
+
'33' => 'orange',
|
6
|
+
'34' => 'deepskyblue',
|
7
|
+
'35' => 'mediumpurple',
|
8
|
+
'36' => 'cyan',
|
9
|
+
'37' => 'grey',
|
10
|
+
'91' => 'red',
|
11
|
+
'92' => 'lightgreen',
|
12
|
+
'93' => 'yellow',
|
13
|
+
'94' => 'lightblue',
|
14
|
+
'95' => 'violet',
|
15
|
+
'96' => 'turquoise',
|
16
|
+
'0' => 'default',
|
17
|
+
}.tap { |h| h.default = 'default' }.freeze
|
18
|
+
|
19
|
+
def colorize_line(line)
|
20
|
+
line = line.gsub(/\e\[.*?m/) do |seq|
|
21
|
+
color = seq[/(\d+)m/,1]
|
22
|
+
"{{{format color:#{color}}}}"
|
23
|
+
end
|
24
|
+
|
25
|
+
current_color = 'default'
|
26
|
+
out = %{<span style="color: #{@current_color}">}
|
27
|
+
parts = line.split(/({{{format.*?}}})/)
|
28
|
+
parts.each do |console_line|
|
29
|
+
if console_line.include?('{{{format')
|
30
|
+
if (color_index = console_line[/color:(\d+)/, 1]).present?
|
31
|
+
current_color = CONSOLE_COLOR[color_index]
|
32
|
+
out << %{</span><span style="color: #{current_color}">}
|
33
|
+
end
|
34
|
+
else
|
35
|
+
out << h(console_line)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
out << %{</span>}
|
39
|
+
out
|
40
|
+
end
|
41
|
+
end
|
@@ -66,6 +66,12 @@ module Actions
|
|
66
66
|
super unless event == Dynflow::Action::Skip
|
67
67
|
end
|
68
68
|
|
69
|
+
def finalize
|
70
|
+
# creating the success notification should be the very last thing this tasks do
|
71
|
+
job_invocation = JobInvocation.find(input[:job_invocation_id])
|
72
|
+
job_invocation.build_notification.deliver!
|
73
|
+
end
|
74
|
+
|
69
75
|
def humanized_input
|
70
76
|
input.fetch(:job_invocation, {}).fetch(:description, '')
|
71
77
|
end
|
@@ -78,6 +78,14 @@ class JobInvocation < ApplicationRecord
|
|
78
78
|
{ :conditions => sanitize_sql_for_conditions(["foreman_tasks_recurring_logics.id IS #{not_operator} NULL"]), :joins => :recurring_logic }
|
79
79
|
end
|
80
80
|
|
81
|
+
def notification_recipients_ids
|
82
|
+
[ self.targeting.user_id ]
|
83
|
+
end
|
84
|
+
|
85
|
+
def build_notification
|
86
|
+
UINotifications::RemoteExecutionJobs::BaseJobFinish.new(self)
|
87
|
+
end
|
88
|
+
|
81
89
|
def status
|
82
90
|
HostStatus::ExecutionStatus::ExecutionTaskStatusMapper.new(task).status
|
83
91
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module UINotifications
|
2
|
+
module RemoteExecutionJobs
|
3
|
+
class BaseJobFinish < ::UINotifications::Base
|
4
|
+
def initialize(job_invocation)
|
5
|
+
@subject = job_invocation
|
6
|
+
end
|
7
|
+
|
8
|
+
def deliver!
|
9
|
+
::Notification.create!(
|
10
|
+
:audience => Notification::AUDIENCE_USER,
|
11
|
+
:notification_blueprint => blueprint,
|
12
|
+
:initiator => initiator,
|
13
|
+
:message => message,
|
14
|
+
:subject => subject
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
def initiator
|
19
|
+
User.anonymous_admin
|
20
|
+
end
|
21
|
+
|
22
|
+
def blueprint
|
23
|
+
@blueprint ||= NotificationBlueprint.unscoped.find_by(:name => 'rex_job_succeeded')
|
24
|
+
end
|
25
|
+
|
26
|
+
def message
|
27
|
+
UINotifications::StringParser.new(blueprint.message, { subject: subject })
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<% javascript 'template_invocation' %>
|
2
|
-
<% stylesheet 'template_invocation' %>
|
1
|
+
<% javascript 'foreman_remote_execution/template_invocation' %>
|
2
|
+
<% stylesheet 'foreman_remote_execution/template_invocation' %>
|
3
3
|
<% title _('Job invocation') %>
|
4
4
|
<%= render :partial => 'form' %>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<% title @job_invocation.description, trunc_with_tooltip(@job_invocation.description, 120) %>
|
2
|
-
<% stylesheet 'job_invocations' %>
|
3
|
-
<% javascript 'charts', 'template_invocation' %>
|
2
|
+
<% stylesheet 'foreman_remote_execution/job_invocations' %>
|
3
|
+
<% javascript 'charts', 'foreman_remote_execution/template_invocation' %>
|
4
4
|
|
5
5
|
<% if @job_invocation.task %>
|
6
6
|
<% title_actions(button_group(job_invocation_task_buttons(@job_invocation.task))) %>
|
@@ -1,6 +1,6 @@
|
|
1
|
-
<%= javascript 'job_templates' %>
|
1
|
+
<%= javascript 'foreman_remote_execution/job_templates' %>
|
2
2
|
<%= javascript 'lookup_keys' %>
|
3
|
-
<%= javascript 'template_input' %>
|
3
|
+
<%= javascript 'foreman_remote_execution/template_input' %>
|
4
4
|
|
5
5
|
<% title _("Job Templates") %>
|
6
6
|
<% title_actions(documentation_button_rex('3.1JobTemplates'),
|
@@ -2,6 +2,6 @@
|
|
2
2
|
<%= content_tag :div, :class => 'line ' + output_line_set['output_type'], :data => { :timestamp => output_line_set['timestamp'] } do %>
|
3
3
|
|
4
4
|
<%= content_tag(:span, (@line_counter += 1).to_s.rjust(4).gsub(' ', ' ').html_safe + ':', :class => 'counter', :title => (output_line_set['timestamp'] && Time.at(output_line_set['timestamp']))) %>
|
5
|
-
<%= content_tag(:div, (line.empty? ? ' ' :
|
5
|
+
<%= content_tag(:div, (line.empty? ? ' ' : colorize_line(line)).html_safe, :class => 'content') %>
|
6
6
|
<% end %>
|
7
7
|
<% end %>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<% title _('Detail of %s run') % @template_invocation.job_invocation.job_category %>
|
2
|
-
<% stylesheet 'template_invocation' %>
|
3
|
-
<% javascript 'template_invocation' %>
|
2
|
+
<% stylesheet 'foreman_remote_execution/template_invocation' %>
|
3
|
+
<% javascript 'foreman_remote_execution/template_invocation' %>
|
4
4
|
|
5
5
|
<div id="title_action">
|
6
6
|
<div class="btn-toolbar pull-right">
|
@@ -0,0 +1,18 @@
|
|
1
|
+
blueprints = [
|
2
|
+
{
|
3
|
+
group: N_('Jobs'),
|
4
|
+
name: 'rex_job_succeeded',
|
5
|
+
message: N_("A job '%{subject}' has finished successfully"),
|
6
|
+
level: 'success',
|
7
|
+
actions:
|
8
|
+
{
|
9
|
+
links:
|
10
|
+
[
|
11
|
+
path_method: :job_invocation_path,
|
12
|
+
title: N_('Job Details')
|
13
|
+
]
|
14
|
+
}
|
15
|
+
}
|
16
|
+
]
|
17
|
+
|
18
|
+
blueprints.each { |blueprint| UINotifications::Seed.new(blueprint).configure }
|
@@ -119,5 +119,14 @@ module ForemanRemoteExecution
|
|
119
119
|
planned.input[:concurrency_control][:level].wont_be_empty
|
120
120
|
end
|
121
121
|
end
|
122
|
+
|
123
|
+
describe 'notifications' do
|
124
|
+
it 'creates notification on sucess run' do
|
125
|
+
FactoryBot.create(:notification_blueprint, :name => 'rex_job_succeeded')
|
126
|
+
assert_difference 'NotificationRecipient.where(:user_id => targeting.user.id).count' do
|
127
|
+
finalize_action planned
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
122
131
|
end
|
123
132
|
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: 1.4.
|
4
|
+
version: 1.4.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: 2018-01
|
11
|
+
date: 2018-02-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: deface
|
@@ -126,13 +126,13 @@ files:
|
|
126
126
|
- LICENSE
|
127
127
|
- README.md
|
128
128
|
- Rakefile
|
129
|
-
- app/assets/javascripts/execution_interface.js
|
130
|
-
- app/assets/javascripts/job_templates.js
|
131
|
-
- app/assets/javascripts/template_input.js
|
132
|
-
- app/assets/javascripts/template_invocation.js
|
133
|
-
- app/assets/stylesheets/job_invocations.css.scss
|
134
|
-
- app/assets/stylesheets/modal_window.css.scss
|
135
|
-
- app/assets/stylesheets/template_invocation.css.scss
|
129
|
+
- app/assets/javascripts/foreman_remote_execution/execution_interface.js
|
130
|
+
- app/assets/javascripts/foreman_remote_execution/job_templates.js
|
131
|
+
- app/assets/javascripts/foreman_remote_execution/template_input.js
|
132
|
+
- app/assets/javascripts/foreman_remote_execution/template_invocation.js
|
133
|
+
- app/assets/stylesheets/foreman_remote_execution/job_invocations.css.scss
|
134
|
+
- app/assets/stylesheets/foreman_remote_execution/modal_window.css.scss
|
135
|
+
- app/assets/stylesheets/foreman_remote_execution/template_invocation.css.scss
|
136
136
|
- app/controllers/api/v2/foreign_input_sets_controller.rb
|
137
137
|
- app/controllers/api/v2/job_invocations_controller.rb
|
138
138
|
- app/controllers/api/v2/job_templates_controller.rb
|
@@ -149,6 +149,7 @@ files:
|
|
149
149
|
- app/controllers/template_invocations_controller.rb
|
150
150
|
- app/helpers/concerns/foreman_remote_execution/hosts_helper_extensions.rb
|
151
151
|
- app/helpers/concerns/foreman_remote_execution/job_templates_extensions.rb
|
152
|
+
- app/helpers/job_invocation_output_helper.rb
|
152
153
|
- app/helpers/remote_execution_helper.rb
|
153
154
|
- app/lib/actions/middleware/bind_job_invocation.rb
|
154
155
|
- app/lib/actions/remote_execution/run_host_job.rb
|
@@ -190,6 +191,7 @@ files:
|
|
190
191
|
- app/overrides/execution_interface.rb
|
191
192
|
- app/overrides/subnet_proxies.rb
|
192
193
|
- app/services/remote_execution_proxy_selector.rb
|
194
|
+
- app/services/ui_notifications/remote_execution_jobs/base_job_finish.rb
|
193
195
|
- app/views/api/v2/foreign_input_sets/base.json.rabl
|
194
196
|
- app/views/api/v2/foreign_input_sets/create.json.rabl
|
195
197
|
- app/views/api/v2/foreign_input_sets/index.json.rabl
|
@@ -294,6 +296,7 @@ files:
|
|
294
296
|
- db/migrate/20170613101039_add_timeout_to_job_templates_and_job_invocations.rb
|
295
297
|
- db/migrate/20180110104432_rename_template_invocation_permission.rb
|
296
298
|
- db/migrate/20180112125015_fix_taxable_taxonomies_job_template.rb
|
299
|
+
- db/seeds.d/50-notification_blueprints.rb
|
297
300
|
- db/seeds.d/60-ssh_proxy_feature.rb
|
298
301
|
- db/seeds.d/70-job_templates.rb
|
299
302
|
- db/seeds.d/90-bookmarks.rb
|