foreman_patch 1.1.4 → 1.1.6.alpha4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/foreman_patch/concerns/hosts_controller_extensions.rb +35 -41
- data/app/controllers/foreman_patch/react_controller.rb +12 -0
- data/app/lib/actions/foreman_patch/cycle/create.rb +5 -1
- data/app/lib/actions/foreman_patch/cycle/initiate.rb +5 -1
- data/app/lib/actions/foreman_patch/invocation/action.rb +23 -29
- data/app/lib/actions/foreman_patch/invocation/patch.rb +16 -7
- data/app/lib/actions/foreman_patch/invocation/process_logging.rb +44 -0
- data/app/lib/actions/foreman_patch/invocation/proxy_action.rb +52 -0
- data/app/lib/actions/foreman_patch/invocation/wait_for_host.rb +4 -29
- data/app/lib/actions/foreman_patch/round/patch.rb +5 -1
- data/app/lib/actions/foreman_patch/window/publish.rb +5 -1
- data/app/lib/actions/foreman_patch/window/resolve_hosts.rb +5 -1
- data/app/models/foreman_patch/event.rb +13 -0
- data/app/models/foreman_patch/invocation.rb +2 -4
- data/app/views/foreman_patch/api/v2/invocations/base.json.rabl +1 -1
- data/app/views/foreman_patch/api/v2/invocations/event.json.rabl +3 -0
- data/app/views/foreman_patch/api/v2/invocations/show.json.rabl +2 -2
- data/app/views/foreman_patch/groups/index.html.erb +1 -1
- data/app/views/foreman_patch/layouts/react.html.erb +1 -1
- data/config/api_routes.rb +26 -28
- data/config/routes.rb +40 -29
- data/db/migrate/20230706092400_nullify_group_on_delete.rb +11 -0
- data/db/migrate/20230707102800_create_invocation_events.rb +16 -0
- data/db/seeds.d/100-assign_features_with_templates.rb +6 -12
- data/lib/foreman_patch/engine.rb +11 -46
- data/lib/foreman_patch/register.rb +119 -0
- data/lib/foreman_patch/version.rb +1 -1
- data/locale/en/foreman_patch.po +1 -1
- data/locale/foreman_patch.pot +1 -1
- data/locale/gemspec.rb +1 -1
- data/package.json +20 -9
- data/public/assets/foreman_patch/calendar-b5391efda77239c4a4894e9f03f34610f6c8e2e748b2a147febfea814b857cdc.scss.gz +0 -0
- data/public/assets/foreman_patch/cycle_plans-e5667e178ba389908f5c815b24ec0ea77c340849d56bc39c5ce72bb626bd446a.scss +6 -0
- data/public/assets/foreman_patch/cycle_plans-e5667e178ba389908f5c815b24ec0ea77c340849d56bc39c5ce72bb626bd446a.scss.gz +0 -0
- data/public/assets/foreman_patch/cycle_plans-ff3d252119622a68828ff70f4a97328303963002237dbf850e92d6a706e93667.scss +6 -0
- data/public/assets/foreman_patch/cycle_plans-ff3d252119622a68828ff70f4a97328303963002237dbf850e92d6a706e93667.scss.gz +0 -0
- data/public/assets/foreman_patch/foreman_patch-410cf04bf9b09e65fee034cc3f2dd74acf2524abf881c6d6e559d5c62a615faf.css +11 -0
- data/public/assets/foreman_patch/foreman_patch-410cf04bf9b09e65fee034cc3f2dd74acf2524abf881c6d6e559d5c62a615faf.css.gz +0 -0
- data/public/assets/foreman_patch/foreman_patch-84845e54f06d3a11189828e656432d587c7312358cdf694753da7b78b7dabcee.css +11 -0
- data/public/assets/foreman_patch/foreman_patch-84845e54f06d3a11189828e656432d587c7312358cdf694753da7b78b7dabcee.css.gz +0 -0
- data/public/assets/foreman_patch/foreman_patch-a76c5fd10a5795e97c5ae4c222bfdf4ab88da49d6a7659175dba79f8fc62ab47.css +82 -0
- data/public/assets/foreman_patch/foreman_patch-a76c5fd10a5795e97c5ae4c222bfdf4ab88da49d6a7659175dba79f8fc62ab47.css.gz +0 -0
- data/public/assets/foreman_patch/foreman_patch.json +1 -0
- data/public/assets/foreman_patch/plan_edit_windows-2eb04c7e83fa62797b0a14364d3ff5b3c4336983603fdc5a276b5464eeba7e60.js +9 -0
- data/public/assets/foreman_patch/plan_edit_windows-2eb04c7e83fa62797b0a14364d3ff5b3c4336983603fdc5a276b5464eeba7e60.js.gz +0 -0
- data/public/assets/foreman_patch/plan_edit_windows-ddedd3e70fb6ef761f636be2b7b35286e86d68e126bfc37294f9365a5171a928.js +9 -0
- data/public/assets/foreman_patch/plan_edit_windows-ddedd3e70fb6ef761f636be2b7b35286e86d68e126bfc37294f9365a5171a928.js.gz +0 -0
- data/public/webpack/foreman_patch/bundle.css +1 -0
- data/public/webpack/foreman_patch/bundle.js +34173 -0
- data/public/webpack/foreman_patch/foreman_patch.css +1 -0
- data/public/webpack/foreman_patch/foreman_patch.js +34366 -0
- data/public/webpack/foreman_patch/foreman_patch:global.css +1 -0
- data/public/webpack/foreman_patch/foreman_patch:global.js +32098 -0
- data/public/webpack/foreman_patch/manifest.json +25 -0
- data/public/webpack/foreman_patch/vendor.js +5201 -0
- data/webpack/components/Invocations/InvocationsPage.js +1 -1
- data/webpack/components/Invocations/index.js +6 -6
- data/webpack/components/common/Calendar/Calendar.css +76 -0
- data/webpack/components/common/Calendar/Calendar.js +5 -4
- data/webpack/components/common/Table/index.js +28 -0
- data/webpack/global_index.js +16 -0
- data/webpack/index.js +3 -8
- data/webpack/src/Components/Invocation/Invocation.js +67 -0
- data/webpack/src/Components/Invocation/InvocationLogFooter.js +30 -0
- data/webpack/src/Components/Invocation/InvocationLogToolbar.js +80 -0
- data/webpack/{components → src/Components}/Invocation/InvocationSelectors.js +0 -3
- data/webpack/src/Components/Invocation/index.js +62 -0
- data/webpack/src/Components/InvocationStatus.js +50 -0
- data/webpack/src/Components/Loading.js +51 -0
- data/webpack/src/Extends/index.js +15 -0
- data/webpack/src/Router/routes.js +4 -2
- data/webpack/src/reducers.js +1 -1
- metadata +57 -88
- data/app/lib/actions/foreman_patch/cycle/complete.rb +0 -41
- data/app/lib/actions/foreman_patch/cycle/plan.rb +0 -73
- data/app/lib/actions/foreman_patch/round/plan.rb +0 -33
- data/app/lib/actions/foreman_patch/window/plan.rb +0 -43
- data/app/models/setting/patching.rb +0 -57
- data/app/views/foreman_patch/api/v2/invocations/phase.json.rabl +0 -7
- data/config/routes/mount_engine.rb +0 -3
- data/config/routes/overrides.rb +0 -10
- data/lib/foreman_patch/plugin.rb +0 -47
- data/webpack/components/Invocation/Invocation.js +0 -47
- data/webpack/components/Invocation/index.js +0 -36
- data/webpack/components/common/Terminal/OutputLine.js +0 -26
- data/webpack/components/common/Terminal/Terminal.js +0 -115
- data/webpack/components/common/Terminal/Terminal.scss +0 -47
- data/webpack/src/ForemanPatch.js +0 -11
- data/webpack/src/Router/index.js +0 -14
- data/webpack/src/index.js +0 -1
- /data/{webpack/components/common/Calendar/Calendar.scss → public/assets/foreman_patch/calendar-b5391efda77239c4a4894e9f03f34610f6c8e2e748b2a147febfea814b857cdc.scss} +0 -0
- /data/webpack/components/Invocations/{Invocations.scss → Invocations.css} +0 -0
- /data/webpack/{components → src/Components}/Invocation/InvocationActions.js +0 -0
- /data/webpack/{components → src/Components}/Invocation/InvocationConsts.js +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a0c418f7823f9284b25ba359c284ac4eb6f090e1826b32759ff11c4c9930a20
|
4
|
+
data.tar.gz: 52f7f32b37f8ab528b6946d17023ed613cf874ba913efc8b42b3c38dc13974bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fcddad96ea62cb31521ca728b418fc2f33fbbc9a167d06270fc4a8d45a5bb6d23915b9686af28c86203d9c4fdd48e62f2c8cf3afdb8c1695da49c8818df89cbb
|
7
|
+
data.tar.gz: 81d7bf80181451853b12c593cfac3bca9e662da2db237e7f54ce780a3b1a41e03a112a34b4fc81ad7bf5cd54096c85d22f7bbfa72b7c602603ca120f910ceb97
|
@@ -3,58 +3,52 @@ module ForemanPatch
|
|
3
3
|
module HostsControllerExtensions
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
6
|
-
|
7
|
-
def action_permission
|
8
|
-
case params[:action]
|
9
|
-
when 'select_multiple_patch_group', 'update_multiple_patch_group'
|
10
|
-
:edit
|
11
|
-
else
|
12
|
-
super
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
6
|
+
MULTIPLE_EDIT_ACTIONS = %w[select_multiple_patch_group, update_multiple_patch_group].freeze
|
16
7
|
|
17
8
|
included do
|
18
|
-
|
19
|
-
|
9
|
+
before_action :find_multiple_for_foreman_patch_extensions, only: MULTIPLE_EDIT_ACTIONS
|
20
10
|
after_action :reschedule_patching, only: :update
|
21
11
|
|
22
|
-
|
23
|
-
find_multiple
|
24
|
-
end
|
12
|
+
define_action_permission MULTIPLE_EDIT_ACTIONS, :edit
|
25
13
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
group_facet = host.group_facet
|
32
|
-
group_facet.group = nil unless group_facet.blank?
|
33
|
-
host.save!
|
34
|
-
end
|
35
|
-
else
|
36
|
-
patch_group = ForemanPatch::Group.find(params['patch_group']['id'])
|
37
|
-
|
38
|
-
@hosts.each do |host|
|
39
|
-
group_facet = host.group_facet || host.build_group_facet
|
40
|
-
group_facet.group = patch_group
|
41
|
-
host.save!
|
42
|
-
end
|
43
|
-
end
|
14
|
+
helper ForemanPatch::HostsHelper
|
15
|
+
end
|
16
|
+
|
17
|
+
def select_multiple_patch_group
|
18
|
+
end
|
44
19
|
|
45
|
-
|
20
|
+
def update_multiple_patch_group
|
21
|
+
if (params['patch_group']['id'].blank?)
|
22
|
+
@hosts.each do |host|
|
23
|
+
group_facet = host.group_facet
|
24
|
+
group_facet.group = nil unless group_facet.blank?
|
25
|
+
host.save!
|
26
|
+
end
|
27
|
+
else
|
28
|
+
patch_group = ForemanPatch::Group.find(params['patch_group']['id'])
|
46
29
|
|
47
|
-
|
48
|
-
|
30
|
+
@hosts.each do |host|
|
31
|
+
group_facet = host.group_facet || host.build_group_facet
|
32
|
+
group_facet.group = patch_group
|
33
|
+
host.save!
|
34
|
+
end
|
49
35
|
end
|
50
36
|
|
51
|
-
|
52
|
-
return if @host.group_facet.nil?
|
53
|
-
return unless @host.group_facet.saved_change_to_attribute?(:group_id)
|
37
|
+
ForemanTasks.async_task(Actions::ForemanPatch::Host::Reschedule, @hosts, include_active: params['patch_group']['include_active'])
|
54
38
|
|
55
|
-
|
56
|
-
|
39
|
+
success _('Updated hosts: changed patch group')
|
40
|
+
redirect_back_or_to hosts_path
|
41
|
+
end
|
42
|
+
|
43
|
+
def reschedule_patching
|
44
|
+
return if @host.group_facet.nil?
|
45
|
+
return unless @host.group_facet.saved_change_to_attribute?(:group_id)
|
46
|
+
|
47
|
+
ForemanTasks.async_task(Actions::ForemanPatch::Host::Reschedule, @host)
|
48
|
+
end
|
57
49
|
|
50
|
+
def find_multiple_for_foreman_patch_extensions
|
51
|
+
find_multiple
|
58
52
|
end
|
59
53
|
end
|
60
54
|
end
|
@@ -46,7 +46,7 @@ module Actions
|
|
46
46
|
provider = template.provider
|
47
47
|
proxy_selector = provider.required_proxy_selector_for(template) || ::RemoteExecutionProxySelector.new
|
48
48
|
|
49
|
-
proxy =
|
49
|
+
proxy = determine_proxy!(proxy_selector, template.provider_type.to_s, host)
|
50
50
|
|
51
51
|
renderer = InputTemplateRenderer.new(template, host, invocation)
|
52
52
|
script = renderer.render
|
@@ -61,7 +61,7 @@ module Actions
|
|
61
61
|
action_options = provider.proxy_command_options(invocation, host).merge(additional_options)
|
62
62
|
|
63
63
|
sequence do
|
64
|
-
|
64
|
+
plan_action(::Actions::ForemanPatch::Invocation::ProxyAction, proxy, provider.proxy_action_class, action_options)
|
65
65
|
plan_self
|
66
66
|
end
|
67
67
|
end
|
@@ -87,37 +87,10 @@ module Actions
|
|
87
87
|
@template ||= feature.job_template
|
88
88
|
end
|
89
89
|
|
90
|
-
def live_output
|
91
|
-
continuous_output.sort!
|
92
|
-
continuous_output.raw_outputs
|
93
|
-
end
|
94
|
-
|
95
|
-
def continuous_output_providers
|
96
|
-
super << self
|
97
|
-
end
|
98
|
-
|
99
|
-
def fill_continuous_output(continuous_output)
|
100
|
-
delegated_output.fetch('result', []).each do |raw_output|
|
101
|
-
continuous_output.add_raw_output(raw_output)
|
102
|
-
end
|
103
|
-
|
104
|
-
final_timestamp = (continuous_output.last_timestamp || task.ended_at).to_f + 1
|
105
|
-
|
106
|
-
fill_planning_errors_to_continuous_output(continuous_output) unless exit_status
|
107
|
-
|
108
|
-
continuous_output.add_output(_('Exit status: %s') % exit_status, 'stdout', final_timestamp) if exit_status
|
109
|
-
rescue => e
|
110
|
-
continuous_output.add_exception(_('Error loading data from proxy'), e)
|
111
|
-
end
|
112
|
-
|
113
90
|
def required?
|
114
91
|
input.fetch(:required, true)
|
115
92
|
end
|
116
93
|
|
117
|
-
def humanized_name
|
118
|
-
input[:feature_name].titleize
|
119
|
-
end
|
120
|
-
|
121
94
|
def rescue_strategy_for_self
|
122
95
|
required? ? ::Dynflow::Action::Rescue::Fail : ::Dynflow::Action::Rescue::Skip
|
123
96
|
end
|
@@ -128,6 +101,27 @@ module Actions
|
|
128
101
|
@host ||= ::Host.find(input[:host][:id])
|
129
102
|
end
|
130
103
|
|
104
|
+
def determine_proxy!(proxy_selector, provider, host)
|
105
|
+
proxy = proxy_selector.determine_proxy(host, provider)
|
106
|
+
if proxy == :not_available
|
107
|
+
offline_proxies = proxy_selector.offline
|
108
|
+
settings = { count: offline_proxies.count, proxy_names: offline_proxies.map(&:name).join(', ') }
|
109
|
+
raise n_('The only applicable proxy %{proxy_names} is down',
|
110
|
+
'All %{count} applicable proxies are down. Tried %{proxy_names}',
|
111
|
+
offline_proxies.count) % settings
|
112
|
+
elsif proxy == :not_defined
|
113
|
+
settings = {
|
114
|
+
global_proxy: 'remote_execution_global_proxy',
|
115
|
+
fallback_proxy: 'remote_execution_fallback_proxy',
|
116
|
+
provider: provider,
|
117
|
+
}
|
118
|
+
|
119
|
+
raise _('Could not use any proxy for the %{provider} job. Consider configuring %{global_proxy}, ' +
|
120
|
+
'%{fallback_proxy} in settings') % settings
|
121
|
+
end
|
122
|
+
proxy
|
123
|
+
end
|
124
|
+
|
131
125
|
end
|
132
126
|
end
|
133
127
|
end
|
@@ -3,6 +3,7 @@ module Actions
|
|
3
3
|
module Invocation
|
4
4
|
class Patch < Actions::EntryAction
|
5
5
|
include ::Actions::Helpers::WithContinuousOutput
|
6
|
+
include ::Actions::ForemanPatch::Invocation::ProcessLogging
|
6
7
|
|
7
8
|
execution_plan_hooks.use :update_status, on: ::Dynflow::ExecutionPlan.states
|
8
9
|
|
@@ -52,8 +53,16 @@ module Actions
|
|
52
53
|
end
|
53
54
|
|
54
55
|
def continuous_output_providers
|
55
|
-
|
56
|
-
|
56
|
+
super << self
|
57
|
+
end
|
58
|
+
|
59
|
+
def fill_continuous_output(continuous_output)
|
60
|
+
invocation.events.order(:sequence).find_each do |output|
|
61
|
+
if output.event_type == 'exit'
|
62
|
+
continuous_output.add_output(_('Exit status: %s') % output.event, 'stdout', output.timestamp)
|
63
|
+
else
|
64
|
+
continuous_output.add_raw_output(output.as_raw_continuous_output)
|
65
|
+
end
|
57
66
|
end
|
58
67
|
end
|
59
68
|
|
@@ -71,7 +80,11 @@ module Actions
|
|
71
80
|
end
|
72
81
|
|
73
82
|
def humanized_name
|
74
|
-
_('Patch
|
83
|
+
_('Patch:')
|
84
|
+
end
|
85
|
+
|
86
|
+
def humanized_input
|
87
|
+
host.name
|
75
88
|
end
|
76
89
|
|
77
90
|
private
|
@@ -80,10 +93,6 @@ module Actions
|
|
80
93
|
@host ||= ::Host.find(input[:host][:id])
|
81
94
|
end
|
82
95
|
|
83
|
-
def invocation
|
84
|
-
@invocation ||= ::ForemanPatch::Invocation.find(input[:invocation_id])
|
85
|
-
end
|
86
|
-
|
87
96
|
def failed_action
|
88
97
|
planned_actions.find do |action|
|
89
98
|
action.steps.compact.any? { |step| [:error, :skipped].include? step.state }
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Actions
|
2
|
+
module ForemanPatch
|
3
|
+
module Invocation
|
4
|
+
module ProcessLogging
|
5
|
+
|
6
|
+
def invocation
|
7
|
+
@invocation ||= ::ForemanPatch::Invocation.find_by(task_id: task.id)
|
8
|
+
end
|
9
|
+
|
10
|
+
def log_invocation_event(event, type = 'debug', timestamp = Time.zone.now)
|
11
|
+
last = invocation.events.order(:sequence).last
|
12
|
+
sequence = last ? last.sequence + 1 : 0
|
13
|
+
invocation.events.create!(
|
14
|
+
event_type: type,
|
15
|
+
event: event,
|
16
|
+
timestamp: timestamp,
|
17
|
+
sequence: sequence
|
18
|
+
)
|
19
|
+
end
|
20
|
+
|
21
|
+
def log_invocation_exception(exception)
|
22
|
+
last = invocation.events.order(:sequence).last
|
23
|
+
sequence = last ? last.sequence + 1 : 0
|
24
|
+
invocation.events.create!(
|
25
|
+
event_type: 'debug',
|
26
|
+
event: "#{exception.class}: #{exception.message}",
|
27
|
+
timestamp: Time.zone.now,
|
28
|
+
sequence: sequence
|
29
|
+
)
|
30
|
+
end
|
31
|
+
|
32
|
+
def with_invocation_error_logging
|
33
|
+
unless catch(::Dynflow::Action::ERROR) { yield || true }
|
34
|
+
log_invocation_exception(error.exception)
|
35
|
+
throw ::Dynflow::Action::ERROR
|
36
|
+
end
|
37
|
+
rescue => e
|
38
|
+
log_invocation_exception(e)
|
39
|
+
raise e
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module Actions
|
2
|
+
module ForemanPatch
|
3
|
+
module Invocation
|
4
|
+
class ProxyAction < ::Actions::ProxyAction
|
5
|
+
include Actions::ForemanPatch::Invocation::ProcessLogging
|
6
|
+
|
7
|
+
def on_data(data, meta = {})
|
8
|
+
super
|
9
|
+
process_proxy_data(output[:proxy_output])
|
10
|
+
end
|
11
|
+
|
12
|
+
def run(event = nil)
|
13
|
+
with_invocation_error_logging { super }
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def get_proxy_data(response)
|
19
|
+
data = super
|
20
|
+
process_proxy_data(data)
|
21
|
+
data
|
22
|
+
end
|
23
|
+
|
24
|
+
def process_proxy_data(data)
|
25
|
+
events = data['result'].each_with_index.map do |update, idx|
|
26
|
+
{
|
27
|
+
sequence: update['sequence'] || idx,
|
28
|
+
invocation_id: invocation.id,
|
29
|
+
event: update['output'],
|
30
|
+
timestamp: Time.at(update['timestamp']).getlocal,
|
31
|
+
event_type: update['output_type'],
|
32
|
+
}
|
33
|
+
end
|
34
|
+
if data['exit_status']
|
35
|
+
last = events.last || { sequence: -1, timestamp: Time.zone.now }
|
36
|
+
events << {
|
37
|
+
sequence: last[:sequence] + 1,
|
38
|
+
invocation_id: invocation.id,
|
39
|
+
event: data['exit_status'],
|
40
|
+
timestamp: last[:timestamp],
|
41
|
+
event_type: 'exit',
|
42
|
+
}
|
43
|
+
end
|
44
|
+
events.each_slice(1000) do |batch|
|
45
|
+
::ForemanPatch::Event.upsert_all(batch, unique_by: [:invocation_id, :sequence])
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -2,8 +2,8 @@ module Actions
|
|
2
2
|
module ForemanPatch
|
3
3
|
module Invocation
|
4
4
|
class WaitForHost < Actions::EntryAction
|
5
|
-
include Actions::Helpers::WithContinuousOutput
|
6
5
|
include Dynflow::Action::Polling
|
6
|
+
include ::Actions::ForemanPatch::Invocation::ProcessLogging
|
7
7
|
|
8
8
|
def plan(host)
|
9
9
|
action_subject(host)
|
@@ -31,7 +31,7 @@ module Actions
|
|
31
31
|
status = 'starting'
|
32
32
|
ensure
|
33
33
|
socket.close if socket
|
34
|
-
|
34
|
+
log_invocation_event("Poll result: #{status}")
|
35
35
|
end
|
36
36
|
|
37
37
|
def poll_intervals
|
@@ -46,30 +46,15 @@ module Actions
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def on_finish
|
49
|
-
|
49
|
+
log_invocation_event(_('Host is up'), 'stdout') if external_task == 'available'
|
50
50
|
end
|
51
51
|
|
52
52
|
def process_timeout
|
53
|
-
|
53
|
+
log_invocation_event(_('Server did not respond withing alloted time after restart.'), 'stderr')
|
54
54
|
|
55
55
|
self.external_task = 'timeout'
|
56
56
|
end
|
57
57
|
|
58
|
-
def live_output
|
59
|
-
continuous_output.sort!
|
60
|
-
continuous_output.raw_outputs
|
61
|
-
end
|
62
|
-
|
63
|
-
def continuous_output_providers
|
64
|
-
super << self
|
65
|
-
end
|
66
|
-
|
67
|
-
def fill_continuous_output(continuous_output)
|
68
|
-
output.fetch('result', []).each do |raw_output|
|
69
|
-
continuous_output.add_raw_output(raw_output)
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
58
|
private
|
74
59
|
|
75
60
|
def host
|
@@ -80,16 +65,6 @@ module Actions
|
|
80
65
|
external_task == 'starting'
|
81
66
|
end
|
82
67
|
|
83
|
-
def add_output(message, type = 'debug', timestamp = Time.now.getlocal)
|
84
|
-
formatted_output = {
|
85
|
-
output_type: type,
|
86
|
-
output: message,
|
87
|
-
timestamp: timestamp.to_f
|
88
|
-
}
|
89
|
-
|
90
|
-
output[:result] = [] if output[:result].nil?
|
91
|
-
output[:result] << formatted_output
|
92
|
-
end
|
93
68
|
end
|
94
69
|
end
|
95
70
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module ForemanPatch
|
2
|
+
class Event < ::ApplicationRecord
|
3
|
+
belongs_to :invocation, class_name: 'ForemanPatch::Invocation'
|
4
|
+
|
5
|
+
def as_raw_continuous_output
|
6
|
+
raw = attibutes
|
7
|
+
raw['output_type'] = raw.delete('event_type')
|
8
|
+
raw['output'] = raw.delete('event')
|
9
|
+
raw['timestamp'] = raw['timestamp'].to_f
|
10
|
+
raw
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -12,6 +12,8 @@ module ForemanPatch
|
|
12
12
|
|
13
13
|
belongs_to :task, class_name: 'ForemanTasks::Task'
|
14
14
|
|
15
|
+
has_many :events, class_name: 'ForemanPatch::Events'
|
16
|
+
|
15
17
|
scope :planned, -> { where(status: 'planned') }
|
16
18
|
scope :pending, -> { where(status: 'pending') }
|
17
19
|
scope :running, -> { where(status: 'running') }
|
@@ -32,10 +34,6 @@ module ForemanPatch
|
|
32
34
|
task&.main_action&.planned_actions || []
|
33
35
|
end
|
34
36
|
|
35
|
-
def events
|
36
|
-
task&.main_action&.live_output || []
|
37
|
-
end
|
38
|
-
|
39
37
|
def complete?
|
40
38
|
['success', 'warning', 'failed', 'cancelled'].include? status
|
41
39
|
end
|
@@ -29,7 +29,7 @@
|
|
29
29
|
</td>
|
30
30
|
<td>
|
31
31
|
<%= action_buttons(
|
32
|
-
display_delete_if_authorized(hash_for_group_path(id: group.id).merge(auth_object: group, authorizer: authorizer), data: { confirm: _("Delete patch group, %s?") % group.name })) %>
|
32
|
+
display_delete_if_authorized(hash_for_group_path(id: group.id).merge(engine: foreman_patch, auth_object: group, authorizer: authorizer), data: { confirm: _("Delete patch group, %s?") % group.name })) %>
|
33
33
|
</td>
|
34
34
|
</tr>
|
35
35
|
<% end %>
|
data/config/api_routes.rb
CHANGED
@@ -1,43 +1,41 @@
|
|
1
1
|
ForemanPatch::Engine.routes.draw do
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
resources :
|
6
|
-
|
7
|
-
|
8
|
-
end
|
2
|
+
namespace :api, defaults: { format: 'json' } do
|
3
|
+
scope '(:apiv)', module: :v2, defaults: { apiv: 'v2' }, apiv: /v1|v2/, constraints: ApiConstraints.new(version: 2, default: true) do
|
4
|
+
resources :plans, only: [:index, :show, :create, :update, :destroy] do
|
5
|
+
resources :window_plans, only: [:index, :create]
|
6
|
+
resources :cycles, only: [:index, :create]
|
7
|
+
end
|
9
8
|
|
10
|
-
|
9
|
+
resources :window_plans, only: [:index, :show, :update, :destroy]
|
11
10
|
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
resources :cycles, only: [:index, :create, :show, :update, :destroy] do
|
12
|
+
resources :windows, only: [:index, :create]
|
13
|
+
end
|
15
14
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
15
|
+
resources :windows, only: [:show, :update, :destroy] do
|
16
|
+
resources :rounds, only: [:index]
|
17
|
+
member do
|
18
|
+
post :schedule
|
21
19
|
end
|
20
|
+
end
|
22
21
|
|
23
|
-
|
22
|
+
resources :groups, only: [:index, :show, :create, :update, :destroy]
|
24
23
|
|
25
|
-
|
26
|
-
|
24
|
+
resources :rounds, only: [:show, :create, :update, :destroy] do
|
25
|
+
resources :invocations, only: [:index]
|
27
26
|
|
28
|
-
|
29
|
-
|
30
|
-
end
|
27
|
+
member do
|
28
|
+
get :status
|
31
29
|
end
|
30
|
+
end
|
32
31
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
end
|
32
|
+
resources :invocations, only: [:show] do
|
33
|
+
collection do
|
34
|
+
put 'move'
|
35
|
+
put 'cancel'
|
38
36
|
end
|
39
|
-
|
40
37
|
end
|
38
|
+
|
41
39
|
end
|
42
40
|
end
|
43
41
|
end
|