summaryrefslogtreecommitdiff
path: root/ironic
diff options
context:
space:
mode:
authorDmitry Tantsur <dtantsur@protonmail.com>2022-04-11 18:48:13 +0200
committerDmitry Tantsur <dtantsur@protonmail.com>2022-04-11 18:54:42 +0200
commit5feb39844ab1a3f266669f01b6a13f39462b4612 (patch)
tree655de33e33b1bd6d013fe26919e6925574b06460 /ironic
parent688f8cb7e8ce454d8df695a15abf8a4ac8ffa119 (diff)
downloadironic-5feb39844ab1a3f266669f01b6a13f39462b4612.tar.gz
Allow reusing defaults in per-node kernel_append_params
It may be convenient to use [pxe/redfish/...]kernel_append_params as the universal defaults, while using {driver,instance}_info to only append values. This change allows that by replacing %default% with the value of the applicable configuration option. An example use case: CoreOS requires an additional artifact (root filesystem URL) when PXE booting. While here, fix the PXE/iPXE interface documentation. Change-Id: I829291ab5cc19ec2ca43bc45815d012697f0b408
Diffstat (limited to 'ironic')
-rw-r--r--ironic/drivers/modules/ilo/boot.py8
-rw-r--r--ironic/drivers/modules/irmc/boot.py9
-rw-r--r--ironic/drivers/modules/pxe_base.py9
-rw-r--r--ironic/drivers/modules/redfish/boot.py9
-rw-r--r--ironic/drivers/utils.py13
-rw-r--r--ironic/tests/unit/common/test_pxe_utils.py9
-rw-r--r--ironic/tests/unit/drivers/modules/test_image_utils.py23
7 files changed, 52 insertions, 28 deletions
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')