foreman_patch 1.1.6.alpha5 → 1.2.0.alpha1
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/controllers/foreman_patch/api/v2/invocations_controller.rb +1 -23
- data/app/controllers/foreman_patch/concerns/hosts_controller_extensions.rb +41 -35
- data/app/helpers/foreman_patch/hosts_helper.rb +1 -1
- data/app/lib/actions/foreman_patch/cycle/complete.rb +41 -0
- data/app/lib/actions/foreman_patch/cycle/create.rb +1 -5
- data/app/lib/actions/foreman_patch/cycle/initiate.rb +1 -5
- data/app/lib/actions/foreman_patch/cycle/plan.rb +66 -0
- data/app/lib/actions/foreman_patch/invocation/action.rb +29 -23
- data/app/lib/actions/foreman_patch/invocation/patch.rb +8 -16
- data/app/lib/actions/foreman_patch/invocation/wait_for_host.rb +29 -4
- data/app/lib/actions/foreman_patch/round/patch.rb +1 -5
- data/app/lib/actions/foreman_patch/round/plan.rb +33 -0
- data/app/lib/actions/foreman_patch/window/plan.rb +43 -0
- data/app/lib/actions/foreman_patch/window/publish.rb +1 -5
- data/app/lib/actions/foreman_patch/window/resolve_hosts.rb +1 -5
- data/app/models/foreman_patch/invocation.rb +4 -4
- data/app/models/foreman_patch/round.rb +23 -4
- data/app/models/setting/patching.rb +57 -0
- data/app/services/foreman_patch/ticket/api.rb +1 -2
- data/app/views/foreman_patch/api/v2/invocations/base.json.rabl +1 -1
- data/app/views/foreman_patch/api/v2/invocations/phase.json.rabl +7 -0
- data/app/views/foreman_patch/api/v2/invocations/show.json.rabl +2 -2
- data/app/views/foreman_patch/api/v2/rounds/base.json.rabl +1 -1
- data/app/views/foreman_patch/api/v2/rounds/status.json.rabl +8 -2
- data/app/views/foreman_patch/groups/index.html.erb +1 -1
- data/app/views/foreman_patch/invocations/show.html.erb +26 -1
- data/app/views/foreman_patch/layouts/react.html.erb +1 -1
- data/app/views/templates/ensure_services.erb +4 -7
- data/config/api_routes.rb +24 -28
- data/config/routes/mount_engine.rb +3 -0
- data/config/routes/overrides.rb +10 -0
- data/config/routes.rb +29 -40
- data/db/seeds.d/100-assign_features_with_templates.rb +12 -6
- data/lib/foreman_patch/engine.rb +46 -11
- data/lib/foreman_patch/plugin.rb +47 -0
- data/lib/foreman_patch/version.rb +1 -1
- data/lib/foreman_patch.rb +2 -3
- data/locale/en/foreman_patch.po +1 -1
- data/locale/foreman_patch.pot +1 -1
- data/locale/gemspec.rb +1 -1
- data/package.json +9 -20
- 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.gz +0 -0
- data/public/assets/foreman_patch/foreman_patch-be2e2ba89548f4a490612e8a6cd1cdebc0473be89f8023a3df7612f05a75d301.css.gz +0 -0
- data/public/assets/foreman_patch/foreman_patch-ce5805a60c0d5f896f557ff5246e5a09172043004c850b39bea54e618df1c485.css +1 -0
- data/public/assets/foreman_patch/foreman_patch-ce5805a60c0d5f896f557ff5246e5a09172043004c850b39bea54e618df1c485.css.gz +0 -0
- data/public/assets/foreman_patch/foreman_patch.json +1 -1
- data/public/assets/foreman_patch/plan_edit_windows-9ba20f84f3ecf2c4eb903acd57d30ee3e16f023a79db30bc614aa22f26442ce3.js.gz +0 -0
- data/public/assets/foreman_patch/plan_edit_windows-e656ba411642a7f983b51958ab30ac49c056322d19295a603cff4d5e6c71c8ed.js +1 -0
- data/public/assets/foreman_patch/plan_edit_windows-e656ba411642a7f983b51958ab30ac49c056322d19295a603cff4d5e6c71c8ed.js.gz +0 -0
- data/public/webpack/foreman_patch/bundle-e45c4bb530e40506f2da.js +6 -0
- data/public/webpack/foreman_patch/bundle-e45c4bb530e40506f2da.js.gz +0 -0
- data/public/webpack/foreman_patch/bundle-e45c4bb530e40506f2da.js.map +1 -0
- data/public/webpack/foreman_patch/bundle-e45c4bb530e40506f2da.js.map.gz +0 -0
- data/public/webpack/foreman_patch/{foreman_patch-8909c3e06f012a43f769.css → foreman_patch-4a4e1a59d74af09c4b8b.css} +1 -1
- data/public/webpack/foreman_patch/{foreman_patch-8909c3e06f012a43f769.css.gz → foreman_patch-4a4e1a59d74af09c4b8b.css.gz} +0 -0
- data/public/webpack/foreman_patch/foreman_patch-4a4e1a59d74af09c4b8b.js +6 -0
- data/public/webpack/foreman_patch/foreman_patch-4a4e1a59d74af09c4b8b.js.gz +0 -0
- data/public/webpack/foreman_patch/foreman_patch-4a4e1a59d74af09c4b8b.js.map +1 -0
- data/public/webpack/foreman_patch/foreman_patch-4a4e1a59d74af09c4b8b.js.map.gz +0 -0
- data/public/webpack/foreman_patch/manifest.json +8 -13
- data/public/webpack/foreman_patch/manifest.json.gz +0 -0
- data/public/webpack/foreman_patch/{vendor-769bd77f6be96c3c37e1.js → vendor-4b77c91f1e9103179596.js} +2 -2
- data/public/webpack/foreman_patch/vendor-4b77c91f1e9103179596.js.gz +0 -0
- data/public/webpack/foreman_patch/{vendor-769bd77f6be96c3c37e1.js.map → vendor-4b77c91f1e9103179596.js.map} +1 -1
- data/public/webpack/foreman_patch/vendor-4b77c91f1e9103179596.js.map.gz +0 -0
- data/webpack/components/Invocation/Invocation.js +47 -0
- data/webpack/{src/Components → components}/Invocation/InvocationSelectors.js +3 -0
- data/webpack/components/Invocation/index.js +36 -0
- data/webpack/components/Invocations/Invocations.js +16 -48
- data/webpack/components/Invocations/InvocationsPage.js +1 -24
- data/webpack/components/Invocations/InvocationsSelectors.js +1 -1
- data/webpack/components/Invocations/components/{InvocationActions.js → InvocationItem.js} +16 -4
- data/webpack/components/Invocations/index.js +12 -95
- data/webpack/components/RoundProgress/AggregateStatus.js +5 -6
- data/webpack/components/RoundProgress/RoundProgress.js +6 -7
- data/webpack/components/RoundProgress/RoundProgressSelectors.js +2 -3
- data/webpack/components/common/Calendar/Calendar.js +4 -5
- data/webpack/components/common/Terminal/OutputLine.js +26 -0
- data/webpack/components/common/Terminal/Terminal.js +115 -0
- data/webpack/components/common/Terminal/Terminal.scss +47 -0
- data/webpack/index.js +0 -3
- metadata +91 -54
- data/app/controllers/foreman_patch/react_controller.rb +0 -12
- data/app/lib/actions/foreman_patch/invocation/process_logging.rb +0 -44
- data/app/lib/actions/foreman_patch/invocation/proxy_action.rb +0 -52
- data/app/models/foreman_patch/event.rb +0 -13
- data/app/views/foreman_patch/api/v2/invocations/event.json.rabl +0 -3
- data/db/migrate/20230706092400_nullify_group_on_delete.rb +0 -11
- data/db/migrate/20230707102800_create_invocation_events.rb +0 -16
- data/lib/foreman_patch/register.rb +0 -119
- data/public/webpack/foreman_patch/bundle-831173d6ae39953b2409.js +0 -6
- data/public/webpack/foreman_patch/bundle-831173d6ae39953b2409.js.gz +0 -0
- data/public/webpack/foreman_patch/bundle-831173d6ae39953b2409.js.map +0 -1
- data/public/webpack/foreman_patch/bundle-831173d6ae39953b2409.js.map.gz +0 -0
- data/public/webpack/foreman_patch/foreman_patch-8909c3e06f012a43f769.js +0 -6
- data/public/webpack/foreman_patch/foreman_patch-8909c3e06f012a43f769.js.gz +0 -0
- data/public/webpack/foreman_patch/foreman_patch-8909c3e06f012a43f769.js.map +0 -1
- data/public/webpack/foreman_patch/foreman_patch-8909c3e06f012a43f769.js.map.gz +0 -0
- data/public/webpack/foreman_patch/foreman_patch:global-d71cc6e1e759f04f631a.css +0 -1
- data/public/webpack/foreman_patch/foreman_patch:global-d71cc6e1e759f04f631a.css.gz +0 -0
- data/public/webpack/foreman_patch/foreman_patch:global-d71cc6e1e759f04f631a.js +0 -6
- data/public/webpack/foreman_patch/foreman_patch:global-d71cc6e1e759f04f631a.js.gz +0 -0
- data/public/webpack/foreman_patch/foreman_patch:global-d71cc6e1e759f04f631a.js.map +0 -1
- data/public/webpack/foreman_patch/foreman_patch:global-d71cc6e1e759f04f631a.js.map.gz +0 -0
- data/public/webpack/foreman_patch/vendor-769bd77f6be96c3c37e1.js.gz +0 -0
- data/public/webpack/foreman_patch/vendor-769bd77f6be96c3c37e1.js.map.gz +0 -0
- data/webpack/components/common/Table/index.js +0 -28
- data/webpack/global_index.js +0 -16
- data/webpack/src/Components/Invocation/Invocation.js +0 -67
- data/webpack/src/Components/Invocation/InvocationLogFooter.js +0 -30
- data/webpack/src/Components/Invocation/InvocationLogToolbar.js +0 -80
- data/webpack/src/Components/Invocation/index.js +0 -62
- data/webpack/src/Components/InvocationStatus.js +0 -50
- data/webpack/src/Components/Loading.js +0 -51
- data/webpack/src/Extends/index.js +0 -15
- data/webpack/src/Router/routes.js +0 -5
- data/webpack/src/reducers.js +0 -7
- /data/public/webpack/foreman_patch/{bundle-831173d6ae39953b2409.css → bundle-e45c4bb530e40506f2da.css} +0 -0
- /data/public/webpack/foreman_patch/{bundle-831173d6ae39953b2409.css.gz → bundle-e45c4bb530e40506f2da.css.gz} +0 -0
- /data/webpack/{src/Components → components}/Invocation/InvocationActions.js +0 -0
- /data/webpack/{src/Components → components}/Invocation/InvocationConsts.js +0 -0
- /data/webpack/components/Invocations/{Invocations.css → InvocationsPage.scss} +0 -0
- /data/webpack/components/common/Calendar/{Calendar.css → Calendar.scss} +0 -0
@@ -2,8 +2,6 @@ module ForemanPatch
|
|
2
2
|
class Round < ::ApplicationRecord
|
3
3
|
include ForemanTasks::Concerns::ActionSubject
|
4
4
|
|
5
|
-
STATUSES = %w(planned pending running complete).freeze
|
6
|
-
|
7
5
|
belongs_to :window, class_name: 'ForemanPatch::Window'
|
8
6
|
has_one :cycle, class_name: 'ForemanPatch::Cycle', through: :window
|
9
7
|
belongs_to :group, class_name: 'ForemanPatch::Group'
|
@@ -34,8 +32,29 @@ module ForemanPatch
|
|
34
32
|
scoped_search on: :name, complete_value: true
|
35
33
|
scoped_search on: :status, complete_value: true
|
36
34
|
|
37
|
-
def progress
|
38
|
-
|
35
|
+
def progress(total = nil, done = nil)
|
36
|
+
if invocations.empty? || done == 0
|
37
|
+
0
|
38
|
+
else
|
39
|
+
total ||= invocations.count
|
40
|
+
done ||= sub_tasks.where(result: %w(success warning error)).count
|
41
|
+
((done.to_f / total) * 100).round
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def progress_report
|
46
|
+
invocations.reduce({
|
47
|
+
pending: 0,
|
48
|
+
running: 0,
|
49
|
+
success: 0,
|
50
|
+
warning: 0,
|
51
|
+
failed: 0,
|
52
|
+
cancelled: 0,
|
53
|
+
}) do |report, invocation|
|
54
|
+
status = (invocation.status == 'planned' ? 'pending' : invocation.status)
|
55
|
+
report[status.to_sym] += 1
|
56
|
+
report
|
57
|
+
end
|
39
58
|
end
|
40
59
|
|
41
60
|
def finished?
|
@@ -0,0 +1,57 @@
|
|
1
|
+
class Setting::Patching < ::Setting
|
2
|
+
def self.default_settings
|
3
|
+
http_proxy_select = [{
|
4
|
+
name: _('Http Proxies'),
|
5
|
+
class: 'HttpProxy',
|
6
|
+
scope: 'all',
|
7
|
+
value_method: 'name',
|
8
|
+
text_method: 'name_and_url',
|
9
|
+
}]
|
10
|
+
|
11
|
+
time_zone_select = [{
|
12
|
+
name: _('Time Zones'),
|
13
|
+
class: 'ActiveSupport::TimeZone',
|
14
|
+
scope: 'all',
|
15
|
+
value_method: 'name',
|
16
|
+
text_method: 'name',
|
17
|
+
}]
|
18
|
+
|
19
|
+
# set(name, description, default, fullname, value, { options })
|
20
|
+
[
|
21
|
+
self.set('host_max_wait_for_up', N_("Maximum seconds to wait for a host after patching restart."),
|
22
|
+
600, N_("Max wait for host up")),
|
23
|
+
self.set('host_patch_timeout', N_("Maximum seconds for a patching invocation to run before timing out"),
|
24
|
+
nil, N_('Patch Timeout')),
|
25
|
+
self.set('patch_schedule_time_zone', N_('Time zone used to base patch window scheduling off of.'),
|
26
|
+
'UTC', N_('Patch Schedule Time Zone'), nil,
|
27
|
+
collection: proc { time_zone_select }),
|
28
|
+
self.set('ticket_api_host', N_('Host used for change management tickets'),
|
29
|
+
nil, N_('Ticket API host')),
|
30
|
+
self.set('ticket_api_proxy', N_('HTTP Proxy to access ticket API host'),
|
31
|
+
nil, N_('Ticket API HTTP proxy'), nil,
|
32
|
+
collection: proc { http_proxy_select }, include_blank: N_('no proxy')),
|
33
|
+
self.set('ticket_api_user', N_('User with access to ticket API'),
|
34
|
+
nil, N_('Ticket API user')),
|
35
|
+
self.set('ticket_api_password', N_('Password for ticket API user'),
|
36
|
+
nil, N_('Ticket API password'), nil, { encrypted: true }),
|
37
|
+
self.set('ticket_api_path', N_('Ticket API path for REST/CRUD operations'),
|
38
|
+
'/api/now/table/change_request', N_('Ticket API path')),
|
39
|
+
self.set('ticket_web_ui_path', N_('Path for opening a ticket in the web UI'),
|
40
|
+
'/change_request.do?sys_id=:id', N_('Ticket Web UI path')),
|
41
|
+
self.set('ticket_label_field', N_('Name of the field used for the ticket label'),
|
42
|
+
'number', N_('Ticket label field')),
|
43
|
+
self.set('ticket_id_field', N_('Name of the field used for the ticket id'),
|
44
|
+
'sys_id', N_('Ticket ID field')),
|
45
|
+
self.set('skip_broken_patches', N_('Skip broken dependencies during patching'), true, N_('Skip broken patches'))
|
46
|
+
]
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.humanized_category
|
50
|
+
N_('Patching')
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.load_defaults
|
54
|
+
BLANK_ATTRS.concat %w(ticket_api_host ticket_api_proxy ticket_api_user ticket_api_password, host_patch_timeout)
|
55
|
+
super
|
56
|
+
end
|
57
|
+
end
|
@@ -57,8 +57,7 @@ module ForemanPatch
|
|
57
57
|
|
58
58
|
@response = JSON.parse(raw)
|
59
59
|
rescue RestClient::ExceptionWithResponse => error
|
60
|
-
|
61
|
-
Rails.logger.error(error)
|
60
|
+
Rails.logger.error(error.response)
|
62
61
|
rescue => error
|
63
62
|
Rails.logger.error(error)
|
64
63
|
end
|
@@ -22,7 +22,7 @@
|
|
22
22
|
<%= group.label %>
|
23
23
|
</td>
|
24
24
|
<td class="hidden-xs ellipsis">
|
25
|
-
<%= group.default_window_plan
|
25
|
+
<%= group.default_window_plan&.name %>
|
26
26
|
</td>
|
27
27
|
<td class="hidden-xs">
|
28
28
|
<%= link_to group.hosts.count, main_app.hosts_path(search: %Q[patch_group = "#{group.name}"]) %>
|
@@ -11,9 +11,34 @@ breadcrumbs(resource_url: api_round_invocations_path(@round.id),
|
|
11
11
|
items: items)
|
12
12
|
%>
|
13
13
|
|
14
|
+
<% stylesheet 'foreman_remote_execution/foreman_remote_execution' %>
|
15
|
+
<% javascript 'foreman_remote_execution/template_invocation' %>
|
16
|
+
|
14
17
|
<%=
|
15
18
|
title_actions(link_to(_('Back to Group'), round_path(@round), class: 'btn btn-default'),
|
19
|
+
button_group(link_to_function(_('Toggle STDERR'), '$("div.line.stderr").toggle()', class: 'btn btn-default'),
|
20
|
+
link_to_function(_('Toggle STDOUT'), '$("div.line.stdout").toggle()', class: 'btn btn-default'),
|
21
|
+
link_to_function(_('Toggle DEBUG'), '$("div.line.debug").toggle()', class: 'btn btn-default')),
|
16
22
|
button_group(invocation_task_buttons(@invocation.task, @invocation)))
|
17
23
|
%>
|
18
24
|
|
19
|
-
|
25
|
+
<ul class="nav nav-tabs" data="tabs">
|
26
|
+
<li class="active"><a href="#primary" data-toggle="tab"><%= _('Primary') %></a></li>
|
27
|
+
<% @invocation.phases.each do |phase| %>
|
28
|
+
<li><a href="#<%= phase.class.name.demodulize.underscore %>" data-toggle="tab"><%= phase.humanized_name.titlecase %></a></li>
|
29
|
+
<% end %>
|
30
|
+
</ul>
|
31
|
+
|
32
|
+
<div class="tab-content">
|
33
|
+
<div class="tab-pane active" id="primary">
|
34
|
+
<%= render partial: 'primary' %>
|
35
|
+
</div>
|
36
|
+
|
37
|
+
<% @invocation.phases.each do |phase| %>
|
38
|
+
<%= render partial: 'phase', locals: { phase: phase } %>
|
39
|
+
<% end %>
|
40
|
+
</div>
|
41
|
+
|
42
|
+
<script>
|
43
|
+
<%= render partial: 'refresh.js' %>
|
44
|
+
</script>
|
@@ -7,20 +7,17 @@ feature: ensure_services
|
|
7
7
|
provider_type: SSH
|
8
8
|
%>
|
9
9
|
<% if @host.operatingsystem.family == "Redhat" && @host.operatingsystem.major.to_i > 6 %>
|
10
|
-
|
11
|
-
|
10
|
+
state=$(systemctl is-system-running)
|
11
|
+
while [ $? -ne 0 ]; do
|
12
12
|
case $state in
|
13
13
|
initializing | starting)
|
14
14
|
sleep 5
|
15
|
+
state=$(systemctl is-system-running)
|
15
16
|
;;
|
16
17
|
maintenance | stopping | offline)
|
17
|
-
echo
|
18
|
+
echo $state
|
18
19
|
exit 1
|
19
20
|
;;
|
20
|
-
running)
|
21
|
-
echo "All services running."
|
22
|
-
exit 0
|
23
|
-
;;
|
24
21
|
*)
|
25
22
|
systemctl list-units --failed
|
26
23
|
exit 1
|
data/config/api_routes.rb
CHANGED
@@ -1,41 +1,37 @@
|
|
1
1
|
ForemanPatch::Engine.routes.draw do
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
resources :
|
6
|
-
|
7
|
-
|
2
|
+
scope :foreman_patch, path: '/foreman_patch' do
|
3
|
+
namespace :api do
|
4
|
+
scope '(:apiv)', module: :v2, defaults: { apiv: 'v2' }, apiv: /v1|v2/, constraints: ApiConstraints.new(version: 2, default: true) do
|
5
|
+
resources :plans, only: [:index, :show, :create, :update, :destroy] do
|
6
|
+
resources :window_plans, only: [:index, :create]
|
7
|
+
resources :cycles, only: [:index, :create]
|
8
|
+
end
|
8
9
|
|
9
|
-
|
10
|
+
resources :window_plans, only: [:index, :show, :update, :destroy]
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
end
|
14
|
-
|
15
|
-
resources :windows, only: [:show, :update, :destroy] do
|
16
|
-
resources :rounds, only: [:index]
|
17
|
-
member do
|
18
|
-
post :schedule
|
12
|
+
resources :cycles, only: [:index, :create, :show, :update, :destroy] do
|
13
|
+
resources :windows, only: [:index, :create]
|
19
14
|
end
|
20
|
-
end
|
21
15
|
|
22
|
-
|
16
|
+
resources :windows, only: [:show, :update, :destroy] do
|
17
|
+
resources :rounds, only: [:index]
|
18
|
+
member do
|
19
|
+
post :schedule
|
20
|
+
end
|
21
|
+
end
|
23
22
|
|
24
|
-
|
25
|
-
resources :invocations, only: [:index]
|
23
|
+
resources :groups, only: [:index, :show, :create, :update, :destroy]
|
26
24
|
|
27
|
-
|
28
|
-
|
25
|
+
resources :rounds, only: [:show, :create, :update, :destroy] do
|
26
|
+
resources :invocations, only: [:index]
|
27
|
+
member do
|
28
|
+
get :status
|
29
|
+
end
|
29
30
|
end
|
30
|
-
end
|
31
31
|
|
32
|
-
|
33
|
-
collection do
|
34
|
-
put 'move'
|
35
|
-
put 'cancel'
|
36
|
-
end
|
37
|
-
end
|
32
|
+
resources :invocations, only: [:show]
|
38
33
|
|
34
|
+
end
|
39
35
|
end
|
40
36
|
end
|
41
37
|
end
|
data/config/routes.rb
CHANGED
@@ -1,58 +1,47 @@
|
|
1
1
|
ForemanPatch::Engine.routes.draw do
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
scope :foreman_patch, path: '/foreman_patch' do
|
3
|
+
resources :groups, only: [:index, :new, :create, :edit, :update, :destroy] do
|
4
|
+
collection do
|
5
|
+
get 'auto_complete_search'
|
6
|
+
end
|
5
7
|
end
|
6
|
-
end
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
resources :cycles, only: [:index, :show, :destroy] do
|
10
|
+
collection do
|
11
|
+
get 'auto_complete_search'
|
12
|
+
end
|
12
13
|
|
13
|
-
|
14
|
-
|
14
|
+
resources :windows, only: [:new, :create]
|
15
|
+
end
|
15
16
|
|
16
|
-
|
17
|
+
resources :windows, only: [:show, :destroy]
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
19
|
+
resources :rounds, only: [:show] do
|
20
|
+
collection do
|
21
|
+
get 'auto_complete_search'
|
22
|
+
end
|
21
23
|
end
|
22
|
-
end
|
23
24
|
|
24
|
-
|
25
|
-
|
26
|
-
|
25
|
+
resources :invocations, only: [:show, :destroy] do
|
26
|
+
collection do
|
27
|
+
get 'auto_complete_search'
|
28
|
+
end
|
27
29
|
end
|
28
|
-
end
|
29
30
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
31
|
+
resources :plans, only: [:index, :new, :create, :show, :edit, :update, :destroy] do
|
32
|
+
resources :window_plans, only: [:new, :create]
|
33
|
+
member do
|
34
|
+
post :iterate
|
35
|
+
end
|
34
36
|
end
|
35
|
-
end
|
36
37
|
|
37
|
-
|
38
|
+
resources :window_plans, only: [:edit, :update, :destroy]
|
38
39
|
|
39
|
-
|
40
|
-
|
41
|
-
collection do
|
42
|
-
get 'auto_complete_search'
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
constraints(id: %r{[^/]+}) do
|
47
|
-
resources :hosts, only: [], controller: '/hosts' do
|
40
|
+
resources :ticket_fields, except: [:show] do
|
41
|
+
resources :lookup_values, only: [:index, :create, :update, :destroy]
|
48
42
|
collection do
|
49
|
-
|
50
|
-
post 'update_multiple_patch_group'
|
43
|
+
get 'auto_complete_search'
|
51
44
|
end
|
52
45
|
end
|
53
46
|
end
|
54
47
|
end
|
55
|
-
|
56
|
-
Foreman::Application.routes.draw do
|
57
|
-
mount ForemanPatch::Engine, at: '/foreman_patch'
|
58
|
-
end
|
@@ -1,10 +1,16 @@
|
|
1
1
|
User.as_anonymous_admin do
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
2
|
+
RemoteExecutionFeature.without_auditing do
|
3
|
+
if Rails.env.test? || Foreman.in_rake?
|
4
|
+
ForemanPatch.register_rex_features
|
5
|
+
end
|
6
|
+
|
7
|
+
JobTemplate.without_auditing do
|
8
|
+
module_template = JobTemplate.find_by(name: 'Power Action - SSH Default')
|
9
|
+
if module_template && !Rails.env.test? && Setting[:remote_execution_sync_templates]
|
10
|
+
module_template.sync_feature('power_action')
|
11
|
+
module_template.organizations << Organization.unscoped.all if module_template.organizations.empty?
|
12
|
+
module_template.locations << Location.unscoped.all if module_template.locations.empty?
|
13
|
+
end
|
8
14
|
end
|
9
15
|
end
|
10
16
|
end
|
data/lib/foreman_patch/engine.rb
CHANGED
@@ -1,9 +1,15 @@
|
|
1
1
|
module ForemanPatch
|
2
2
|
class Engine < ::Rails::Engine
|
3
|
-
isolate_namespace ForemanPatch
|
4
3
|
engine_name 'foreman_patch'
|
4
|
+
isolate_namespace ForemanPatch
|
5
5
|
|
6
|
-
config.
|
6
|
+
config.autoload_paths += Dir["#{config.root}/app/controllers/concerns"]
|
7
|
+
config.autoload_paths += Dir["#{config.root}/app/helpers/concerns"]
|
8
|
+
config.autoload_paths += Dir["#{config.root}/app/models/concerns"]
|
9
|
+
|
10
|
+
initializer 'foreman_patch.configure_assets', group: :assets do
|
11
|
+
SETTINGS[:foreman_patch] = { assets: { precompile: ['foreman_patch.css'] } }
|
12
|
+
end
|
7
13
|
|
8
14
|
# Add any db migrations
|
9
15
|
initializer 'foreman_patch.load_app_instance_data' do |app|
|
@@ -12,29 +18,40 @@ module ForemanPatch
|
|
12
18
|
end
|
13
19
|
end
|
14
20
|
|
15
|
-
initializer 'foreman_patch.
|
16
|
-
|
21
|
+
initializer 'foreman_patch.mount_engine', before: :sooner_routes_load do |app|
|
22
|
+
app.routes_reloader.paths << "#{ForemanPatch::Engine.root}/config/routes/mount_engine.rb"
|
23
|
+
app.routes_reloader.paths << "#{ForemanPatch::Engine.root}/config/api_routes.rb"
|
24
|
+
app.routes_reloader.paths.unshift("#{ForemanPatch::Engine.root}/config/routes/overrides.rb")
|
25
|
+
end
|
26
|
+
|
27
|
+
initializer 'foreman_patch.load_default_settings', before: :load_config_initializers do |_app|
|
28
|
+
require_dependency File.expand_path('../../../app/models/setting/patching.rb', __FILE__)
|
29
|
+
end
|
30
|
+
|
31
|
+
initializer 'foreman_patch.require_dynflow', before: 'foreman_tasks.initialize_dynflow' do |_app|
|
32
|
+
::ForemanTasks.dynflow.require!
|
33
|
+
::ForemanTasks.dynflow.config.eager_load_paths << File.join(ForemanPatch::Engine.root, 'app/lib/actions/foreman_patch')
|
34
|
+
end
|
35
|
+
|
36
|
+
initializer 'foreman_patch.register_plugin', :before => :finisher_hook do |_app|
|
37
|
+
require 'foreman_patch/plugin'
|
17
38
|
Apipie.configuration.checksum_path += ['/foreman_patch/api/']
|
18
39
|
end
|
19
40
|
|
20
|
-
initializer 'foreman_patch.
|
21
|
-
|
22
|
-
ForemanTasks.dynflow.config.eager_load_paths << File.join(ForemanPatch::Engine.root, 'app/lib/actions/foreman_patch')
|
23
|
-
ForemanTasks.dynflow.eager_load_actions!
|
41
|
+
initializer 'foreman_patch.helpers' do |_app|
|
42
|
+
ActionView::Base.include ForemanPatch::HostsHelper
|
24
43
|
end
|
25
44
|
|
26
45
|
# Include concerns in this config.to_prepare block
|
27
46
|
config.to_prepare do
|
28
47
|
# Model extensions
|
29
|
-
::Host::Managed.include ForemanPatch::Concerns::HostManagedExtensions
|
48
|
+
::Host::Managed.send(:include, ForemanPatch::Concerns::HostManagedExtensions)
|
30
49
|
|
31
50
|
# Controller extensions
|
32
51
|
::HostsController.include ForemanPatch::Concerns::HostsControllerExtensions
|
33
52
|
|
34
53
|
# Api Controller extensions
|
35
54
|
::Api::V2::HostsController.include ForemanPatch::Concerns::Api::V2::HostsControllerExtensions
|
36
|
-
rescue => e
|
37
|
-
Rails.logger.warn "ForemanPatch: skipping engine hook (#{e})"
|
38
55
|
end
|
39
56
|
|
40
57
|
rake_tasks do
|
@@ -49,4 +66,22 @@ module ForemanPatch
|
|
49
66
|
Foreman::Gettext::Support.add_text_domain locale_domain, locale_dir
|
50
67
|
end
|
51
68
|
end
|
69
|
+
|
70
|
+
def self.table_name_prefix
|
71
|
+
'foreman_patch_'
|
72
|
+
end
|
73
|
+
|
74
|
+
def self.use_relative_model_naming
|
75
|
+
true
|
76
|
+
end
|
77
|
+
|
78
|
+
def self.register_rex_features
|
79
|
+
RemoteExecutionFeature.register(
|
80
|
+
:power_action,
|
81
|
+
N_('Power Action'),
|
82
|
+
description: N_('Power Action'),
|
83
|
+
provided_inputs: 'action',
|
84
|
+
host_action_button: false
|
85
|
+
)
|
86
|
+
end
|
52
87
|
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
Foreman::Plugin.register :foreman_patch do
|
2
|
+
requires_foreman '>= 2.1'
|
3
|
+
|
4
|
+
apipie_documented_controllers(["#{ForemanPatch::Engine.root}/app/controllers/foreman_patch/api/v2/*.rb"])
|
5
|
+
|
6
|
+
register_facet ForemanPatch::Host::GroupFacet, :group_facet do
|
7
|
+
api_view list: 'foreman_patch/api/v2/group_facet/base_with_root', single: 'foreman_patch/api/v2/group_facet/show'
|
8
|
+
api_docs :group_facet_attributes, ::ForemanPatch::Api::V2::HostGroupsController
|
9
|
+
extend_model ForemanPatch::Concerns::GroupFacetHostExtensions
|
10
|
+
set_dependent_action :destroy
|
11
|
+
end
|
12
|
+
|
13
|
+
# Add permissions
|
14
|
+
security_block :foreman_patch do
|
15
|
+
end
|
16
|
+
|
17
|
+
divider :top_menu, caption: N_('Patching'), parent: :content_menu
|
18
|
+
menu :top_menu, :groups,
|
19
|
+
caption: N_('Groups'),
|
20
|
+
engine: ForemanPatch::Engine,
|
21
|
+
parent: :content_menu
|
22
|
+
|
23
|
+
menu :top_menu, :cycles,
|
24
|
+
caption: N_('Cycles'),
|
25
|
+
engine: ForemanPatch::Engine,
|
26
|
+
parent: :content_menu
|
27
|
+
|
28
|
+
menu :top_menu, :plans,
|
29
|
+
caption: N_('Plans'),
|
30
|
+
engine: ForemanPatch::Engine,
|
31
|
+
parent: :content_menu
|
32
|
+
|
33
|
+
menu :top_menu, :ticket_fields,
|
34
|
+
caption: N_('Ticket Fields'),
|
35
|
+
engine: ForemanPatch::Engine,
|
36
|
+
parent: :content_menu
|
37
|
+
|
38
|
+
parameter_filter ::Host::Managed, :group_facet_attributes => [:group_id]
|
39
|
+
|
40
|
+
describe_host do
|
41
|
+
multiple_actions_provider :patch_host_multiple_actions
|
42
|
+
overview_fields_provider :patch_host_overview_fields
|
43
|
+
end
|
44
|
+
|
45
|
+
RemoteExecutionFeature.register(:power_action, N_("Power Action"), description: N_("Power Action"), provided_inputs: ['action'])
|
46
|
+
RemoteExecutionFeature.register(:ensure_services, N_("Ensure Services"), description: N_("Ensure Services are running"))
|
47
|
+
end
|
data/lib/foreman_patch.rb
CHANGED
data/locale/en/foreman_patch.po
CHANGED
data/locale/foreman_patch.pot
CHANGED
data/locale/gemspec.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
# Matches foreman_patch.gemspec
|
2
|
-
_(
|
2
|
+
_('TODO: Description of ForemanPatch.')
|