foreman_bootdisk 15.0.0 → 17.1.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/.github/workflows/rubocop.yaml +19 -0
- data/.tx/config +1 -1
- data/AUTHORS +11 -0
- data/README.md +25 -0
- data/app/controllers/concerns/allowed_actions.rb +16 -0
- data/app/controllers/foreman_bootdisk/api/v2/disks_controller.rb +9 -7
- data/app/controllers/foreman_bootdisk/api/v2/subnet_disks_controller.rb +16 -4
- data/app/controllers/foreman_bootdisk/disks_controller.rb +14 -10
- data/app/helpers/concerns/foreman_bootdisk/hosts_helper_ext.rb +71 -45
- data/app/lib/foreman_bootdisk/scope/bootdisk.rb +28 -1
- data/app/lib/foreman_bootdisk/scope/full_host_bootdisk_efi.rb +15 -0
- data/app/models/concerns/foreman_bootdisk/compute_resources/vmware.rb +10 -1
- data/app/models/concerns/foreman_bootdisk/host_ext.rb +13 -6
- data/app/models/concerns/foreman_bootdisk/orchestration/compute.rb +38 -22
- data/app/models/setting/bootdisk.rb +25 -19
- data/app/services/foreman_bootdisk/iso_generator.rb +132 -51
- data/app/services/foreman_bootdisk/renderer.rb +36 -19
- data/app/views/foreman_bootdisk/generic_efi_host.erb +68 -0
- data/app/views/foreman_bootdisk/generic_static_host.erb +34 -0
- data/app/views/foreman_bootdisk/host.erb +29 -8
- data/db/seeds.d/50-bootdisk_templates.rb +15 -31
- data/lib/foreman_bootdisk/engine.rb +9 -6
- data/lib/foreman_bootdisk/version.rb +1 -1
- data/lib/tasks/bootdisk.rake +10 -24
- data/locale/action_names.rb +7 -0
- data/locale/ca/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/ca/foreman_bootdisk.po +58 -7
- data/locale/de/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/de/foreman_bootdisk.po +62 -11
- data/locale/en/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/en/foreman_bootdisk.po +56 -5
- data/locale/en_GB/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/en_GB/foreman_bootdisk.po +62 -11
- data/locale/es/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/es/foreman_bootdisk.po +62 -11
- data/locale/foreman_bootdisk.pot +108 -36
- data/locale/fr/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/fr/foreman_bootdisk.po +61 -10
- data/locale/it/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/it/foreman_bootdisk.po +60 -9
- data/locale/ja/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/ja/foreman_bootdisk.po +61 -10
- data/locale/ko/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/ko/foreman_bootdisk.po +60 -9
- data/locale/pt_BR/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/pt_BR/foreman_bootdisk.po +60 -9
- data/locale/ru/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/ru/foreman_bootdisk.po +60 -9
- data/locale/sv_SE/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/sv_SE/foreman_bootdisk.po +59 -8
- data/locale/zh_CN/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/zh_CN/foreman_bootdisk.po +60 -9
- data/locale/zh_TW/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/zh_TW/foreman_bootdisk.po +60 -9
- data/release-gem +2 -0
- data/test/functional/foreman_bootdisk/api/v2/disks_controller_test.rb +51 -17
- data/test/functional/foreman_bootdisk/api/v2/subnet_disks_controller_test.rb +23 -10
- data/test/functional/foreman_bootdisk/disks_controller_test.rb +65 -25
- data/test/test_plugin_helper.rb +21 -3
- data/test/unit/concerns/host_test.rb +12 -1
- data/test/unit/concerns/orchestration/compute_test.rb +32 -13
- data/test/unit/foreman_bootdisk/renderer_test.rb +1 -1
- data/test/unit/iso_generator_test.rb +6 -7
- metadata +14 -9
@@ -5,45 +5,85 @@ require 'test_plugin_helper'
|
|
5
5
|
class ForemanBootdisk::DisksControllerTest < ActionController::TestCase
|
6
6
|
include ForemanBootdiskTestHelper
|
7
7
|
setup :setup_bootdisk
|
8
|
+
setup :setup_referer
|
9
|
+
setup :setup_org_loc
|
8
10
|
|
9
|
-
|
10
|
-
|
11
|
-
|
11
|
+
def perform_generic_generate
|
12
|
+
tmp = create_tempfile
|
13
|
+
ForemanBootdisk::ISOGenerator.expects(:generate).yields(create_tempfile.path)
|
12
14
|
get :generic, session: set_session_user
|
13
15
|
assert_response :success
|
14
|
-
|
16
|
+
ensure
|
17
|
+
tmp.unlink
|
15
18
|
end
|
16
19
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
20
|
+
def perform_host_generate
|
21
|
+
tmp = create_tempfile
|
22
|
+
ForemanBootdisk::ISOGenerator.expects(:generate).yields(create_tempfile.path)
|
23
|
+
get :host, params: { id: @host.name }, session: set_session_user
|
24
|
+
assert_response :success
|
25
|
+
ensure
|
26
|
+
tmp.unlink
|
27
|
+
end
|
28
|
+
|
29
|
+
def perform_full_host_generate
|
30
|
+
tmp = create_tempfile
|
31
|
+
ForemanBootdisk::ISOGenerator.expects(:generate_full_host).yields(create_tempfile.path)
|
32
|
+
get :full_host, params: { id: @host.name }, session: set_session_user
|
33
|
+
assert_response :success
|
34
|
+
ensure
|
35
|
+
tmp.unlink
|
36
|
+
end
|
37
|
+
|
38
|
+
def perform_subnet_generate
|
39
|
+
tmp = create_tempfile
|
40
|
+
ForemanBootdisk::ISOGenerator.expects(:generate).yields(create_tempfile.path)
|
41
|
+
get :subnet, params: { id: @host.name }, session: set_session_user
|
42
|
+
assert_empty flash[:error]
|
43
|
+
assert_response :success
|
44
|
+
ensure
|
45
|
+
tmp.unlink
|
46
|
+
end
|
47
|
+
|
48
|
+
describe '#generic with TFTP' do
|
49
|
+
setup :setup_subnet_with_tftp
|
21
50
|
setup :setup_host
|
22
51
|
|
52
|
+
test 'should generate generic image' do
|
53
|
+
perform_generic_generate
|
54
|
+
end
|
55
|
+
|
23
56
|
test 'should generate host image' do
|
24
|
-
|
25
|
-
@controller.expects(:read_file).with('temp ISO').returns('ISO image')
|
26
|
-
get :host, params: { id: @host.name }, session: set_session_user
|
27
|
-
assert_response :success
|
28
|
-
assert_equal 'ISO image', @response.body
|
57
|
+
perform_host_generate
|
29
58
|
end
|
30
59
|
|
31
60
|
test 'should generate full host image' do
|
32
|
-
|
33
|
-
@controller.expects(:read_file).with('temp ISO').returns('ISO image')
|
34
|
-
get :full_host, params: { id: @host.name }, session: set_session_user
|
35
|
-
assert_response :success
|
36
|
-
assert_equal 'ISO image', @response.body
|
61
|
+
perform_full_host_generate
|
37
62
|
end
|
38
63
|
|
39
64
|
test 'should generate subnet image' do
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
65
|
+
perform_subnet_generate
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe '#subnet_host with TFTP and HTTPBOOT' do
|
70
|
+
setup :setup_subnet_with_tftp_httpboot_template
|
71
|
+
setup :setup_host
|
72
|
+
|
73
|
+
test 'should generate generic image' do
|
74
|
+
perform_generic_generate
|
75
|
+
end
|
76
|
+
|
77
|
+
test 'should generate host image' do
|
78
|
+
perform_host_generate
|
79
|
+
end
|
80
|
+
|
81
|
+
test 'should generate full host image' do
|
82
|
+
perform_full_host_generate
|
83
|
+
end
|
84
|
+
|
85
|
+
test 'should generate subnet image' do
|
86
|
+
perform_subnet_generate
|
47
87
|
end
|
48
88
|
end
|
49
89
|
|
data/test/test_plugin_helper.rb
CHANGED
@@ -5,15 +5,23 @@ require 'webmock/minitest'
|
|
5
5
|
require 'webmock'
|
6
6
|
|
7
7
|
module ForemanBootdiskTestHelper
|
8
|
+
def create_tempfile
|
9
|
+
file = Tempfile.new('bootdisk-test', '/tmp')
|
10
|
+
file.close
|
11
|
+
file
|
12
|
+
end
|
13
|
+
|
8
14
|
def setup_bootdisk
|
15
|
+
ForemanBootdisk::Scope::Bootdisk.any_instance.stubs(:bootdisk_chain_url).returns('http://smart-proxy.example.com/unattended/iPXE?mac=')
|
9
16
|
setup_routes
|
10
17
|
setup_settings
|
11
18
|
setup_templates
|
12
19
|
end
|
13
20
|
|
21
|
+
# TODO remove me
|
14
22
|
def setup_host_env
|
15
23
|
setup_org_loc
|
16
|
-
|
24
|
+
setup_subnet_with_tftp
|
17
25
|
setup_host
|
18
26
|
end
|
19
27
|
|
@@ -39,7 +47,17 @@ module ForemanBootdiskTestHelper
|
|
39
47
|
@loc = FactoryBot.create(:location)
|
40
48
|
end
|
41
49
|
|
42
|
-
def
|
50
|
+
def setup_subnet_with_tftp_httpboot_template
|
51
|
+
ProxyAPI::V2::Features.any_instance.stubs(:features).returns(:httpboot => { :settings => { :https_port => 1234 }, :state => 'running' }, :templates => {}, :tftp => {})
|
52
|
+
SmartProxy.any_instance.stubs(:httpboot_http_port).returns('8888')
|
53
|
+
SmartProxy.any_instance.stubs(:httpboot_https_port).returns('9999')
|
54
|
+
|
55
|
+
proxy = FactoryBot.create(:smart_proxy, features: [FactoryBot.create(:tftp_feature), FactoryBot.create(:feature, :templates), FactoryBot.create(:feature, :httpboot)])
|
56
|
+
proxy.reload
|
57
|
+
setup_subnet_no_tftp.update! tftp: proxy, httpboot: proxy, template: proxy
|
58
|
+
end
|
59
|
+
|
60
|
+
def setup_subnet_with_tftp
|
43
61
|
tftp_proxy = FactoryBot.create(:smart_proxy, features: [FactoryBot.create(:tftp_feature)])
|
44
62
|
setup_subnet_no_tftp.update! tftp: tftp_proxy
|
45
63
|
end
|
@@ -49,6 +67,6 @@ module ForemanBootdiskTestHelper
|
|
49
67
|
end
|
50
68
|
|
51
69
|
def setup_host
|
52
|
-
@host = FactoryBot.create(:host, :managed, subnet: @subnet, ip: @subnet.network.sub(/0$/, '4'), organization: @org, location: @loc)
|
70
|
+
@host = FactoryBot.create(:host, :managed, subnet: @subnet, ip: @subnet.network.sub(/0$/, '4'), organization: @org, location: @loc, build: true)
|
53
71
|
end
|
54
72
|
end
|
@@ -36,7 +36,7 @@ module ForemanBootdisk
|
|
36
36
|
test 'host should not have bootdisk' do
|
37
37
|
if unattended?
|
38
38
|
h = FactoryBot.create(:host)
|
39
|
-
|
39
|
+
assert_not(h.bootdisk?)
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
@@ -69,5 +69,16 @@ module ForemanBootdisk
|
|
69
69
|
assert host.bootdisk_downloadable?
|
70
70
|
end
|
71
71
|
end
|
72
|
+
|
73
|
+
context '#bootdisk_build?' do
|
74
|
+
test 'should be false for hosts without bootdisk' do
|
75
|
+
host = FactoryBot.create(:host)
|
76
|
+
assert_not host.bootdisk_build?
|
77
|
+
end
|
78
|
+
|
79
|
+
test 'should be available in safe mode' do
|
80
|
+
assert Host::Managed::Jail.allowed?(:bootdisk_build?)
|
81
|
+
end
|
82
|
+
end
|
72
83
|
end
|
73
84
|
end
|
@@ -22,29 +22,48 @@ module ForemanBootdisk
|
|
22
22
|
@host.send(:setAttachIsoImage)
|
23
23
|
end
|
24
24
|
|
25
|
-
test 'provisioning a host with provision method bootdisk should
|
25
|
+
test 'provisioning a host with provision method bootdisk should detach iso' do
|
26
|
+
@cr.expects(:iso_detach)
|
27
|
+
@host.send(:setDetachIsoImage)
|
28
|
+
end
|
29
|
+
|
30
|
+
test 'provisioning a new host with provision method bootdisk should queue bootdisk tasks' do
|
26
31
|
@host.stubs(:compute?).returns(true)
|
32
|
+
@host.stubs(:build?).returns(true)
|
27
33
|
@host.send(:queue_bootdisk_compute)
|
28
34
|
tasks = @host.queue.all.map(&:name)
|
29
35
|
assert_includes tasks, "Generating ISO image for #{@host.name}"
|
30
36
|
assert_includes tasks, "Upload ISO image to datastore for #{@host.name}"
|
31
37
|
assert_includes tasks, "Attach ISO image to CDROM drive for #{@host.name}"
|
38
|
+
assert_not_includes tasks, "Detach ISO image from CDROM drive for #{@host.name}"
|
32
39
|
end
|
33
40
|
|
34
|
-
test 'should
|
35
|
-
@host.
|
36
|
-
|
37
|
-
|
38
|
-
|
41
|
+
test 'rebuilding a host with provision method bootdisk should queue bootdisk tasks' do
|
42
|
+
@host.stubs(:compute?).returns(true)
|
43
|
+
old = stub()
|
44
|
+
old.stubs(:build?).returns(false)
|
45
|
+
@host.stubs(:old).returns(old)
|
46
|
+
@host.stubs(:build?).returns(true)
|
47
|
+
@host.send(:queue_bootdisk_compute)
|
48
|
+
tasks = @host.queue.all.map(&:name)
|
49
|
+
assert_includes tasks, "Generating ISO image for #{@host.name}"
|
50
|
+
assert_includes tasks, "Upload ISO image to datastore for #{@host.name}"
|
51
|
+
assert_includes tasks, "Attach ISO image to CDROM drive for #{@host.name}"
|
52
|
+
assert_not_includes tasks, "Detach ISO image from CDROM drive for #{@host.name}"
|
39
53
|
end
|
40
54
|
|
41
|
-
test 'should
|
42
|
-
host
|
43
|
-
|
44
|
-
|
45
|
-
host.
|
46
|
-
host.
|
47
|
-
|
55
|
+
test 'the iso should be detached when the host leaves build mode' do
|
56
|
+
@host.stubs(:compute?).returns(true)
|
57
|
+
old = stub()
|
58
|
+
old.stubs(:build?).returns(true)
|
59
|
+
@host.stubs(:old).returns(old)
|
60
|
+
@host.stubs(:build?).returns(false)
|
61
|
+
@host.send(:queue_bootdisk_compute)
|
62
|
+
tasks = @host.queue.all.map(&:name)
|
63
|
+
assert_not_includes tasks, "Generating ISO image for #{@host.name}"
|
64
|
+
assert_not_includes tasks, "Upload ISO image to datastore for #{@host.name}"
|
65
|
+
assert_not_includes tasks, "Attach ISO image to CDROM drive for #{@host.name}"
|
66
|
+
assert_includes tasks, "Detach ISO image from CDROM drive for #{@host.name}"
|
48
67
|
end
|
49
68
|
end
|
50
69
|
end
|
@@ -21,7 +21,7 @@ module ForemanBootdisk
|
|
21
21
|
|
22
22
|
test 'does not include a host token' do
|
23
23
|
rendered_template = renderer.generic_template_render
|
24
|
-
assert_includes rendered_template, 'http://
|
24
|
+
assert_includes rendered_template, 'http://smart-proxy.example.com/unattended/iPXE?mac=${net0/mac}'
|
25
25
|
assert_not_includes rendered_template, 'token'
|
26
26
|
end
|
27
27
|
end
|
@@ -11,10 +11,12 @@ module ForemanBootdisk
|
|
11
11
|
let(:medium) { FactoryBot.create(:medium, name: 'Red Hat Enterprise Linux Atomic Mirror') }
|
12
12
|
let(:operatingsystem) { FactoryBot.create(:ubuntu14_10, :with_archs, :with_ptables, media: [medium]) }
|
13
13
|
let(:host) { FactoryBot.create(:host, :managed, operatingsystem: operatingsystem, build: true) }
|
14
|
-
let(:
|
14
|
+
let(:pxelinux_template) { FactoryBot.create(:provisioning_template, template: 'Fake kernel line <%= @kernel %> - <%= @initrd %>') }
|
15
|
+
let(:pxegrub2_template) { FactoryBot.create(:provisioning_template, template: 'Fake kernel line <%= @kernel %> - <%= @initrd %>') }
|
15
16
|
|
16
17
|
setup do
|
17
|
-
host.stubs(:provisioning_template).with(kind: :PXELinux).returns(
|
18
|
+
host.stubs(:provisioning_template).with(kind: :PXELinux).returns(pxelinux_template)
|
19
|
+
host.stubs(:provisioning_template).with(kind: :PXEGrub2).returns(pxegrub2_template)
|
18
20
|
end
|
19
21
|
|
20
22
|
test 'fetch handles redirect' do
|
@@ -40,11 +42,8 @@ module ForemanBootdisk
|
|
40
42
|
)
|
41
43
|
initrd_url = urls[:initrd]
|
42
44
|
|
43
|
-
ForemanBootdisk::ISOGenerator.expects(:generate)
|
44
|
-
|
45
|
-
files: { kernel => kernel_url,
|
46
|
-
initrd => initrd_url }
|
47
|
-
}, anything)
|
45
|
+
ForemanBootdisk::ISOGenerator.expects(:generate)
|
46
|
+
.with({ isolinux: "Fake kernel line #{kernel} - #{initrd}", grub: "Fake kernel line /#{kernel} - /#{initrd}", files: { kernel => kernel_url, initrd => initrd_url } }, anything)
|
48
47
|
|
49
48
|
ForemanBootdisk::ISOGenerator.generate_full_host(host)
|
50
49
|
end
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_bootdisk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 17.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dominic Cleal
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name: rubocop
|
14
|
+
name: theforeman-rubocop
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
@@ -48,18 +48,21 @@ extra_rdoc_files:
|
|
48
48
|
- LICENSE
|
49
49
|
- README.md
|
50
50
|
files:
|
51
|
+
- ".github/workflows/rubocop.yaml"
|
51
52
|
- ".tx/config"
|
52
53
|
- AUTHORS
|
53
54
|
- CHANGES.md
|
54
55
|
- LICENSE
|
55
56
|
- README.md
|
56
57
|
- app/assets/javascripts/foreman_bootdisk/host_edit.js
|
58
|
+
- app/controllers/concerns/allowed_actions.rb
|
57
59
|
- app/controllers/foreman_bootdisk/api/v2/disks_controller.rb
|
58
60
|
- app/controllers/foreman_bootdisk/api/v2/subnet_disks_controller.rb
|
59
61
|
- app/controllers/foreman_bootdisk/disks_controller.rb
|
60
62
|
- app/helpers/concerns/foreman_bootdisk/hosts_helper_ext.rb
|
61
63
|
- app/lib/foreman_bootdisk/scope/bootdisk.rb
|
62
64
|
- app/lib/foreman_bootdisk/scope/full_host_bootdisk.rb
|
65
|
+
- app/lib/foreman_bootdisk/scope/full_host_bootdisk_efi.rb
|
63
66
|
- app/models/concerns/foreman_bootdisk/compute_resources/vmware.rb
|
64
67
|
- app/models/concerns/foreman_bootdisk/host_ext.rb
|
65
68
|
- app/models/concerns/foreman_bootdisk/orchestration/compute.rb
|
@@ -67,7 +70,9 @@ files:
|
|
67
70
|
- app/services/foreman_bootdisk/iso_generator.rb
|
68
71
|
- app/services/foreman_bootdisk/renderer.rb
|
69
72
|
- app/views/foreman_bootdisk/disks/help.html.erb
|
73
|
+
- app/views/foreman_bootdisk/generic_efi_host.erb
|
70
74
|
- app/views/foreman_bootdisk/generic_host.erb
|
75
|
+
- app/views/foreman_bootdisk/generic_static_host.erb
|
71
76
|
- app/views/foreman_bootdisk/host.erb
|
72
77
|
- app/views/hosts/provision_method/bootdisk/_form.html.erb
|
73
78
|
- config/routes.rb
|
@@ -85,6 +90,7 @@ files:
|
|
85
90
|
- lib/foreman_bootdisk/version.rb
|
86
91
|
- lib/tasks/bootdisk.rake
|
87
92
|
- locale/Makefile
|
93
|
+
- locale/action_names.rb
|
88
94
|
- locale/ca/LC_MESSAGES/foreman_bootdisk.mo
|
89
95
|
- locale/ca/foreman_bootdisk.po
|
90
96
|
- locale/de/LC_MESSAGES/foreman_bootdisk.mo
|
@@ -134,7 +140,7 @@ homepage: http://github.com/theforeman/foreman_bootdisk
|
|
134
140
|
licenses:
|
135
141
|
- GPL-3.0
|
136
142
|
metadata: {}
|
137
|
-
post_install_message:
|
143
|
+
post_install_message:
|
138
144
|
rdoc_options: []
|
139
145
|
require_paths:
|
140
146
|
- lib
|
@@ -142,16 +148,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
142
148
|
requirements:
|
143
149
|
- - ">="
|
144
150
|
- !ruby/object:Gem::Version
|
145
|
-
version: '
|
151
|
+
version: '2.5'
|
146
152
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
147
153
|
requirements:
|
148
154
|
- - ">="
|
149
155
|
- !ruby/object:Gem::Version
|
150
156
|
version: '0'
|
151
157
|
requirements: []
|
152
|
-
|
153
|
-
|
154
|
-
signing_key:
|
158
|
+
rubygems_version: 3.1.4
|
159
|
+
signing_key:
|
155
160
|
specification_version: 4
|
156
161
|
summary: Create boot disks to provision hosts with Foreman
|
157
162
|
test_files: []
|