Skip to content

Commit 0bfd657

Browse files
sbernhardShimShteinekohl
committed
Fixes #36691 - use 'connectefi scsi' by default
Co-Authored-by: Shimon Shtein <[email protected]> Co-Authored-by: Ewoud Kohl van Wijngaarden <[email protected]>
1 parent bf03a25 commit 0bfd657

File tree

5 files changed

+87
-19
lines changed

5 files changed

+87
-19
lines changed

app/views/unattended/provisioning_templates/snippet/pxegrub2_chainload.erb

+11-4
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,13 @@ insmod fat
3232
insmod chain
3333

3434
echo "VMWare hosts with QuickBoot feature enabled may not find the local ESP"
35-
echo "partition due to not initializing all the EFI devices. To workaround, upgrade"
36-
echo "to the latest grub2 (*) and uncomment "connectefi scsi" statement in the"
37-
echo "grub2_chainload template."
35+
echo "partition due to not initializing all the EFI devices. To address this,"
36+
echo "use an up-to-date grub2 (*) version and include the "connectefi scsi" statement"
37+
echo "as provided below. If you're using an older grub2 version or"
38+
echo "the "connectefi" option isn't recognized by your grub2, grub2 will print a error"
39+
echo "like 'can't find command connectefi' but the boot process will continue."
40+
echo "You can omit this by adding a (global) parameter to 'grub2-connectefi=false'."
41+
echo "Valid values of 'grub2-connectefi' parameter: false, scsi, pciroot"
3842
echo
3943
echo "Virtual or physical hosts using Software RAID for the ESP partition may try"
4044
echo "booting on the Software RAID, which will fail. To workaround, upgrade to the"
@@ -43,7 +47,10 @@ echo "the grub2_chainload template."
4347
echo
4448
echo "(*) grub2-efi-x64-2.02-122.el8 (upstream doesn't have the patches yet)"
4549
echo
46-
#connectefi scsi
50+
<%=
51+
connectefi_option = host_param('grub2-connectefi', 'scsi')
52+
"connectefi #{connectefi_option}" if connectefi_option.present? && connectefi_option != 'false'
53+
-%>
4754

4855
menuentry 'Chainload Grub2 EFI from ESP' --id local_chain_hd0 {
4956
echo "Chainloading Grub2 EFI from ESP, enabled devices for booting:"

test/unit/foreman/renderer/snapshots/ProvisioningTemplate/PXEGrub2/PXEGrub2_default_local_boot.host4dhcp.snap.txt

+8-5
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@ insmod fat
77
insmod chain
88

99
echo "VMWare hosts with QuickBoot feature enabled may not find the local ESP"
10-
echo "partition due to not initializing all the EFI devices. To workaround, upgrade"
11-
echo "to the latest grub2 (*) and uncomment "connectefi scsi" statement in the"
12-
echo "grub2_chainload template."
10+
echo "partition due to not initializing all the EFI devices. To address this,"
11+
echo "use an up-to-date grub2 (*) version and include the "connectefi scsi" statement"
12+
echo "as provided below. If you're using an older grub2 version or"
13+
echo "the "connectefi" option isn't recognized by your grub2, grub2 will print a error"
14+
echo "like 'can't find command connectefi' but the boot process will continue."
15+
echo "You can omit this by adding a (global) parameter to 'grub2-connectefi=false'."
16+
echo "Valid values of 'grub2-connectefi' parameter: false, scsi, pciroot"
1317
echo
1418
echo "Virtual or physical hosts using Software RAID for the ESP partition may try"
1519
echo "booting on the Software RAID, which will fail. To workaround, upgrade to the"
@@ -18,8 +22,7 @@ echo "the grub2_chainload template."
1822
echo
1923
echo "(*) grub2-efi-x64-2.02-122.el8 (upstream doesn't have the patches yet)"
2024
echo
21-
#connectefi scsi
22-
25+
connectefi scsi
2326
menuentry 'Chainload Grub2 EFI from ESP' --id local_chain_hd0 {
2427
echo "Chainloading Grub2 EFI from ESP, enabled devices for booting:"
2528
ls

test/unit/foreman/renderer/snapshots/ProvisioningTemplate/PXEGrub2/PXEGrub2_global_default.host4dhcp.snap.txt

+8-5
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,13 @@ insmod fat
2323
insmod chain
2424

2525
echo "VMWare hosts with QuickBoot feature enabled may not find the local ESP"
26-
echo "partition due to not initializing all the EFI devices. To workaround, upgrade"
27-
echo "to the latest grub2 (*) and uncomment "connectefi scsi" statement in the"
28-
echo "grub2_chainload template."
26+
echo "partition due to not initializing all the EFI devices. To address this,"
27+
echo "use an up-to-date grub2 (*) version and include the "connectefi scsi" statement"
28+
echo "as provided below. If you're using an older grub2 version or"
29+
echo "the "connectefi" option isn't recognized by your grub2, grub2 will print a error"
30+
echo "like 'can't find command connectefi' but the boot process will continue."
31+
echo "You can omit this by adding a (global) parameter to 'grub2-connectefi=false'."
32+
echo "Valid values of 'grub2-connectefi' parameter: false, scsi, pciroot"
2933
echo
3034
echo "Virtual or physical hosts using Software RAID for the ESP partition may try"
3135
echo "booting on the Software RAID, which will fail. To workaround, upgrade to the"
@@ -34,8 +38,7 @@ echo "the grub2_chainload template."
3438
echo
3539
echo "(*) grub2-efi-x64-2.02-122.el8 (upstream doesn't have the patches yet)"
3640
echo
37-
#connectefi scsi
38-
41+
connectefi scsi
3942
menuentry 'Chainload Grub2 EFI from ESP' --id local_chain_hd0 {
4043
echo "Chainloading Grub2 EFI from ESP, enabled devices for booting:"
4144
ls

test/unit/foreman/renderer/snapshots/ProvisioningTemplate/snippet/pxegrub2_chainload.host4dhcp.snap.txt

+8-5
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@ insmod fat
33
insmod chain
44

55
echo "VMWare hosts with QuickBoot feature enabled may not find the local ESP"
6-
echo "partition due to not initializing all the EFI devices. To workaround, upgrade"
7-
echo "to the latest grub2 (*) and uncomment "connectefi scsi" statement in the"
8-
echo "grub2_chainload template."
6+
echo "partition due to not initializing all the EFI devices. To address this,"
7+
echo "use an up-to-date grub2 (*) version and include the "connectefi scsi" statement"
8+
echo "as provided below. If you're using an older grub2 version or"
9+
echo "the "connectefi" option isn't recognized by your grub2, grub2 will print a error"
10+
echo "like 'can't find command connectefi' but the boot process will continue."
11+
echo "You can omit this by adding a (global) parameter to 'grub2-connectefi=false'."
12+
echo "Valid values of 'grub2-connectefi' parameter: false, scsi, pciroot"
913
echo
1014
echo "Virtual or physical hosts using Software RAID for the ESP partition may try"
1115
echo "booting on the Software RAID, which will fail. To workaround, upgrade to the"
@@ -14,8 +18,7 @@ echo "the grub2_chainload template."
1418
echo
1519
echo "(*) grub2-efi-x64-2.02-122.el8 (upstream doesn't have the patches yet)"
1620
echo
17-
#connectefi scsi
18-
21+
connectefi scsi
1922
menuentry 'Chainload Grub2 EFI from ESP' --id local_chain_hd0 {
2023
echo "Chainloading Grub2 EFI from ESP, enabled devices for booting:"
2124
ls
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
require 'test_helper'
2+
3+
class PxeGrub2ChainloadTest < ActiveSupport::TestCase
4+
def renderer
5+
@renderer ||= Foreman::Renderer::SafeModeRenderer
6+
end
7+
8+
def render_template(host)
9+
@snippet ||= File.read(Rails.root.join('app', 'views', 'unattended', 'provisioning_templates', 'snippet', 'pxegrub2_chainload.erb'))
10+
11+
source = OpenStruct.new(
12+
name: 'Test',
13+
content: @snippet
14+
)
15+
16+
scope = Class.new(Foreman::Renderer::Scope::Provisioning).send(
17+
:new,
18+
host: host,
19+
source: source,
20+
variables: {
21+
host: host,
22+
})
23+
24+
renderer.render(source, scope)
25+
end
26+
27+
setup do
28+
@host = FactoryBot.create(:host, :managed, :build => true)
29+
end
30+
31+
test 'should render connectefi scsi option by default' do
32+
actual = render_template(@host)
33+
34+
assert_match(/^ *connectefi scsi/, actual)
35+
end
36+
37+
test 'should not render connectefi option if parameter false' do
38+
FactoryBot.create(:host_parameter, host: @host, name: 'grub2-connectefi', value: 'false')
39+
40+
actual = render_template(@host)
41+
42+
assert_no_match(/^ *connectefi/, actual)
43+
end
44+
45+
test 'should render connectefi option if parameter present' do
46+
FactoryBot.create(:host_parameter, host: @host, name: 'grub2-connectefi', value: 'TESTOPT')
47+
48+
actual = render_template(@host)
49+
50+
assert_match(/^ *connectefi TESTOPT/, actual)
51+
end
52+
end

0 commit comments

Comments
 (0)