diff options
-rw-r--r-- | doc/source/admin/drivers/redfish.rst | 11 | ||||
-rw-r--r-- | doc/source/admin/interfaces/boot.rst | 61 | ||||
-rw-r--r-- | ironic/drivers/modules/ilo/boot.py | 8 | ||||
-rw-r--r-- | ironic/drivers/modules/irmc/boot.py | 9 | ||||
-rw-r--r-- | ironic/drivers/modules/pxe_base.py | 9 | ||||
-rw-r--r-- | ironic/drivers/modules/redfish/boot.py | 9 | ||||
-rw-r--r-- | ironic/drivers/utils.py | 13 | ||||
-rw-r--r-- | ironic/tests/unit/common/test_pxe_utils.py | 9 | ||||
-rw-r--r-- | ironic/tests/unit/drivers/modules/test_image_utils.py | 23 | ||||
-rw-r--r-- | releasenotes/notes/append-params-a8b9f844328da83e.yaml | 10 |
10 files changed, 121 insertions, 41 deletions
diff --git a/doc/source/admin/drivers/redfish.rst b/doc/source/admin/drivers/redfish.rst index d2d93d9ff..dcae7edd0 100644 --- a/doc/source/admin/drivers/redfish.rst +++ b/doc/source/admin/drivers/redfish.rst @@ -206,8 +206,17 @@ user-specified kernel command line parameters. .. note:: The ``driver_info`` field is supported starting with the Xena release. +Starting with the Zed cycle, you can combine the parameters from the +configuration and from the node using the special ``%default%`` syntax: + +.. code-block:: bash + + baremetal node set node-0 \ + --driver-info kernel_append_params="%default% console=ttyS0,115200n8" + For ramdisk boot, the ``instance_info[ramdisk_kernel_arguments]`` property -serves the same purpose. +serves the same purpose (``%default%`` is not supported since there is no +default value in the configuration). Pre-built ISO images ~~~~~~~~~~~~~~~~~~~~ diff --git a/doc/source/admin/interfaces/boot.rst b/doc/source/admin/interfaces/boot.rst index 5cee944c6..cd9420cc9 100644 --- a/doc/source/admin/interfaces/boot.rst +++ b/doc/source/admin/interfaces/boot.rst @@ -16,15 +16,15 @@ Check your driver documentation at :doc:`../drivers` for details. PXE boot -------- -The ``pxe`` boot interface uses PXE_ or iPXE_ to deliver the target -kernel/ramdisk pair. PXE uses relatively slow and unreliable TFTP protocol -for transfer, while iPXE uses HTTP. The downside of iPXE is that it's less -common, and usually requires bootstrapping using PXE first. - -The ``pxe`` boot interface works by preparing a PXE/iPXE environment for a -node on the file system, then instructing the DHCP provider (for example, -the Networking service) to boot the node from it. See -ref:`direct-deploy-example` for a better understanding of the whole deployment +The ``pxe`` and ``ipxe`` boot interfaces uses PXE_ or iPXE_ accordingly to +deliver the target kernel/ramdisk pair. PXE uses relatively slow and unreliable +TFTP protocol for transfer, while iPXE uses HTTP. The downside of iPXE is that +it's less common, and usually requires bootstrapping using PXE first. + +The ``pxe`` and ``ipxe`` boot interfaces work by preparing a PXE/iPXE +environment for a node on the file system, then instructing the DHCP provider +(for example, the Networking service) to boot the node from it. See +:ref:`direct-deploy-example` for a better understanding of the whole deployment process. .. note:: @@ -32,13 +32,50 @@ process. instead of conventional BIOS boot. This is particularly important for CPU architectures that do not have BIOS support at all. -The ``pxe`` boot interface is used by default for many hardware types, -including ``ipmi``. Some hardware types, notably ``ilo`` and ``irmc`` have their -specific implementations of the PXE boot interface. +The ``ipxe`` boot interface is used by default for many hardware types, +including ``ipmi``. Some hardware types, notably ``ilo`` and ``irmc`` have +their specific implementations of the PXE boot interface. Additional configuration is required for this boot interface - see :doc:`/install/configure-pxe` for details. +Kernel parameters +~~~~~~~~~~~~~~~~~ + +If you need to pass additional kernel parameters to the deployment/cleaning +ramdisk (for example, to configure serial console), use the following +configuration option: + +.. code-block:: ini + + [pxe] + kernel_append_params = nofb nomodeset vga=normal + +.. note:: + The option was called ``pxe_append_params`` before the Xena cycle. + +Per-node and per-instance overrides are also possible, for example: + +.. code-block:: bash + + baremetal node set node-0 \ + --driver-info kernel_append_params="nofb nomodeset vga=normal" + baremetal node set node-0 \ + --instance-info kernel_append_params="nofb nomodeset vga=normal" + +Starting with the Zed cycle, you can combine the parameters from the +configuration and from the node using the special ``%default%`` syntax: + +.. code-block:: bash + + baremetal node set node-0 \ + --driver-info kernel_append_params="%default% console=ttyS0,115200n8" + +Together with the configuration above, the following parameters will be +appended to the kernel command line:: + + nofb nomodeset vga=normal console=ttyS0,115200n8 + Common options -------------- diff --git a/ironic/drivers/modules/ilo/boot.py b/ironic/drivers/modules/ilo/boot.py index 5087e3998..7f5c5adcf 100644 --- a/ironic/drivers/modules/ilo/boot.py +++ b/ironic/drivers/modules/ilo/boot.py @@ -74,12 +74,8 @@ OPTIONAL_PROPERTIES = { 'ilo_add_certificates': _("Boolean value that indicates whether the " "certificates require to be added to the " "iLO."), - 'kernel_append_params': _("Additional kernel parameters to pass down " - "to instance kernel. These parameters can " - "be consumed by the kernel or by the " - "applications by reading /proc/cmdline. " - "Mind severe cmdline size limit. Overrides " - "[ilo]/kernel_append_params ironic option.") + 'kernel_append_params': driver_utils.KERNEL_APPEND_PARAMS_DESCRIPTION % + {'option_group': 'ilo'}, } COMMON_PROPERTIES = REQUIRED_PROPERTIES diff --git a/ironic/drivers/modules/irmc/boot.py b/ironic/drivers/modules/irmc/boot.py index 1195a0670..84964bd2f 100644 --- a/ironic/drivers/modules/irmc/boot.py +++ b/ironic/drivers/modules/irmc/boot.py @@ -80,13 +80,8 @@ OPTIONAL_PROPERTIES = { "the IPv4 subnet mask that the storage network is configured to " "utilize, in a range between 1 and 31 inclusive. This is necessary " "for booting a node from a remote iSCSI volume. Optional."), - 'kernel_append_params': _("Additional kernel parameters to pass down to " - "instance kernel. These parameters can be " - "consumed by the kernel or by the applications " - "by reading /proc/cmdline. Mind severe cmdline " - "size limit. Overrides " - "[irmc]/kernel_append_params ironic " - "option."), + 'kernel_append_params': driver_utils.KERNEL_APPEND_PARAMS_DESCRIPTION % + {'option_group': 'irmc'}, } COMMON_PROPERTIES = REQUIRED_PROPERTIES.copy() diff --git a/ironic/drivers/modules/pxe_base.py b/ironic/drivers/modules/pxe_base.py index a89c9e443..317b65b85 100644 --- a/ironic/drivers/modules/pxe_base.py +++ b/ironic/drivers/modules/pxe_base.py @@ -50,13 +50,8 @@ RESCUE_PROPERTIES = { 'required for rescue mode.'), } OPTIONAL_PROPERTIES = { - 'kernel_append_params': _("Additional kernel parameters to pass down to " - "instance kernel. These parameters can be " - "consumed by the kernel or by the applications " - "by reading /proc/cmdline. Mind severe cmdline " - "size limit. Overrides " - "[pxe]/kernel_append_params ironic " - "option."), + 'kernel_append_params': driver_utils.KERNEL_APPEND_PARAMS_DESCRIPTION % + {'option_group': 'pxe'}, } COMMON_PROPERTIES = REQUIRED_PROPERTIES.copy() COMMON_PROPERTIES.update(driver_utils.OPTIONAL_PROPERTIES) diff --git a/ironic/drivers/modules/redfish/boot.py b/ironic/drivers/modules/redfish/boot.py index 55c826fc6..1ce05ced9 100644 --- a/ironic/drivers/modules/redfish/boot.py +++ b/ironic/drivers/modules/redfish/boot.py @@ -46,13 +46,8 @@ OPTIONAL_PROPERTIES = { "driver should use virtual media USB or floppy " "device for passing configuration information " "to the ramdisk. Defaults to False. Optional."), - 'kernel_append_params': _("Additional kernel parameters to pass down to " - "instance kernel. These parameters can be " - "consumed by the kernel or by the applications " - "by reading /proc/cmdline. Mind severe cmdline " - "size limit. Overrides " - "[redfish]/kernel_append_params ironic " - "option."), + 'kernel_append_params': driver_utils.KERNEL_APPEND_PARAMS_DESCRIPTION % + {'option_group': 'redfish'}, 'bootloader': _("URL or Glance UUID of the EFI system partition " "image containing EFI boot loader. This image will be " "used by ironic when building UEFI-bootable ISO " diff --git a/ironic/drivers/utils.py b/ironic/drivers/utils.py index 5e1596eb4..fc5cdcf0d 100644 --- a/ironic/drivers/utils.py +++ b/ironic/drivers/utils.py @@ -384,6 +384,17 @@ OPTIONAL_PROPERTIES = { } +KERNEL_APPEND_PARAMS_DESCRIPTION = _( + "Additional kernel parameters to pass down to instance kernel. " + "These parameters can be consumed by the kernel or by the applications " + "by reading /proc/cmdline. Mind severe cmdline size limit. " + "When used with virtual media, only applies to ISO images that Ironic " + "builds, but not to pre-built ISOs provided via e.g. deploy_iso. " + "Overrides the [%(option_group)s]/kernel_append_params configuration " + "option, use %%default%% to insert its value." +) + + def get_kernel_append_params(node, default): """Get the applicable kernel params. @@ -399,7 +410,7 @@ def get_kernel_append_params(node, default): for location in ('instance_info', 'driver_info'): result = getattr(node, location).get('kernel_append_params') if result is not None: - return result + return result.replace('%default%', default or '') return default diff --git a/ironic/tests/unit/common/test_pxe_utils.py b/ironic/tests/unit/common/test_pxe_utils.py index 5ba0033a7..77ac5f4d3 100644 --- a/ironic/tests/unit/common/test_pxe_utils.py +++ b/ironic/tests/unit/common/test_pxe_utils.py @@ -1712,6 +1712,15 @@ class PXEBuildConfigOptionsTestCase(db_base.DbTestCase): self._test_build_pxe_config_options_pxe(whle_dsk_img=True, expected_pxe_params='params2') + def test_build_pxe_config_options_kernel_params_with_default(self): + info = self.node.driver_info + info['kernel_append_params'] = 'param1 %default% params2' + self.node.driver_info = info + self.node.save() + self._test_build_pxe_config_options_pxe( + whle_dsk_img=True, + expected_pxe_params='param1 test_param params2') + def test_build_pxe_config_options_kernel_params_from_instance_info(self): info = self.node.instance_info info['kernel_append_params'] = 'params2' diff --git a/ironic/tests/unit/drivers/modules/test_image_utils.py b/ironic/tests/unit/drivers/modules/test_image_utils.py index 29db32c56..6d79629d9 100644 --- a/ironic/tests/unit/drivers/modules/test_image_utils.py +++ b/ironic/tests/unit/drivers/modules/test_image_utils.py @@ -582,6 +582,29 @@ class RedfishImageUtilsTestCase(db_base.DbTestCase): @mock.patch.object(image_utils.ImageHandler, 'publish_image', autospec=True) @mock.patch.object(images, 'create_boot_iso', autospec=True) + def test__prepare_iso_image_kernel_params_defaults( + self, mock_create_boot_iso, mock_publish_image): + with task_manager.acquire(self.context, self.node.uuid, + shared=True) as task: + kernel_params = 'network-config=base64-cloudinit-blob' + + task.node.driver_info['kernel_append_params'] = \ + f'%default% {kernel_params}' + + image_utils._prepare_iso_image( + task, 'http://kernel/img', 'http://ramdisk/img', + bootloader_href=None, root_uuid=task.node.uuid) + + mock_create_boot_iso.assert_called_once_with( + mock.ANY, mock.ANY, 'http://kernel/img', 'http://ramdisk/img', + boot_mode='uefi', esp_image_href=None, + kernel_params=f'nofb nomodeset vga=normal {kernel_params}', + root_uuid='1be26c0b-03f2-4d2e-ae87-c02d7f33c123', + inject_files=None) + + @mock.patch.object(image_utils.ImageHandler, 'publish_image', + autospec=True) + @mock.patch.object(images, 'create_boot_iso', autospec=True) def test__prepare_iso_image_kernel_params_driver_info_bios( self, mock_create_boot_iso, mock_publish_image): self.config(default_boot_mode='bios', group='deploy') diff --git a/releasenotes/notes/append-params-a8b9f844328da83e.yaml b/releasenotes/notes/append-params-a8b9f844328da83e.yaml new file mode 100644 index 000000000..8a17a0f28 --- /dev/null +++ b/releasenotes/notes/append-params-a8b9f844328da83e.yaml @@ -0,0 +1,10 @@ +--- +features: + - | + When using per-node kernel parameters, i.e. ``kernel_append_params`` in the + node's ``instance_info`` or ``driver_info``, it is now possible to insert + the value of the driver's configuration option (e.g. + ``[pxe]kernel_append_params`` via the special ``%default%`` syntax, e.g.:: + + baremetal node set node-0 \ + --driver-info kernel_append_params="%default% foo=bar" |