From 605f7445701b2d8b2161b53a64f68943d6e09c9f Mon Sep 17 00:00:00 2001 From: Ilya Etingof Date: Mon, 7 Oct 2019 17:58:01 +0200 Subject: [PATCH] Add `instance_info/kernel_append_params` to `redfish` Adds `instance_info/kernel_append_params` property support to `redfish` hardware type. If given, this property overrides `[redfish]/kernel_append_params` ironic option. The rationale for adding this property is to allow passing node-specific kernel parameters to instance kernel. One of the use-cases for this is to pass node static network configuration to the kernel. Change-Id: Ib1617f5a7ab34968d8bfe06fe49f3ba68e56f99f Story: 2006691 Task: 36988 --- doc/source/admin/drivers/redfish.rst | 6 ++++++ ironic/conf/redfish.py | 8 +++++-- ironic/drivers/modules/redfish/boot.py | 17 ++++++++++++--- .../unit/drivers/modules/redfish/test_boot.py | 21 +++++++++++++++++++ ...ernel-params-redfish-72b87075465c87f6.yaml | 9 ++++++++ 5 files changed, 56 insertions(+), 5 deletions(-) create mode 100644 releasenotes/notes/add-kernel-params-redfish-72b87075465c87f6.yaml diff --git a/doc/source/admin/drivers/redfish.rst b/doc/source/admin/drivers/redfish.rst index cef9dbe763..9c20d6e1be 100644 --- a/doc/source/admin/drivers/redfish.rst +++ b/doc/source/admin/drivers/redfish.rst @@ -176,6 +176,12 @@ If ``[driver_info]/config_via_floppy`` boolean property of the node is set to place into on a FAT image, then insert the image into node's virtual floppy drive. +When booting over PXE or virtual media, and user instance requires some +specific kernel configuration, ``[instance_info]/kernel_append_params`` +property can be used to pass user-specified kernel command line parameters. +For ramdisk kernel, ``[instance_info]/kernel_append_params`` property serves +the same purpose. + .. _Redfish: http://redfish.dmtf.org/ .. _Sushy: https://opendev.org/openstack/sushy .. _TLS: https://en.wikipedia.org/wiki/Transport_Layer_Security diff --git a/ironic/conf/redfish.py b/ironic/conf/redfish.py index b67f51315a..70696f7af7 100644 --- a/ironic/conf/redfish.py +++ b/ironic/conf/redfish.py @@ -62,8 +62,12 @@ opts = [ 'enabled.')), cfg.StrOpt('kernel_append_params', default='nofb nomodeset vga=normal', - help=_('Additional kernel parameters for baremetal ' - 'Virtual Media boot.')), + help=_('Additional kernel parameters to pass down to the ' + 'instance kernel. These parameters can be consumed by ' + 'the kernel or by the applications by reading ' + '/proc/cmdline. Mind severe cmdline size limit! Can be ' + 'overridden by `instance_info/kernel_append_params` ' + 'property.')), ] diff --git a/ironic/drivers/modules/redfish/boot.py b/ironic/drivers/modules/redfish/boot.py index 8fe1fd5279..608975ff87 100644 --- a/ironic/drivers/modules/redfish/boot.py +++ b/ironic/drivers/modules/redfish/boot.py @@ -50,11 +50,19 @@ OPTIONAL_PROPERTIES = { "driver should use virtual media 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."), '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 " "out of kernel and ramdisk. Required for UEFI " - "boot from partition images.") + "boot from partition images."), + } RESCUE_PROPERTIES = { @@ -431,12 +439,15 @@ class RedfishVirtualMediaBoot(base.BootInterface): "building ISO for %(node)s") % {'node': task.node.uuid}) + i_info = task.node.instance_info + if deploy_utils.get_boot_option(task.node) == "ramdisk": - i_info = task.node.instance_info kernel_params = "root=/dev/ram0 text " kernel_params += i_info.get("ramdisk_kernel_arguments", "") + else: - kernel_params = CONF.redfish.kernel_append_params + kernel_params = i_info.get( + 'kernel_append_params', CONF.redfish.kernel_append_params) if params: kernel_params = ' '.join( diff --git a/ironic/tests/unit/drivers/modules/redfish/test_boot.py b/ironic/tests/unit/drivers/modules/redfish/test_boot.py index 44d337c1ae..cb187971a8 100644 --- a/ironic/tests/unit/drivers/modules/redfish/test_boot.py +++ b/ironic/tests/unit/drivers/modules/redfish/test_boot.py @@ -397,6 +397,27 @@ class RedfishVirtualMediaBootTestCase(db_base.DbTestCase): self.assertEqual(expected_url, url) + @mock.patch.object(redfish_boot.RedfishVirtualMediaBoot, + '_publish_image', autospec=True) + @mock.patch.object(images, 'create_boot_iso', autospec=True) + def test__prepare_iso_image_kernel_params( + 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.instance_info.update(kernel_append_params=kernel_params) + + task.driver.boot._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=None, esp_image_href=None, + kernel_params=kernel_params, + root_uuid='1be26c0b-03f2-4d2e-ae87-c02d7f33c123') + @mock.patch.object(redfish_boot.RedfishVirtualMediaBoot, '_prepare_iso_image', autospec=True) def test__prepare_deploy_iso(self, mock__prepare_iso_image): diff --git a/releasenotes/notes/add-kernel-params-redfish-72b87075465c87f6.yaml b/releasenotes/notes/add-kernel-params-redfish-72b87075465c87f6.yaml new file mode 100644 index 0000000000..f61699a7a7 --- /dev/null +++ b/releasenotes/notes/add-kernel-params-redfish-72b87075465c87f6.yaml @@ -0,0 +1,9 @@ +--- +features: + - | + Adds ``instance_info/kernel_append_params`` property support to ``redfish`` + hardware type. If given, this property overrides + ``[redfish]/kernel_append_params`` ironic option. The rationale for adding + this property is to allow passing node-specific kernel parameters to instance + kernel. One of the use-cases for this is to pass node static network + configuration to the kernel.