foreman_rescue 4.0.0 → 5.0.0
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/README.md +1 -0
- data/app/models/concerns/foreman_rescue/provisioning_template_extensions.rb +1 -1
- data/lib/foreman_rescue/engine.rb +30 -31
- data/lib/foreman_rescue/version.rb +1 -1
- data/test/models/host_test.rb +11 -1
- data/test/models/provisioning_template_test.rb +26 -0
- metadata +5 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd45138c63c9ba95c38d04d10adfefdc3559c73dfd73b42f7ebcc3788fb727b7
|
4
|
+
data.tar.gz: 8de3698b0905932213fd9217b82083c52b642886a2a08da47ce7a449caab4d83
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59b4a5dcec262b3b166ef8f4cace5ba2ce94f4ce8ad41513952128a4eca6a8327a00e2c4a8ea200fbbe6ca4a714242497850af6ebaf06004f1a55c193df358ae
|
7
|
+
data.tar.gz: 6d091efc235c1a01d40e6e068af5f53fe0542e90c46559f6ed97bbf5e33dca670ea4fc9f259596b5f7ff0c2cf3363699f3ed3acca4a2a76d588c6a9b9b917fb5
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module ForemanRescue
|
4
4
|
module ProvisioningTemplateExtensions
|
5
|
-
def
|
5
|
+
def templates_by_kind(kind)
|
6
6
|
template_kind = TemplateKind.find_by(name: kind)
|
7
7
|
ProvisioningTemplate.where(:template_kind => template_kind).pluck(:name, :name).to_h
|
8
8
|
end
|
@@ -4,9 +4,6 @@ module ForemanRescue
|
|
4
4
|
class Engine < ::Rails::Engine
|
5
5
|
engine_name 'foreman_rescue'
|
6
6
|
|
7
|
-
config.autoload_paths += Dir["#{config.root}/app/helpers/concerns"]
|
8
|
-
config.autoload_paths += Dir["#{config.root}/app/models/concerns"]
|
9
|
-
|
10
7
|
# Add any db migrations
|
11
8
|
initializer 'foreman_rescue.load_app_instance_data' do |app|
|
12
9
|
ForemanRescue::Engine.paths['db/migrate'].existent.each do |path|
|
@@ -14,38 +11,40 @@ module ForemanRescue
|
|
14
11
|
end
|
15
12
|
end
|
16
13
|
|
17
|
-
initializer 'foreman_rescue.register_plugin', :before => :finisher_hook do |
|
18
|
-
|
19
|
-
|
14
|
+
initializer 'foreman_rescue.register_plugin', :before => :finisher_hook do |app| # rubocop:disable Metrics/BlockLength
|
15
|
+
app.reloader.to_prepare do # rubocop:disable Metrics/BlockLength
|
16
|
+
Foreman::Plugin.register :foreman_rescue do # rubocop:disable Metrics/BlockLength
|
17
|
+
requires_foreman '>= 3.13'
|
20
18
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
19
|
+
settings do
|
20
|
+
category :rescue, N_('Rescue') do
|
21
|
+
setting('rescue_pxelinux_tftp_template',
|
22
|
+
type: :string,
|
23
|
+
default: 'Kickstart rescue PXELinux',
|
24
|
+
full_name: N_('PXELinux rescue template'),
|
25
|
+
description: N_('PXELinux template used when booting rescue system'),
|
26
|
+
collection: proc { ProvisioningTemplate.templates_by_kind('PXELinux') })
|
29
27
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
28
|
+
setting('rescue_pxegrub_tftp_template',
|
29
|
+
type: :string,
|
30
|
+
default: '',
|
31
|
+
full_name: N_('PXEGrub rescue template'),
|
32
|
+
description: N_('PXEGrub template used when booting rescue system'),
|
33
|
+
collection: proc { ProvisioningTemplate.templates_by_kind('PXEGrub') })
|
36
34
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
35
|
+
setting('rescue_pxegrub2_tftp_template',
|
36
|
+
type: :string,
|
37
|
+
default: '',
|
38
|
+
full_name: N_('PXEGrub2 rescue template'),
|
39
|
+
description: N_('PXEGrub2 template used when booting rescue system'),
|
40
|
+
collection: proc { ProvisioningTemplate.templates_by_kind('PXEGrub2') })
|
41
|
+
end
|
43
42
|
end
|
44
|
-
end
|
45
43
|
|
46
|
-
|
47
|
-
|
48
|
-
|
44
|
+
# Add permissions
|
45
|
+
security_block :foreman_rescue do
|
46
|
+
permission :rescue_hosts, :'foreman_rescue/hosts' => [:rescue, :set_rescue, :cancel_rescue]
|
47
|
+
end
|
49
48
|
end
|
50
49
|
end
|
51
50
|
end
|
@@ -54,7 +53,7 @@ module ForemanRescue
|
|
54
53
|
Host::Managed.prepend ForemanRescue::HostExtensions
|
55
54
|
HostsHelper.prepend ForemanRescue::HostsHelperExtensions
|
56
55
|
Nic::Managed.prepend ForemanRescue::Orchestration::TFTP
|
57
|
-
ProvisioningTemplate.prepend ForemanRescue::ProvisioningTemplateExtensions
|
56
|
+
ProvisioningTemplate.singleton_class.prepend ForemanRescue::ProvisioningTemplateExtensions
|
58
57
|
rescue StandardError => e
|
59
58
|
Rails.logger.warn "ForemanRescue: skipping engine hook (#{e})"
|
60
59
|
end
|
data/test/models/host_test.rb
CHANGED
@@ -56,7 +56,17 @@ class HostTest < ActiveSupport::TestCase
|
|
56
56
|
|
57
57
|
test 'should deploy rescue template' do
|
58
58
|
Setting['rescue_pxelinux_tftp_template'] = template.name
|
59
|
-
|
59
|
+
version = Foreman::Version.new
|
60
|
+
if version.major.to_i == 3 && version.minor.to_i <= 13
|
61
|
+
ProxyAPI::TFTP.any_instance.expects(:set).with('PXELinux', host.mac, :pxeconfig => template.template).once
|
62
|
+
else
|
63
|
+
ProxyAPI::TFTP.any_instance.expects(:set).with('PXELinux', host.mac, { :pxeconfig => template.template,
|
64
|
+
:targetos => os.name.downcase.to_s,
|
65
|
+
:release => host.operatingsystem.release,
|
66
|
+
:arch => host.arch.name,
|
67
|
+
:bootfile_suffix => host.arch.bootfilename_efi }).once
|
68
|
+
|
69
|
+
end
|
60
70
|
host.stubs(:skip_orchestration?).returns(false) # Enable orchestration
|
61
71
|
assert host.save
|
62
72
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_plugin_helper'
|
4
|
+
|
5
|
+
class ProvisioningHostTest < ActiveSupport::TestCase
|
6
|
+
setup do
|
7
|
+
User.current = FactoryBot.build(:user, :admin)
|
8
|
+
disable_orchestration
|
9
|
+
end
|
10
|
+
|
11
|
+
context 'provisioning template query' do
|
12
|
+
context 'with type PXELinux' do
|
13
|
+
let(:type) do
|
14
|
+
'PXELinux'
|
15
|
+
end
|
16
|
+
|
17
|
+
test 'should return templates' do
|
18
|
+
templates = ProvisioningTemplate.templates_by_kind(type)
|
19
|
+
|
20
|
+
assert_includes templates, 'PXE Default Menu'
|
21
|
+
assert_includes templates, 'PXELinux default local boot'
|
22
|
+
assert_includes templates, 'PXELinux global default'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_rescue
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 5.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Timo Goebel
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: rdoc
|
@@ -71,13 +70,13 @@ files:
|
|
71
70
|
- test/factories/host.rb
|
72
71
|
- test/lib/tasks/seeds_test.rb
|
73
72
|
- test/models/host_test.rb
|
73
|
+
- test/models/provisioning_template_test.rb
|
74
74
|
- test/test_plugin_helper.rb
|
75
75
|
- test/unit/foreman_rescue/access_permissions_test.rb
|
76
76
|
homepage: https://github.com/dm-drogeriemarkt/foreman_rescue
|
77
77
|
licenses:
|
78
78
|
- GPL-3.0
|
79
79
|
metadata: {}
|
80
|
-
post_install_message:
|
81
80
|
rdoc_options: []
|
82
81
|
require_paths:
|
83
82
|
- lib
|
@@ -95,8 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
94
|
- !ruby/object:Gem::Version
|
96
95
|
version: '0'
|
97
96
|
requirements: []
|
98
|
-
rubygems_version: 3.
|
99
|
-
signing_key:
|
97
|
+
rubygems_version: 3.6.7
|
100
98
|
specification_version: 4
|
101
99
|
summary: Provides the ability to boot a host into a rescue system.
|
102
100
|
test_files:
|
@@ -104,5 +102,6 @@ test_files:
|
|
104
102
|
- test/factories/host.rb
|
105
103
|
- test/lib/tasks/seeds_test.rb
|
106
104
|
- test/models/host_test.rb
|
105
|
+
- test/models/provisioning_template_test.rb
|
107
106
|
- test/test_plugin_helper.rb
|
108
107
|
- test/unit/foreman_rescue/access_permissions_test.rb
|