GRUB conf template compatibility with arm server

Determine the appropriate GRUB commands during UEFI boot
based on the node's CPU architecture.

Closes-Bug: #2050054
Change-Id: I0c5f513cdc8f4112f8dfdeb4ccaf566d3424a2ca
This commit is contained in:
cid 2024-05-30 14:41:09 +01:00
parent 2f41bf1a0d
commit e8634748a1
3 changed files with 41 additions and 7 deletions

View File

@ -347,6 +347,14 @@ def create_pxe_config(task, pxe_options, template=None, ipxe_enabled=False):
if uefi_with_grub:
pxe_config_root_tag = '(( ROOT ))'
pxe_config_disk_ident = '(( DISK_IDENTIFIER ))'
# Determine the appropriate commands based on the CPU architecture
arch = task.node.properties.get('cpu_arch', 'x86_64')
commands = {
'linux_cmd': 'linuxefi' if arch != 'aarch64' else 'linux',
'initrd_cmd': 'initrdefi' if arch != 'aarch64' else 'initrd'
}
pxe_options.update(commands)
else:
# TODO(stendulker): We should use '(' ')' as the delimiters for all our
# config files so that we do not need special handling for each of the

View File

@ -3,20 +3,20 @@ set timeout=5
set hidden_timeout_quiet=false
menuentry "deploy" {
linuxefi {{ pxe_options.deployment_aki_path }} selinux=0 troubleshoot=0 text {{ pxe_options.pxe_append_params|default("", true) }} boot_server={{pxe_options.tftp_server}}
initrdefi {{ pxe_options.deployment_ari_path }}
{{ pxe_options.linux_cmd|default('linuxefi', true) }} {{ pxe_options.deployment_aki_path }} selinux=0 troubleshoot=0 text {{ pxe_options.pxe_append_params|default("", true) }} boot_server={{pxe_options.tftp_server}}
{{ pxe_options.initrd_cmd|default('initrdefi', true) }} {{ pxe_options.deployment_ari_path }}
}
menuentry "boot_ramdisk" {
linuxefi {{ pxe_options.aki_path }} root=/dev/ram0 text {{ pxe_options.pxe_append_params|default("", true) }} {{ pxe_options.ramdisk_opts|default('', true) }}
initrdefi {{ pxe_options.ari_path }}
{{ pxe_options.linux_cmd|default('linuxefi', true) }} {{ pxe_options.aki_path }} root=/dev/ram0 text {{ pxe_options.pxe_append_params|default("", true) }} {{ pxe_options.ramdisk_opts|default('', true) }}
{{ pxe_options.initrd_cmd|default('initrdefi', true) }} {{ pxe_options.ari_path }}
}
menuentry "boot_whole_disk" {
linuxefi chain.c32 mbr:{{ DISK_IDENTIFIER }}
{{ pxe_options.linux_cmd|default('linuxefi', true) }} chain.c32 mbr:{{ DISK_IDENTIFIER }}
}
menuentry "boot_anaconda" {
linuxefi {{ pxe_options.aki_path }} text {{ pxe_options.pxe_append_params|default("", true) }} inst.ks={{ pxe_options.ks_cfg_url }} {% if pxe_options.repo_url %}inst.repo={{ pxe_options.repo_url }}{% else %}inst.stage2={{ pxe_options.stage2_url }}{% endif %}
initrdefi {{ pxe_options.ari_path }}
{{ pxe_options.linux_cmd|default('linuxefi', true) }} {{ pxe_options.aki_path }} text {{ pxe_options.pxe_append_params|default("", true) }} inst.ks={{ pxe_options.ks_cfg_url }} {% if pxe_options.repo_url %}inst.repo={{ pxe_options.repo_url }}{% else %}inst.stage2={{ pxe_options.stage2_url }}{% endif %}
{{ pxe_options.initrd_cmd|default('initrdefi', true) }} {{ pxe_options.ari_path }}
}

View File

@ -166,6 +166,32 @@ class TestPXEUtils(db_base.DbTestCase):
self.assertEqual(str(expected_template), rendered_template)
def test_pxe_config_x86_64(self):
self.node.properties['cpu_arch'] = 'x86_64'
self.node.save()
rendered_template = utils.render_template(
CONF.pxe.uefi_pxe_config_template,
{'pxe_options': self.pxe_options,
'ROOT': '{{ ROOT }}',
'DISK_IDENTIFIER': '{{ DISK_IDENTIFIER }}'})
self.assertIn('linuxefi', rendered_template)
self.assertIn('initrdefi', rendered_template)
def test_pxe_config_aarch64(self):
self.node.properties['cpu_arch'] = 'aarch64'
self.node.save()
rendered_template = utils.render_template(
CONF.pxe.uefi_pxe_config_template,
{'pxe_options': self.pxe_options,
'ROOT': '{{ ROOT }}',
'DISK_IDENTIFIER': '{{ DISK_IDENTIFIER }}'})
self.assertIn('linux', rendered_template)
self.assertIn('initrd', rendered_template)
def test_default_ipxe_boot_script(self):
rendered_template = utils.render_template(
CONF.pxe.ipxe_boot_script,