foreman_bootdisk 14.0.0 → 17.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/AUTHORS +30 -0
- data/README.md +25 -0
- data/app/controllers/foreman_bootdisk/api/v2/disks_controller.rb +5 -7
- data/app/controllers/foreman_bootdisk/api/v2/subnet_disks_controller.rb +9 -4
- data/app/controllers/foreman_bootdisk/disks_controller.rb +11 -10
- data/app/helpers/concerns/foreman_bootdisk/hosts_helper_ext.rb +14 -14
- data/app/lib/foreman_bootdisk/scope/bootdisk.rb +4 -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 +7 -10
- data/app/models/concerns/foreman_bootdisk/orchestration/compute.rb +28 -19
- data/app/models/setting/bootdisk.rb +16 -19
- data/app/services/foreman_bootdisk/iso_generator.rb +129 -52
- data/app/services/foreman_bootdisk/renderer.rb +36 -18
- data/app/views/foreman_bootdisk/generic_efi_host.erb +64 -0
- data/app/views/foreman_bootdisk/generic_static_host.erb +34 -0
- data/app/views/foreman_bootdisk/host.erb +27 -11
- data/db/seeds.d/50-bootdisk_templates.rb +15 -31
- data/lib/foreman_bootdisk/engine.rb +6 -6
- data/lib/foreman_bootdisk/version.rb +1 -1
- data/lib/tasks/bootdisk.rake +10 -6
- data/locale/action_names.rb +5 -0
- data/locale/ca/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/ca/foreman_bootdisk.po +65 -16
- data/locale/de/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/de/foreman_bootdisk.po +74 -23
- data/locale/en/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/en/foreman_bootdisk.po +58 -10
- data/locale/en_GB/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/en_GB/foreman_bootdisk.po +65 -17
- data/locale/es/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/es/foreman_bootdisk.po +82 -34
- data/locale/foreman_bootdisk.pot +124 -48
- data/locale/fr/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/fr/foreman_bootdisk.po +65 -17
- data/locale/it/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/it/foreman_bootdisk.po +63 -15
- data/locale/ja/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/ja/foreman_bootdisk.po +64 -16
- data/locale/ko/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/ko/foreman_bootdisk.po +63 -15
- data/locale/pt_BR/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/pt_BR/foreman_bootdisk.po +76 -27
- data/locale/ru/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/ru/foreman_bootdisk.po +63 -15
- data/locale/sv_SE/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/sv_SE/foreman_bootdisk.po +61 -13
- data/locale/zh_CN/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/zh_CN/foreman_bootdisk.po +79 -31
- data/locale/zh_TW/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/zh_TW/foreman_bootdisk.po +63 -15
- data/release-gem +84 -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 +23 -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 +16 -7
- metadata +65 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc43113465fd89f890f9606fb04af3e948b96ac1bd6c1943211a452e38c4cb2a
|
4
|
+
data.tar.gz: 9db1069085f706df776576fc0df25f49a7d09ae71555ea15397d57656ddd0da5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 115bddba362f7c53b78d06ca78a1f120babae76cc2f922447cd0e05b1f322f189e30b186e6cb0718b7d9a24bfca67bf2287283fd9495eba4193a9b6bb560ec29
|
7
|
+
data.tar.gz: 1cd764fdc0a939d45934070d6b34e2619870c8c206afd4915cae93f68f7553cfcc9b18d3c04770aba9f4b6f45d62bbd779563798b7175595ee8c2b991f03b660
|
data/AUTHORS
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
Adam Ruzicka
|
2
|
+
Bernhard Suttner
|
3
|
+
Bryan Kearney
|
4
|
+
crito
|
5
|
+
Damon Maria
|
6
|
+
Dominic Cleal
|
7
|
+
Greg Sutcliffe
|
8
|
+
Ido Kanner
|
9
|
+
Jon Fautley
|
10
|
+
Justin Sherrill
|
11
|
+
Leos Stejskal
|
12
|
+
Lukas Zapletal
|
13
|
+
Lukáš Zapletal
|
14
|
+
Marek Hulan
|
15
|
+
Marek Hulán
|
16
|
+
Martin Bačovský
|
17
|
+
Michael Hofer
|
18
|
+
Michael Moll
|
19
|
+
Ohad Levy
|
20
|
+
Ondrej Prazak
|
21
|
+
Ondřej Ezr
|
22
|
+
Ondřej Pražák
|
23
|
+
Robert Antoni Buj Gelonch
|
24
|
+
Rohan21Lobo
|
25
|
+
Ronald van Zantvoort
|
26
|
+
Sam Kottler
|
27
|
+
Sean O'Keeffe
|
28
|
+
Stephen Benjamin
|
29
|
+
Swapnil Abnave
|
30
|
+
Timo Goebel
|
data/README.md
CHANGED
@@ -50,6 +50,10 @@ gPXE images are unsupported due to lack of initrd support.
|
|
50
50
|
| >= 1.19 | ~> 13.0 |
|
51
51
|
| >= 1.20 | ~> 14.0 |
|
52
52
|
| >= 1.21 | ~> 15.0 |
|
53
|
+
| >= 1.23 | ~> 16.0 |
|
54
|
+
| >= 1.24 | ~> 16.1 |
|
55
|
+
| >= 2.0 | ~> 16.1 |
|
56
|
+
| >= 2.1 | ~> 17.0 |
|
53
57
|
|
54
58
|
# Usage
|
55
59
|
|
@@ -119,6 +123,7 @@ TFTP settings are needed.
|
|
119
123
|
<th>DHCP reservation</th>
|
120
124
|
<th>Pre-register host</th>
|
121
125
|
<th>OS-specific</th>
|
126
|
+
<th>EFI supported</th>
|
122
127
|
</tr>
|
123
128
|
<tr>
|
124
129
|
<td>Per-host image</td>
|
@@ -127,6 +132,7 @@ TFTP settings are needed.
|
|
127
132
|
<td>No</td>
|
128
133
|
<td>Yes</td>
|
129
134
|
<td>No</td>
|
135
|
+
<td>No</td>
|
130
136
|
</tr>
|
131
137
|
<tr>
|
132
138
|
<td>Full host image</td>
|
@@ -135,6 +141,7 @@ TFTP settings are needed.
|
|
135
141
|
<td>No</td>
|
136
142
|
<td>Yes</td>
|
137
143
|
<td>Yes</td>
|
144
|
+
<td>Yes</td>
|
138
145
|
</tr>
|
139
146
|
<tr>
|
140
147
|
<td>Generic image</td>
|
@@ -143,6 +150,7 @@ TFTP settings are needed.
|
|
143
150
|
<td>No</td>
|
144
151
|
<td>Yes</td>
|
145
152
|
<td>No</td>
|
153
|
+
<td>No</td>
|
146
154
|
</tr>
|
147
155
|
<tr>
|
148
156
|
<td>Subnet image</td>
|
@@ -151,6 +159,7 @@ TFTP settings are needed.
|
|
151
159
|
<td>No</td>
|
152
160
|
<td>Yes</td>
|
153
161
|
<td>No</td>
|
162
|
+
<td>Yes</td>
|
154
163
|
</tr>
|
155
164
|
</table>
|
156
165
|
|
@@ -236,6 +245,22 @@ To generate from the command line on the Foreman server:
|
|
236
245
|
Set `OUTPUT=/path` to change the output destination path (directory or file).
|
237
246
|
It must be writable by the 'foreman' user.
|
238
247
|
|
248
|
+
### Generic static image
|
249
|
+
|
250
|
+
This is generic image type which asks for network credentials instead of doing
|
251
|
+
DHCP request. Tokens must be turned off in order to find the host by MAC
|
252
|
+
address. To do that, set Token duration to 0 in Administer - Settings.
|
253
|
+
|
254
|
+
- Network interface name
|
255
|
+
- IP Address
|
256
|
+
- Netmask
|
257
|
+
- Gateway
|
258
|
+
- DNS
|
259
|
+
|
260
|
+
To use generic static host image, set "Generic image template" to "Bootdisk
|
261
|
+
iPXE - host template" in Administer - Settings - Boot disk. Only one template
|
262
|
+
can be used at one time across all hosts.
|
263
|
+
|
239
264
|
### Subnet images
|
240
265
|
|
241
266
|
Subnet images are similar to generic images, but chain-loading is done via the
|
@@ -21,9 +21,10 @@ module ForemanBootdisk
|
|
21
21
|
|
22
22
|
api :GET, '/generic', N_('Download generic image')
|
23
23
|
def generic
|
24
|
+
# EFI not supported for iPXE generic bootdisk
|
24
25
|
tmpl = ForemanBootdisk::Renderer.new.generic_template_render
|
25
26
|
ForemanBootdisk::ISOGenerator.generate(ipxe: tmpl) do |iso|
|
26
|
-
|
27
|
+
send_file(iso, filename: "bootdisk_#{URI.parse(Setting[:foreman_url]).host}.iso")
|
27
28
|
end
|
28
29
|
end
|
29
30
|
|
@@ -34,22 +35,19 @@ module ForemanBootdisk
|
|
34
35
|
host = @disk
|
35
36
|
if params[:full]
|
36
37
|
ForemanBootdisk::ISOGenerator.generate_full_host(host) do |iso|
|
37
|
-
|
38
|
+
send_file(iso, filename: "#{host.name}#{ForemanBootdisk::ISOGenerator.token_expiry(host)}.iso")
|
38
39
|
end
|
39
40
|
else
|
41
|
+
# EFI not supported for iPXE host bootdisk
|
40
42
|
tmpl = host.bootdisk_template_render
|
41
43
|
ForemanBootdisk::ISOGenerator.generate(ipxe: tmpl) do |iso|
|
42
|
-
|
44
|
+
send_file(iso, filename: "#{host.name}.iso")
|
43
45
|
end
|
44
46
|
end
|
45
47
|
end
|
46
48
|
|
47
49
|
private
|
48
50
|
|
49
|
-
def read_file(filename)
|
50
|
-
File.read(filename)
|
51
|
-
end
|
52
|
-
|
53
51
|
def resource_scope
|
54
52
|
Host::Managed.authorized('view_hosts')
|
55
53
|
end
|
@@ -25,10 +25,15 @@ module ForemanBootdisk
|
|
25
25
|
def subnet
|
26
26
|
subnet = @subnet_disk
|
27
27
|
subnet.tftp || raise(::Foreman::Exception.new(N_('TFTP feature not enabled for subnet %s'), subnet.name))
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
tmpl_bios = ForemanBootdisk::Renderer.new.generic_template_render(subnet)
|
29
|
+
tmpl_efi = nil
|
30
|
+
if subnet.httpboot
|
31
|
+
tmpl_efi = ForemanBootdisk::Renderer.new.generic_efi_template_render(subnet)
|
32
|
+
else
|
33
|
+
ForemanBootdisk.logger.warn('HTTPBOOT feature is not enabled for subnet %s, UEFI may not be available for bootdisk' % subnet.name)
|
34
|
+
end
|
35
|
+
ForemanBootdisk::ISOGenerator.generate(ipxe: tmpl_bios, grub: tmpl_efi) do |temp_iso_filename|
|
36
|
+
send_file(temp_iso_filename, filename: subnet.name)
|
32
37
|
end
|
33
38
|
end
|
34
39
|
|
@@ -12,6 +12,7 @@ module ForemanBootdisk
|
|
12
12
|
|
13
13
|
def generic
|
14
14
|
begin
|
15
|
+
# EFI not supported for iPXE generic bootdisk
|
15
16
|
tmpl = ForemanBootdisk::Renderer.new.generic_template_render
|
16
17
|
rescue StandardError => e
|
17
18
|
error_rendering(e)
|
@@ -20,13 +21,14 @@ module ForemanBootdisk
|
|
20
21
|
end
|
21
22
|
|
22
23
|
ForemanBootdisk::ISOGenerator.generate(ipxe: tmpl) do |iso|
|
23
|
-
|
24
|
+
send_file(iso, filename: "bootdisk_#{URI.parse(Setting[:foreman_url]).host}.iso")
|
24
25
|
end
|
25
26
|
end
|
26
27
|
|
27
28
|
def host
|
28
29
|
host = @disk
|
29
30
|
begin
|
31
|
+
# EFI not supported for iPXE host bootdisk
|
30
32
|
tmpl = host.bootdisk_template_render
|
31
33
|
rescue StandardError => e
|
32
34
|
error_rendering(e)
|
@@ -35,14 +37,14 @@ module ForemanBootdisk
|
|
35
37
|
end
|
36
38
|
|
37
39
|
ForemanBootdisk::ISOGenerator.generate(ipxe: tmpl) do |iso|
|
38
|
-
|
40
|
+
send_file(iso, filename: "#{host.name}.iso")
|
39
41
|
end
|
40
42
|
end
|
41
43
|
|
42
44
|
def full_host
|
43
45
|
host = @disk
|
44
46
|
ForemanBootdisk::ISOGenerator.generate_full_host(host) do |iso|
|
45
|
-
|
47
|
+
send_file(iso, filename: "#{host.name}#{ForemanBootdisk::ISOGenerator.token_expiry(host)}.iso")
|
46
48
|
end
|
47
49
|
end
|
48
50
|
|
@@ -51,15 +53,18 @@ module ForemanBootdisk
|
|
51
53
|
begin
|
52
54
|
subnet = host.try(:subnet) || raise(::Foreman::Exception.new(N_('Subnet is not assigned to the host %s'), host.name))
|
53
55
|
subnet.tftp || raise(::Foreman::Exception.new(N_('TFTP feature not enabled for subnet %s'), subnet.name))
|
54
|
-
|
56
|
+
subnet.httpboot || ForemanBootdisk.logger.warn('HTTPBOOT feature is not enabled for subnet %s, UEFI may not be available for bootdisk' % subnet.name)
|
57
|
+
|
58
|
+
tmpl_bios = ForemanBootdisk::Renderer.new.generic_template_render(subnet)
|
59
|
+
tmpl_efi = ForemanBootdisk::Renderer.new.generic_efi_template_render(subnet)
|
55
60
|
rescue StandardError => e
|
56
61
|
error_rendering(e)
|
57
62
|
redirect_back(fallback_location: '/')
|
58
63
|
return
|
59
64
|
end
|
60
65
|
|
61
|
-
ForemanBootdisk::ISOGenerator.generate(ipxe:
|
62
|
-
|
66
|
+
ForemanBootdisk::ISOGenerator.generate(ipxe: tmpl_bios, grub: tmpl_efi) do |iso|
|
67
|
+
send_file(iso, filename: "bootdisk_subnet_#{subnet.name}.iso")
|
63
68
|
end
|
64
69
|
end
|
65
70
|
|
@@ -67,10 +72,6 @@ module ForemanBootdisk
|
|
67
72
|
|
68
73
|
private
|
69
74
|
|
70
|
-
def read_file(filename)
|
71
|
-
File.read(filename)
|
72
|
-
end
|
73
|
-
|
74
75
|
def resource_scope(_controller = controller_name)
|
75
76
|
Host::Managed.authorized(:view_hosts)
|
76
77
|
end
|
@@ -2,27 +2,27 @@
|
|
2
2
|
|
3
3
|
module ForemanBootdisk
|
4
4
|
module HostsHelperExt
|
5
|
-
def host_title_actions(
|
6
|
-
if
|
5
|
+
def host_title_actions(host)
|
6
|
+
if host.bootdisk_downloadable?
|
7
7
|
title_actions(
|
8
8
|
button_group(
|
9
9
|
select_action_button(
|
10
10
|
_('Boot disk'), { class: 'btn btn-group' },
|
11
11
|
display_bootdisk_link_if_authorized(
|
12
|
-
_("Host '%s' image") %
|
12
|
+
_("Host '%s' image") % host.name.split('.')[0],
|
13
13
|
{
|
14
14
|
controller: 'foreman_bootdisk/disks',
|
15
15
|
action: 'host',
|
16
|
-
id:
|
16
|
+
id: host
|
17
17
|
},
|
18
18
|
class: 'la'
|
19
19
|
),
|
20
20
|
display_bootdisk_link_if_authorized(
|
21
|
-
_("Full host '%s' image") %
|
21
|
+
_("Full host '%s' image") % host.name.split('.')[0],
|
22
22
|
{
|
23
23
|
controller: 'foreman_bootdisk/disks',
|
24
24
|
action: 'full_host',
|
25
|
-
id:
|
25
|
+
id: host
|
26
26
|
},
|
27
27
|
class: 'la'
|
28
28
|
),
|
@@ -35,7 +35,7 @@ module ForemanBootdisk
|
|
35
35
|
},
|
36
36
|
class: 'la'
|
37
37
|
),
|
38
|
-
display_bootdisk_for_subnet,
|
38
|
+
display_bootdisk_for_subnet(host),
|
39
39
|
content_tag(:li, '', class: 'divider'),
|
40
40
|
display_bootdisk_link_if_authorized(
|
41
41
|
_('Help'), {
|
@@ -48,29 +48,29 @@ module ForemanBootdisk
|
|
48
48
|
)
|
49
49
|
)
|
50
50
|
else
|
51
|
-
bootdisk_button_disabled
|
51
|
+
bootdisk_button_disabled(host)
|
52
52
|
end
|
53
53
|
|
54
54
|
super
|
55
55
|
end
|
56
56
|
|
57
|
-
def bootdisk_button_disabled
|
57
|
+
def bootdisk_button_disabled(host)
|
58
58
|
title_actions(
|
59
59
|
button_group(
|
60
60
|
link_to(_('Boot disk'), '#', disabled: true, class: 'btn btn-default',
|
61
|
-
title: _('Boot disk download not available for %s architecture') %
|
61
|
+
title: _('Boot disk download not available for %s architecture') % host.architecture.name)
|
62
62
|
)
|
63
63
|
)
|
64
64
|
end
|
65
65
|
|
66
66
|
# need to wrap this one in a test for template proxy presence
|
67
|
-
def display_bootdisk_for_subnet
|
68
|
-
if (proxy =
|
67
|
+
def display_bootdisk_for_subnet(host)
|
68
|
+
if (proxy = host.try(:subnet).try(:tftp) || host.try(:subnet).try(:httpboot)) && proxy.has_feature?('Templates')
|
69
69
|
display_bootdisk_link_if_authorized(
|
70
|
-
_("Subnet '%s' generic image") %
|
70
|
+
_("Subnet '%s' generic image") % host.subnet.name, {
|
71
71
|
controller: 'foreman_bootdisk/disks',
|
72
72
|
action: 'subnet',
|
73
|
-
id:
|
73
|
+
id: host
|
74
74
|
},
|
75
75
|
class: 'la'
|
76
76
|
)
|
@@ -6,7 +6,6 @@ module ForemanBootdisk
|
|
6
6
|
def bootdisk_chain_url(mac = host.try(:mac), action = 'iPXE')
|
7
7
|
url = foreman_url(action)
|
8
8
|
u = URI.parse(url)
|
9
|
-
ForemanBootdisk.logger.warn("Foreman or proxy is configured with HTTPS, probably not supported by iPXE: #{u}") if u.scheme == 'https'
|
10
9
|
new_query_data = URI.decode_www_form(u.query || '') << ['mac', mac || '']
|
11
10
|
new_querystring = URI.encode_www_form(new_query_data)
|
12
11
|
u.query = nil
|
@@ -18,6 +17,10 @@ module ForemanBootdisk
|
|
18
17
|
def bootdisk_raise(*args)
|
19
18
|
raise ::Foreman::Exception.new(*args)
|
20
19
|
end
|
20
|
+
|
21
|
+
def template_name
|
22
|
+
"Foreman Bootdisk"
|
23
|
+
end
|
21
24
|
end
|
22
25
|
end
|
23
26
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ForemanBootdisk
|
4
|
+
module Scope
|
5
|
+
class FullHostBootdiskEfi < Bootdisk
|
6
|
+
def kernel(medium_provider)
|
7
|
+
'/' + ForemanBootdisk::ISOGenerator.iso9660_filename(super)
|
8
|
+
end
|
9
|
+
|
10
|
+
def initrd(medium_provider)
|
11
|
+
'/' + ForemanBootdisk::ISOGenerator.iso9660_filename(super)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -36,12 +36,21 @@ module ForemanBootdisk
|
|
36
36
|
'instance_uuid' => vm_uuid,
|
37
37
|
'iso' => "foreman_isos/#{iso}",
|
38
38
|
'datastore' => bootdisk_datastore(vm_uuid),
|
39
|
-
'start_connected' =>
|
39
|
+
'start_connected' => true,
|
40
40
|
'connected' => true,
|
41
41
|
'allow_guest_control' => true
|
42
42
|
}
|
43
43
|
client.vm_reconfig_cdrom options
|
44
44
|
end
|
45
|
+
|
46
|
+
def iso_detach(vm_uuid)
|
47
|
+
options = {
|
48
|
+
'instance_uuid' => vm_uuid,
|
49
|
+
'start_connected' => false,
|
50
|
+
'connected' => false,
|
51
|
+
}
|
52
|
+
client.vm_reconfig_cdrom options
|
53
|
+
end
|
45
54
|
end
|
46
55
|
end
|
47
56
|
end
|
@@ -5,14 +5,11 @@ require 'uri'
|
|
5
5
|
module ForemanBootdisk
|
6
6
|
module HostExt
|
7
7
|
def bootdisk_template
|
8
|
-
template = ProvisioningTemplate.unscoped.find_by(
|
9
|
-
name: Setting[:bootdisk_host_template]
|
10
|
-
)
|
8
|
+
template = ProvisioningTemplate.unscoped.find_by(name: Setting[:bootdisk_host_template])
|
11
9
|
unless template
|
12
|
-
raise ::Foreman::Exception.new(
|
13
|
-
N_('Unable to find template specified by %s setting'), 'bootdisk_host_template'
|
14
|
-
)
|
10
|
+
raise ::Foreman::Exception.new(N_('Unable to find template specified by %s setting'), 'bootdisk_host_template')
|
15
11
|
end
|
12
|
+
|
16
13
|
template
|
17
14
|
end
|
18
15
|
|
@@ -36,12 +33,12 @@ module ForemanBootdisk
|
|
36
33
|
/i.86|x86[_-]64/ =~ architecture.name
|
37
34
|
end
|
38
35
|
|
39
|
-
def validate_media?
|
40
|
-
super || (managed && bootdisk_build? && build?)
|
41
|
-
end
|
42
|
-
|
43
36
|
def can_be_built?
|
44
37
|
super || (managed? && SETTINGS[:unattended] && bootdisk_build? && !build?)
|
45
38
|
end
|
46
39
|
end
|
47
40
|
end
|
41
|
+
|
42
|
+
class Host::Managed::Jail < Safemode::Jail
|
43
|
+
allow :bootdisk_build?
|
44
|
+
end
|
@@ -9,7 +9,6 @@ module ForemanBootdisk
|
|
9
9
|
|
10
10
|
included do
|
11
11
|
after_validation :queue_bootdisk_compute
|
12
|
-
after_build :rebuild_with_bootdisk
|
13
12
|
end
|
14
13
|
|
15
14
|
def bootdisk_isodir
|
@@ -21,15 +20,25 @@ module ForemanBootdisk
|
|
21
20
|
end
|
22
21
|
|
23
22
|
def queue_bootdisk_compute
|
24
|
-
return unless compute? && errors.empty?
|
23
|
+
return unless compute? && errors.empty?
|
25
24
|
return unless provision_method == 'bootdisk'
|
26
25
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
26
|
+
# We want to add our queue jobs only if really necessary:
|
27
|
+
# - in case of starting to create a new host
|
28
|
+
# - in case of a rebuild
|
29
|
+
if (old.nil? || !old.build?) && build?
|
30
|
+
queue.create(name: _('Generating ISO image for %s') % self, priority: 5,
|
31
|
+
action: [self, :setGenerateIsoImage])
|
32
|
+
queue.create(name: _('Upload ISO image to datastore for %s') % self, priority: 6,
|
33
|
+
action: [self, :setIsoImage])
|
34
|
+
queue.create(name: _('Attach ISO image to CDROM drive for %s') % self, priority: 1001,
|
35
|
+
action: [self, :setAttachIsoImage])
|
36
|
+
# Detach ISO image when host sends 'built' HTTP POST request
|
37
|
+
elsif old&.build? && !build?
|
38
|
+
queue.create(name: _('Detach ISO image from CDROM drive for %s') % self, priority: 52,
|
39
|
+
action: [self, :setDetachIsoImage])
|
40
|
+
end
|
41
|
+
true
|
33
42
|
end
|
34
43
|
|
35
44
|
def bootdisk_generate_iso_image
|
@@ -46,6 +55,10 @@ module ForemanBootdisk
|
|
46
55
|
compute_resource.iso_attach(File.basename(bootdisk_isofile), uuid)
|
47
56
|
end
|
48
57
|
|
58
|
+
def bootdisk_detach_iso
|
59
|
+
compute_resource.iso_detach(uuid)
|
60
|
+
end
|
61
|
+
|
49
62
|
def setGenerateIsoImage
|
50
63
|
logger.info format('Generating ISO image for %s', name)
|
51
64
|
bootdisk_generate_iso_image
|
@@ -73,18 +86,14 @@ module ForemanBootdisk
|
|
73
86
|
|
74
87
|
def delAttachIsoImage; end
|
75
88
|
|
76
|
-
def
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
bootdisk_upload_iso
|
82
|
-
bootdisk_attach_iso
|
83
|
-
rescue StandardError => e
|
84
|
-
Foreman::Logging.exception "Failed to rebuild Bootdisk image for #{name}", e, level: :error
|
85
|
-
return false
|
86
|
-
end
|
89
|
+
def setDetachIsoImage
|
90
|
+
logger.info format('Detaching ISO image from CDROM drive for %s', name)
|
91
|
+
bootdisk_detach_iso
|
92
|
+
rescue StandardError => e
|
93
|
+
failure format(_('Failed to detach ISO image from CDROM drive of instance %{name}: %{message}'), name: name, message: e.message), e
|
87
94
|
end
|
95
|
+
|
96
|
+
def delDetachIsoImage; end
|
88
97
|
end
|
89
98
|
end
|
90
99
|
end
|