foreman_bootdisk 13.0.0 → 14.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/CHANGES.md +4 -0
- data/README.md +3 -2
- data/app/controllers/foreman_bootdisk/api/v2/disks_controller.rb +11 -9
- data/app/controllers/foreman_bootdisk/api/v2/subnet_disks_controller.rb +37 -31
- data/app/controllers/foreman_bootdisk/disks_controller.rb +20 -19
- data/app/helpers/concerns/foreman_bootdisk/hosts_helper_ext.rb +86 -45
- data/app/lib/foreman_bootdisk/scope/bootdisk.rb +2 -0
- data/app/lib/foreman_bootdisk/scope/full_host_bootdisk.rb +15 -0
- data/app/models/concerns/foreman_bootdisk/compute_resources/vmware.rb +4 -2
- data/app/models/concerns/foreman_bootdisk/host_ext.rb +43 -31
- data/app/models/concerns/foreman_bootdisk/orchestration/compute.rb +14 -10
- data/app/models/setting/bootdisk.rb +28 -23
- data/app/services/foreman_bootdisk/iso_generator.rb +127 -104
- data/app/services/foreman_bootdisk/renderer.rb +16 -13
- data/config/routes.rb +15 -13
- data/config/routes/mount_engine.rb +3 -1
- data/db/migrate/20130914211030_create_host_bootdisk_template.rb +4 -4
- data/db/migrate/20130915104500_edit_host_bootdisk_template_multinic.rb +4 -4
- data/db/migrate/20130915133321_create_kickstart_bootdisk_template.rb +4 -4
- data/db/migrate/20130915201457_create_generic_host_bootdisk_template.rb +4 -4
- data/db/migrate/20131021095100_edit_host_bootdisk_template_dns_secondary.rb +4 -4
- data/db/migrate/20140522185700_change_templatekind_to_bootdisk.rb +16 -14
- data/db/migrate/20171009225200_remove_duplicate_bootdisk_templates.rb +4 -2
- data/db/seeds.d/50-bootdisk_templates.rb +24 -22
- data/lib/foreman_bootdisk.rb +2 -0
- data/lib/foreman_bootdisk/engine.rb +22 -33
- data/lib/foreman_bootdisk/version.rb +3 -1
- data/lib/tasks/bootdisk.rake +34 -17
- data/locale/gemspec.rb +3 -1
- data/test/functional/foreman_bootdisk/api/v2/disks_controller_test.rb +35 -33
- data/test/functional/foreman_bootdisk/api/v2/subnet_disks_controller_test.rb +9 -7
- data/test/functional/foreman_bootdisk/disks_controller_test.rb +27 -25
- data/test/models/host/managed_test.rb +17 -13
- data/test/test_plugin_helper.rb +9 -7
- data/test/unit/access_permissions_test.rb +2 -0
- data/test/unit/concerns/compute_resources/vmware_test.rb +67 -63
- data/test/unit/concerns/host_test.rb +54 -54
- data/test/unit/concerns/orchestration/compute_test.rb +41 -39
- data/test/unit/foreman_bootdisk/renderer_test.rb +3 -1
- data/test/unit/foreman_bootdisk/scope/bootdisk_test.rb +3 -1
- data/test/unit/foreman_bootdisk/scope/full_host_bootdisk_test.rb +30 -0
- data/test/unit/iso_generator_test.rb +57 -40
- metadata +19 -3
@@ -1,73 +1,73 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
test "#bootdisk_build? must be true when provision_method is bootdisk" do
|
5
|
-
host = FactoryBot.build(:host, :managed)
|
6
|
-
host.provision_method = 'bootdisk'
|
7
|
-
assert host.bootdisk_build?
|
8
|
-
refute host.image_build?
|
9
|
-
refute host.pxe_build?
|
10
|
-
end
|
3
|
+
require 'test_plugin_helper'
|
11
4
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
5
|
+
module ForemanBootdisk
|
6
|
+
class HostTest < ActiveSupport::TestCase
|
7
|
+
test '#bootdisk_build? must be true when provision_method is bootdisk' do
|
8
|
+
host = FactoryBot.build(:host, :managed)
|
9
|
+
host.provision_method = 'bootdisk'
|
10
|
+
assert host.bootdisk_build?
|
11
|
+
assert_not host.image_build?
|
12
|
+
assert_not host.pxe_build?
|
13
|
+
end
|
19
14
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
15
|
+
test '#validate_media? must be true when provision_method is bootdisk' do
|
16
|
+
host = FactoryBot.build(:host, :managed,
|
17
|
+
provision_method: 'bootdisk',
|
18
|
+
build: true)
|
19
|
+
assert host.validate_media?
|
20
|
+
end
|
26
21
|
|
22
|
+
test '#can_be_built? must be true when provision_method is bootdisk' do
|
23
|
+
host = FactoryBot.build(:host, :managed,
|
24
|
+
provision_method: 'bootdisk')
|
25
|
+
assert host.can_be_built?
|
26
|
+
end
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
28
|
+
test 'host should have bootdisk' do
|
29
|
+
if unattended?
|
30
|
+
h = FactoryBot.build(:host, :managed,
|
31
|
+
provision_method: 'bootdisk')
|
32
|
+
assert h.bootdisk?
|
33
|
+
end
|
34
34
|
end
|
35
|
-
end
|
36
35
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
36
|
+
test 'host should not have bootdisk' do
|
37
|
+
if unattended?
|
38
|
+
h = FactoryBot.create(:host)
|
39
|
+
assert_equal false, h.bootdisk?
|
40
|
+
end
|
41
41
|
end
|
42
|
-
end
|
43
42
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
43
|
+
context '#bootdisk_downloadable?' do
|
44
|
+
test 'should be true for 64 bit architecture' do
|
45
|
+
architecture = Architecture.where(name: 'x86_64').first
|
46
|
+
host = FactoryBot.build(:host, :managed, architecture: architecture)
|
48
47
|
|
49
|
-
|
50
|
-
|
48
|
+
assert host.bootdisk_downloadable?
|
49
|
+
end
|
51
50
|
|
52
|
-
|
53
|
-
|
54
|
-
|
51
|
+
test 'should be true for 32 bit architecture' do
|
52
|
+
architecture = FactoryBot.create(:architecture, name: 'i386')
|
53
|
+
host = FactoryBot.build(:host, :managed, architecture: architecture)
|
55
54
|
|
56
|
-
|
57
|
-
|
55
|
+
assert host.bootdisk_downloadable?
|
56
|
+
end
|
58
57
|
|
59
|
-
|
60
|
-
|
61
|
-
|
58
|
+
test 'should be false for non-intel architecture' do
|
59
|
+
architecture = Architecture.where(name: 's390').first
|
60
|
+
host = FactoryBot.build(:host, :managed, architecture: architecture)
|
62
61
|
|
63
|
-
|
64
|
-
|
62
|
+
assert_not host.bootdisk_downloadable?
|
63
|
+
end
|
65
64
|
|
66
|
-
|
67
|
-
|
65
|
+
test 'should be true if architecture is absent' do
|
66
|
+
host = FactoryBot.build(:host, :managed, architecture: nil)
|
68
67
|
|
69
|
-
|
70
|
-
|
68
|
+
assert_nil host.architecture
|
69
|
+
assert host.bootdisk_downloadable?
|
70
|
+
end
|
71
71
|
end
|
72
72
|
end
|
73
73
|
end
|
@@ -1,48 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'test_plugin_helper'
|
2
4
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
5
|
+
module ForemanBootdisk
|
6
|
+
class OrchestrationComputeTest < ActiveSupport::TestCase
|
7
|
+
setup do
|
8
|
+
disable_orchestration
|
9
|
+
@cr = FactoryBot.build(:vmware_cr)
|
10
|
+
@host = FactoryBot.build(:host, :managed,
|
11
|
+
compute_resource: @cr,
|
12
|
+
provision_method: 'bootdisk')
|
13
|
+
end
|
12
14
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
15
|
+
test 'provisioning a host with provision method bootdisk should upload iso' do
|
16
|
+
@cr.expects(:iso_upload)
|
17
|
+
@host.send(:setIsoImage)
|
18
|
+
end
|
17
19
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
20
|
+
test 'provisioning a host with provision method bootdisk should attach iso' do
|
21
|
+
@cr.expects(:iso_attach)
|
22
|
+
@host.send(:setAttachIsoImage)
|
23
|
+
end
|
22
24
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
25
|
+
test 'provisioning a host with provision method bootdisk should queue bootdisk tasks' do
|
26
|
+
@host.stubs(:compute?).returns(true)
|
27
|
+
@host.send(:queue_bootdisk_compute)
|
28
|
+
tasks = @host.queue.all.map(&:name)
|
29
|
+
assert_includes tasks, "Generating ISO image for #{@host.name}"
|
30
|
+
assert_includes tasks, "Upload ISO image to datastore for #{@host.name}"
|
31
|
+
assert_includes tasks, "Attach ISO image to CDROM drive for #{@host.name}"
|
32
|
+
end
|
31
33
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
34
|
+
test 'should rebuild bootdisk' do
|
35
|
+
@host.expects(:bootdisk_generate_iso_image).returns(true)
|
36
|
+
@host.expects(:bootdisk_upload_iso).returns(true)
|
37
|
+
@host.expects(:bootdisk_attach_iso).returns(true)
|
38
|
+
assert @host.rebuild_with_bootdisk
|
39
|
+
end
|
38
40
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
41
|
+
test 'should skip rebuild bootdisk' do
|
42
|
+
host = FactoryBot.build(:host,
|
43
|
+
compute_resource: @cr)
|
44
|
+
host.expects(:bootdisk_generate_iso_image).never
|
45
|
+
host.expects(:bootdisk_upload_iso).never
|
46
|
+
host.expects(:bootdisk_attach_iso).never
|
47
|
+
assert host.rebuild_with_bootdisk
|
48
|
+
end
|
47
49
|
end
|
48
50
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'test_plugin_helper'
|
2
4
|
|
3
5
|
module ForemanBootdisk
|
@@ -20,7 +22,7 @@ module ForemanBootdisk
|
|
20
22
|
test 'does not include a host token' do
|
21
23
|
rendered_template = renderer.generic_template_render
|
22
24
|
assert_includes rendered_template, 'http://foreman.some.host.fqdn/unattended/iPXE?mac=${net0/mac}'
|
23
|
-
|
25
|
+
assert_not_includes rendered_template, 'token'
|
24
26
|
end
|
25
27
|
end
|
26
28
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'test_plugin_helper'
|
2
4
|
|
3
5
|
module ForemanBootdisk
|
@@ -13,7 +15,7 @@ module ForemanBootdisk
|
|
13
15
|
end
|
14
16
|
|
15
17
|
test 'should render bootdisk chain url with custom mac' do
|
16
|
-
assert_equal
|
18
|
+
assert_equal 'http://foreman.some.host.fqdn/unattended/iPXE?mac=00%3A11%3A22%3A33%3A44%3A55', scope.bootdisk_chain_url('00:11:22:33:44:55')
|
17
19
|
end
|
18
20
|
end
|
19
21
|
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_plugin_helper'
|
4
|
+
|
5
|
+
module ForemanBootdisk
|
6
|
+
module Scope
|
7
|
+
class BootdiskTest < ActiveSupport::TestCase
|
8
|
+
let(:operatingsystem) { FactoryBot.create(:ubuntu14_10, :with_media, :with_archs) }
|
9
|
+
let(:host) { FactoryBot.build(:host, :managed, operatingsystem: operatingsystem) }
|
10
|
+
let(:source) { Foreman::Renderer::Source::String.new(content: 'Test') }
|
11
|
+
let(:scope) { ForemanBootdisk::Scope::FullHostBootdisk.new(host: host, source: source) }
|
12
|
+
|
13
|
+
setup do
|
14
|
+
MediumProviders::Default.any_instance.stubs(:unique_id).returns('MyMedium01-ZYHBD6OPET')
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '@kernel' do
|
18
|
+
test 'should match filename on bootdisk' do
|
19
|
+
assert_equal 'BOOT/MYMEDIUM01_ZYHBD6OPET_LINUX', scope.instance_variable_get('@kernel')
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '@initrd' do
|
24
|
+
test 'should match filename on bootdisk' do
|
25
|
+
assert_equal 'BOOT/EDIUM01_ZYHBD6OPET_INITRD_GZ', scope.instance_variable_get('@initrd')
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -1,48 +1,65 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'test_plugin_helper'
|
2
4
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
setup :setup_subnet
|
8
|
-
setup :setup_host
|
5
|
+
module ForemanBootdisk
|
6
|
+
class IsoGeneratorTest < ActiveSupport::TestCase
|
7
|
+
include ForemanBootdiskTestHelper
|
8
|
+
setup :setup_bootdisk
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
describe '#generate_full_host' do
|
11
|
+
let(:medium) { FactoryBot.create(:medium, name: 'Red Hat Enterprise Linux Atomic Mirror') }
|
12
|
+
let(:operatingsystem) { FactoryBot.create(:ubuntu14_10, :with_archs, :with_ptables, media: [medium]) }
|
13
|
+
let(:host) { FactoryBot.create(:host, :managed, operatingsystem: operatingsystem, build: true) }
|
14
|
+
let(:template) { FactoryBot.create(:provisioning_template, template: 'Fake kernel line <%= @kernel %> - <%= @initrd %>') }
|
13
15
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
{:"boot/Debian-8.1-x86_64"=>"/tmp/pxeboot/vmlinuz"},
|
18
|
-
{:"boot/Debian-8.1-x86_64"=>"/tmp/pxeboot/initrd.img"}
|
19
|
-
]
|
20
|
-
@host.operatingsystem.expects(:pxe_files).returns(boot_files)
|
21
|
-
ForemanBootdisk::ISOGenerator.expects(:generate).with({
|
22
|
-
:isolinux => 'Fake kernel line BOOT/DEBIAN_8_1_X86_64_VMLINUZ',
|
23
|
-
:files => [[['BOOT/DEBIAN_8_1_X86_64_VMLINUZ', '/tmp/pxeboot/vmlinuz']],
|
24
|
-
[['BOOT/DEBIAN_8_1_X86_64_INITRD_IMG', '/tmp/pxeboot/initrd.img']]] }, anything)
|
25
|
-
ForemanBootdisk::ISOGenerator.generate_full_host(@host)
|
26
|
-
end
|
16
|
+
setup do
|
17
|
+
host.expects(:provisioning_template).with(kind: :PXELinux).returns(template)
|
18
|
+
end
|
27
19
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
20
|
+
test 'generate_full_host creates with ISO-compatible file names' do
|
21
|
+
urls = host.operatingsystem.boot_file_sources(host.medium_provider)
|
22
|
+
|
23
|
+
kernel = ForemanBootdisk::ISOGenerator.iso9660_filename(
|
24
|
+
host.operatingsystem.kernel(host.medium_provider)
|
25
|
+
)
|
26
|
+
kernel_url = urls[:kernel]
|
27
|
+
|
28
|
+
initrd = ForemanBootdisk::ISOGenerator.iso9660_filename(
|
29
|
+
host.operatingsystem.initrd(host.medium_provider)
|
30
|
+
)
|
31
|
+
initrd_url = urls[:initrd]
|
32
|
+
|
33
|
+
ForemanBootdisk::ISOGenerator.expects(:generate).with({
|
34
|
+
isolinux: "Fake kernel line #{kernel} - #{initrd}",
|
35
|
+
files: { kernel => kernel_url,
|
36
|
+
initrd => initrd_url }
|
37
|
+
}, anything)
|
38
|
+
|
39
|
+
ForemanBootdisk::ISOGenerator.generate_full_host(host)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe '#generate' do
|
44
|
+
test 'generates an iso image' do
|
45
|
+
ForemanBootdisk::ISOGenerator.expects(:system).with(
|
46
|
+
regexp_matches(/genisoimage -o .*output.iso -iso-level 2 -b isolinux.bin -c boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table .*build/)
|
47
|
+
).returns(true)
|
48
|
+
ForemanBootdisk::ISOGenerator.expects(:system).with('isohybrid', anything).returns(true)
|
49
|
+
ForemanBootdisk::ISOGenerator.generate do |iso|
|
50
|
+
assert_not_nil iso
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe '#iso9660_filename' do
|
56
|
+
test 'converts path to iso9660' do
|
57
|
+
assert_equal 'BOOT/SOME_FILE_N_A_M_E123_', ForemanBootdisk::ISOGenerator.iso9660_filename('boot/some-File-n_a_m_e123Ä')
|
58
|
+
end
|
41
59
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
ForemanBootdisk::ISOGenerator.generate_full_host(@host)
|
60
|
+
test 'shortens long filenames' do
|
61
|
+
assert_equal 'BOOT/RPRISELINUXATOMIC_7_3_X86_64', ForemanBootdisk::ISOGenerator.iso9660_filename('boot/RedHatEnterpriseLinuxAtomic-7.3-x86_64')
|
62
|
+
end
|
63
|
+
end
|
47
64
|
end
|
48
65
|
end
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_bootdisk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 14.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dominic Cleal
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
12
|
-
dependencies:
|
11
|
+
date: 2018-11-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rubocop
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
description: Plugin for Foreman that creates iPXE-based boot disks to provision hosts
|
14
28
|
without the need for PXE infrastructure.
|
15
29
|
email: dcleal@redhat.com
|
@@ -30,6 +44,7 @@ files:
|
|
30
44
|
- app/controllers/foreman_bootdisk/disks_controller.rb
|
31
45
|
- app/helpers/concerns/foreman_bootdisk/hosts_helper_ext.rb
|
32
46
|
- app/lib/foreman_bootdisk/scope/bootdisk.rb
|
47
|
+
- app/lib/foreman_bootdisk/scope/full_host_bootdisk.rb
|
33
48
|
- app/models/concerns/foreman_bootdisk/compute_resources/vmware.rb
|
34
49
|
- app/models/concerns/foreman_bootdisk/host_ext.rb
|
35
50
|
- app/models/concerns/foreman_bootdisk/orchestration/compute.rb
|
@@ -97,6 +112,7 @@ files:
|
|
97
112
|
- test/unit/concerns/orchestration/compute_test.rb
|
98
113
|
- test/unit/foreman_bootdisk/renderer_test.rb
|
99
114
|
- test/unit/foreman_bootdisk/scope/bootdisk_test.rb
|
115
|
+
- test/unit/foreman_bootdisk/scope/full_host_bootdisk_test.rb
|
100
116
|
- test/unit/iso_generator_test.rb
|
101
117
|
homepage: http://github.com/theforeman/foreman_bootdisk
|
102
118
|
licenses:
|