diff --git a/ironic/common/pxe_utils.py b/ironic/common/pxe_utils.py index e77191b685..1062523321 100644 --- a/ironic/common/pxe_utils.py +++ b/ironic/common/pxe_utils.py @@ -720,12 +720,15 @@ def build_instance_pxe_options(task, pxe_info, ipxe_enabled=False): return pxe_opts -def build_extra_pxe_options(): +def build_extra_pxe_options(ramdisk_params=None): # Enable debug in IPA according to CONF.debug if it was not # specified yet pxe_append_params = CONF.pxe.pxe_append_params if CONF.debug and 'ipa-debug' not in pxe_append_params: pxe_append_params += ' ipa-debug=1' + if ramdisk_params: + pxe_append_params += ' ' + ' '.join('%s=%s' % tpl + for tpl in ramdisk_params.items()) return {'pxe_append_params': pxe_append_params, 'tftp_server': CONF.pxe.tftp_server, @@ -733,7 +736,7 @@ def build_extra_pxe_options(): def build_pxe_config_options(task, pxe_info, service=False, - ipxe_enabled=False): + ipxe_enabled=False, ramdisk_params=None): """Build the PXE config options for a node This method builds the PXE boot options for a node, @@ -749,6 +752,8 @@ def build_pxe_config_options(task, pxe_info, service=False, to PXE options. :param ipxe_enabled: Default false boolean to indicate if ipxe is in use by the caller. + :param ramdisk_params: the parameters to be passed to the ramdisk. + as kernel command-line arguments. :returns: A dictionary of pxe options to be used in the pxe bootfile template. """ @@ -771,7 +776,7 @@ def build_pxe_config_options(task, pxe_info, service=False, pxe_options.update(build_instance_pxe_options(task, pxe_info, ipxe_enabled=ipxe_enabled)) - pxe_options.update(build_extra_pxe_options()) + pxe_options.update(build_extra_pxe_options(ramdisk_params)) return pxe_options diff --git a/ironic/drivers/modules/agent_config.template b/ironic/drivers/modules/agent_config.template index d4828919cb..bf9f5f4b49 100644 --- a/ironic/drivers/modules/agent_config.template +++ b/ironic/drivers/modules/agent_config.template @@ -2,7 +2,7 @@ default deploy label deploy kernel {{ pxe_options.deployment_aki_path }} -append initrd={{ pxe_options.deployment_ari_path }} text {{ pxe_options.pxe_append_params }} ipa-api-url={{ pxe_options['ipa-api-url'] }} +append initrd={{ pxe_options.deployment_ari_path }} text {{ pxe_options.pxe_append_params }} label boot_partition kernel {{ pxe_options.aki_path }} diff --git a/ironic/drivers/modules/ipxe.py b/ironic/drivers/modules/ipxe.py index 0495e87369..49ac313481 100644 --- a/ironic/drivers/modules/ipxe.py +++ b/ironic/drivers/modules/ipxe.py @@ -158,9 +158,8 @@ class iPXEBoot(pxe_base.PXEBaseMixin, base.BootInterface): pxe_utils.get_instance_image_info(task, ipxe_enabled=True)) boot_mode_utils.sync_boot_mode(task) - pxe_options = pxe_utils.build_pxe_config_options(task, pxe_info, - ipxe_enabled=True) - pxe_options.update(ramdisk_params) + pxe_options = pxe_utils.build_pxe_config_options( + task, pxe_info, ipxe_enabled=True, ramdisk_params=ramdisk_params) pxe_config_template = deploy_utils.get_pxe_config_template(node) @@ -187,6 +186,10 @@ class iPXEBoot(pxe_base.PXEBaseMixin, base.BootInterface): if pxe_info: pxe_utils.cache_ramdisk_kernel(task, pxe_info, ipxe_enabled=True) + LOG.debug('Ramdisk iPXE boot for node %(node)s has been prepared ' + 'with kernel params %(params)s', + {'node': node.uuid, 'params': pxe_options}) + @METRICS.timer('iPXEBoot.prepare_instance') def prepare_instance(self, task): """Prepares the boot of instance. diff --git a/ironic/drivers/modules/ipxe_config.template b/ironic/drivers/modules/ipxe_config.template index 3fdbb2d7b6..84b01d1047 100644 --- a/ironic/drivers/modules/ipxe_config.template +++ b/ironic/drivers/modules/ipxe_config.template @@ -7,7 +7,7 @@ goto deploy :deploy imgfree -kernel {% if pxe_options.ipxe_timeout > 0 %}--timeout {{ pxe_options.ipxe_timeout }} {% endif %}{{ pxe_options.deployment_aki_path }} selinux=0 troubleshoot=0 text {{ pxe_options.pxe_append_params|default("", true) }} BOOTIF=${mac} ipa-api-url={{ pxe_options['ipa-api-url'] }} initrd={{ pxe_options.initrd_filename|default("deploy_ramdisk", true) }} || goto retry +kernel {% if pxe_options.ipxe_timeout > 0 %}--timeout {{ pxe_options.ipxe_timeout }} {% endif %}{{ pxe_options.deployment_aki_path }} selinux=0 troubleshoot=0 text {{ pxe_options.pxe_append_params|default("", true) }} BOOTIF=${mac} initrd={{ pxe_options.initrd_filename|default("deploy_ramdisk", true) }} || goto retry initrd {% if pxe_options.ipxe_timeout > 0 %}--timeout {{ pxe_options.ipxe_timeout }} {% endif %}{{ pxe_options.deployment_ari_path }} || goto retry boot diff --git a/ironic/drivers/modules/pxe.py b/ironic/drivers/modules/pxe.py index 9fd7d78f79..a73f18abfe 100644 --- a/ironic/drivers/modules/pxe.py +++ b/ironic/drivers/modules/pxe.py @@ -164,8 +164,8 @@ class PXEBoot(pxe_base.PXEBaseMixin, base.BootInterface): boot_mode_utils.sync_boot_mode(task) pxe_options = pxe_utils.build_pxe_config_options( - task, pxe_info, ipxe_enabled=ipxe_enabled) - pxe_options.update(ramdisk_params) + task, pxe_info, ipxe_enabled=ipxe_enabled, + ramdisk_params=ramdisk_params) pxe_config_template = deploy_utils.get_pxe_config_template(node) @@ -186,6 +186,9 @@ class PXEBoot(pxe_base.PXEBaseMixin, base.BootInterface): if pxe_info: pxe_utils.cache_ramdisk_kernel(task, pxe_info, ipxe_enabled=CONF.pxe.ipxe_enabled) + LOG.debug('Ramdisk PXE boot for node %(node)s has been prepared ' + 'with kernel params %(params)s', + {'node': node.uuid, 'params': pxe_options}) @METRICS.timer('PXEBoot.prepare_instance') def prepare_instance(self, task): diff --git a/ironic/drivers/modules/pxe_config.template b/ironic/drivers/modules/pxe_config.template index 701733b39f..e60be13928 100644 --- a/ironic/drivers/modules/pxe_config.template +++ b/ironic/drivers/modules/pxe_config.template @@ -2,7 +2,7 @@ default deploy label deploy kernel {{ pxe_options.deployment_aki_path }} -append initrd={{ pxe_options.deployment_ari_path }} selinux=0 troubleshoot=0 text {{ pxe_options.pxe_append_params|default("", true) }} ipa-api-url={{ pxe_options['ipa-api-url'] }} +append initrd={{ pxe_options.deployment_ari_path }} selinux=0 troubleshoot=0 text {{ pxe_options.pxe_append_params|default("", true) }} ipappend 2 diff --git a/ironic/drivers/modules/pxe_grub_config.template b/ironic/drivers/modules/pxe_grub_config.template index e73cd4607a..d33cbb8cd7 100644 --- a/ironic/drivers/modules/pxe_grub_config.template +++ b/ironic/drivers/modules/pxe_grub_config.template @@ -3,7 +3,7 @@ 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}} ipa-api-url={{ pxe_options['ipa-api-url'] }} + 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 }} } diff --git a/ironic/tests/unit/common/test_pxe_utils.py b/ironic/tests/unit/common/test_pxe_utils.py index c84ac21042..778792d7c5 100644 --- a/ironic/tests/unit/common/test_pxe_utils.py +++ b/ironic/tests/unit/common/test_pxe_utils.py @@ -1164,7 +1164,8 @@ class PXEInterfacesTestCase(db_base.DbTestCase): @mock.patch('ironic.common.utils.render_template', autospec=True) def _test_build_pxe_config_options_pxe(self, render_mock, whle_dsk_img=False, - debug=False, mode='deploy'): + debug=False, mode='deploy', + ramdisk_params=None): self.config(debug=debug) self.config(pxe_append_params='test_param', group='pxe') # NOTE: right '/' should be removed from url string @@ -1216,6 +1217,9 @@ class PXEInterfacesTestCase(db_base.DbTestCase): expected_pxe_params = 'test_param' if debug: expected_pxe_params += ' ipa-debug=1' + if ramdisk_params: + expected_pxe_params += ' ' + ' '.join( + '%s=%s' % tpl for tpl in ramdisk_params.items()) expected_options = { 'deployment_ari_path': pxe_ramdisk, @@ -1233,7 +1237,8 @@ class PXEInterfacesTestCase(db_base.DbTestCase): with task_manager.acquire(self.context, self.node.uuid, shared=True) as task: - options = pxe_utils.build_pxe_config_options(task, image_info) + options = pxe_utils.build_pxe_config_options( + task, image_info, ramdisk_params=ramdisk_params) self.assertEqual(expected_options, options) def test_build_pxe_config_options_pxe(self): @@ -1263,6 +1268,10 @@ class PXEInterfacesTestCase(db_base.DbTestCase): self.node.save() self._test_build_pxe_config_options_pxe(whle_dsk_img=False) + def test_build_pxe_config_options_ramdisk_params(self): + self._test_build_pxe_config_options_pxe(whle_dsk_img=True, + ramdisk_params={'foo': 'bar'}) + def test_build_pxe_config_options_pxe_no_kernel_no_ramdisk(self): del self.node.driver_internal_info['is_whole_disk_image'] self.node.save() diff --git a/ironic/tests/unit/drivers/ipxe_config.template b/ironic/tests/unit/drivers/ipxe_config.template index e3e7c443f9..472ed9cf0c 100644 --- a/ironic/tests/unit/drivers/ipxe_config.template +++ b/ironic/tests/unit/drivers/ipxe_config.template @@ -7,7 +7,7 @@ goto deploy :deploy imgfree -kernel http://1.2.3.4:1234/deploy_kernel selinux=0 troubleshoot=0 text test_param BOOTIF=${mac} ipa-api-url=http://192.168.122.184:6385 initrd=deploy_ramdisk || goto retry +kernel http://1.2.3.4:1234/deploy_kernel selinux=0 troubleshoot=0 text test_param BOOTIF=${mac} initrd=deploy_ramdisk || goto retry initrd http://1.2.3.4:1234/deploy_ramdisk || goto retry boot diff --git a/ironic/tests/unit/drivers/ipxe_config_boot_from_volume_extra_volume.template b/ironic/tests/unit/drivers/ipxe_config_boot_from_volume_extra_volume.template index ce86ceb73a..5e64e53c5b 100644 --- a/ironic/tests/unit/drivers/ipxe_config_boot_from_volume_extra_volume.template +++ b/ironic/tests/unit/drivers/ipxe_config_boot_from_volume_extra_volume.template @@ -7,7 +7,7 @@ goto deploy :deploy imgfree -kernel http://1.2.3.4:1234/deploy_kernel selinux=0 troubleshoot=0 text test_param BOOTIF=${mac} ipa-api-url=http://192.168.122.184:6385 initrd=deploy_ramdisk || goto retry +kernel http://1.2.3.4:1234/deploy_kernel selinux=0 troubleshoot=0 text test_param BOOTIF=${mac} initrd=deploy_ramdisk || goto retry initrd http://1.2.3.4:1234/deploy_ramdisk || goto retry boot diff --git a/ironic/tests/unit/drivers/ipxe_config_boot_from_volume_no_extra_volumes.template b/ironic/tests/unit/drivers/ipxe_config_boot_from_volume_no_extra_volumes.template index f848646082..30f3688900 100644 --- a/ironic/tests/unit/drivers/ipxe_config_boot_from_volume_no_extra_volumes.template +++ b/ironic/tests/unit/drivers/ipxe_config_boot_from_volume_no_extra_volumes.template @@ -7,7 +7,7 @@ goto deploy :deploy imgfree -kernel http://1.2.3.4:1234/deploy_kernel selinux=0 troubleshoot=0 text test_param BOOTIF=${mac} ipa-api-url=http://192.168.122.184:6385 initrd=deploy_ramdisk || goto retry +kernel http://1.2.3.4:1234/deploy_kernel selinux=0 troubleshoot=0 text test_param BOOTIF=${mac} initrd=deploy_ramdisk || goto retry initrd http://1.2.3.4:1234/deploy_ramdisk || goto retry boot diff --git a/ironic/tests/unit/drivers/ipxe_config_timeout.template b/ironic/tests/unit/drivers/ipxe_config_timeout.template index 63497be691..0f6d8bfd3a 100644 --- a/ironic/tests/unit/drivers/ipxe_config_timeout.template +++ b/ironic/tests/unit/drivers/ipxe_config_timeout.template @@ -7,7 +7,7 @@ goto deploy :deploy imgfree -kernel --timeout 120 http://1.2.3.4:1234/deploy_kernel selinux=0 troubleshoot=0 text test_param BOOTIF=${mac} ipa-api-url=http://192.168.122.184:6385 initrd=deploy_ramdisk || goto retry +kernel --timeout 120 http://1.2.3.4:1234/deploy_kernel selinux=0 troubleshoot=0 text test_param BOOTIF=${mac} initrd=deploy_ramdisk || goto retry initrd --timeout 120 http://1.2.3.4:1234/deploy_ramdisk || goto retry boot diff --git a/ironic/tests/unit/drivers/modules/test_ipxe.py b/ironic/tests/unit/drivers/modules/test_ipxe.py index f8fdb50f72..65f0194cdb 100644 --- a/ironic/tests/unit/drivers/modules/test_ipxe.py +++ b/ironic/tests/unit/drivers/modules/test_ipxe.py @@ -293,11 +293,11 @@ class iPXEBootTestCase(db_base.DbTestCase): ipxe_enabled=True) if uefi: mock_pxe_config.assert_called_once_with( - task, {'foo': 'bar'}, CONF.pxe.uefi_pxe_config_template, + task, {}, CONF.pxe.uefi_pxe_config_template, ipxe_enabled=True) else: mock_pxe_config.assert_called_once_with( - task, {'foo': 'bar'}, CONF.pxe.pxe_config_template, + task, {}, CONF.pxe.pxe_config_template, ipxe_enabled=True) def test_prepare_ramdisk(self): diff --git a/ironic/tests/unit/drivers/modules/test_pxe.py b/ironic/tests/unit/drivers/modules/test_pxe.py index 87e770e0b8..8d710b4d0e 100644 --- a/ironic/tests/unit/drivers/modules/test_pxe.py +++ b/ironic/tests/unit/drivers/modules/test_pxe.py @@ -290,11 +290,11 @@ class PXEBootTestCase(db_base.DbTestCase): ipxe_enabled=CONF.pxe.ipxe_enabled) if uefi: mock_pxe_config.assert_called_once_with( - task, {'foo': 'bar'}, CONF.pxe.uefi_pxe_config_template, + task, {}, CONF.pxe.uefi_pxe_config_template, ipxe_enabled=CONF.pxe.ipxe_enabled) else: mock_pxe_config.assert_called_once_with( - task, {'foo': 'bar'}, CONF.pxe.pxe_config_template, + task, {}, CONF.pxe.pxe_config_template, ipxe_enabled=CONF.pxe.ipxe_enabled) def test_prepare_ramdisk(self): diff --git a/ironic/tests/unit/drivers/pxe_config.template b/ironic/tests/unit/drivers/pxe_config.template index 15a4209acc..a94a816aec 100644 --- a/ironic/tests/unit/drivers/pxe_config.template +++ b/ironic/tests/unit/drivers/pxe_config.template @@ -2,7 +2,7 @@ default deploy label deploy kernel /tftpboot/1be26c0b-03f2-4d2e-ae87-c02d7f33c123/deploy_kernel -append initrd=/tftpboot/1be26c0b-03f2-4d2e-ae87-c02d7f33c123/deploy_ramdisk selinux=0 troubleshoot=0 text test_param ipa-api-url=http://192.168.122.184:6385 +append initrd=/tftpboot/1be26c0b-03f2-4d2e-ae87-c02d7f33c123/deploy_ramdisk selinux=0 troubleshoot=0 text test_param ipappend 2 diff --git a/ironic/tests/unit/drivers/pxe_grub_config.template b/ironic/tests/unit/drivers/pxe_grub_config.template index d1574bbbd5..568018671d 100644 --- a/ironic/tests/unit/drivers/pxe_grub_config.template +++ b/ironic/tests/unit/drivers/pxe_grub_config.template @@ -3,7 +3,7 @@ set timeout=5 set hidden_timeout_quiet=false menuentry "deploy" { - linuxefi /tftpboot/1be26c0b-03f2-4d2e-ae87-c02d7f33c123/deploy_kernel selinux=0 troubleshoot=0 text test_param boot_server=192.0.2.1 ipa-api-url=http://192.168.122.184:6385 + linuxefi /tftpboot/1be26c0b-03f2-4d2e-ae87-c02d7f33c123/deploy_kernel selinux=0 troubleshoot=0 text test_param boot_server=192.0.2.1 initrdefi /tftpboot/1be26c0b-03f2-4d2e-ae87-c02d7f33c123/deploy_ramdisk }