From 5d03d8915a64655cbe2bfbee779a438d41431fd0 Mon Sep 17 00:00:00 2001 From: Kyle MacLeod Date: Thu, 8 Jun 2023 23:43:34 -0400 Subject: [PATCH] Add extra_boot_params install value for subcloud installs This commit adds support for the extra_boot_params install value. The extra_boot_params install value provides a mechanism to pass custom boot arguments into the main sysroot disk kernel options. The intent is to allow for custom, hardware-specific boot option(s) for a given subcloud. Note: these extra options are only applied for the post-miniboot boot, i.e., when booting into the main ostree-based installation. The boot arguments are NOT applied during the initial miniboot ISO boot. Multiple boot arguments can be provided by separating each argument by a single comma. Spaces are not allowed. Example install value (yaml snippet): extra_boot_params: arg1=val1,arg2=val2 The extra_boot_params value is included in the miniboot ISO boot parameters in the form of 'extra_boot_params=arg1=val1,arg2=val2'. When the subcloud boots, the miniboot kickstart translates this parameter into proper grub/syslinux kernel options to be applied for subsequent ostree-based boots. Test Plan PASS: - Verify the extra_boot_params install value is translated into a boot parameter for initial miniboot ISO boots. - Verify that any spaces in the extra_boot_params value are detected and an error is raised, aborting the subcloud installation. - Verify an empty extra_boot_params value is ignored - Verify that functionality is not affected if the extra_boot_params value is not provided - Tested values: - Success: extra_boot_params: arg1=val1,arg2=val2 extra_boot_params: arg1=val1 extra_boot_params: arg1 # extra_boot_params: arg1=val1,arg2=val2 - Fail: extra_boot_params: extra_boot_params: arg1=val1, arg2=val2 Partial-Bug: 2023407 Change-Id: I183e07fbdef67cf5bac0da363b7f31d230e95bf5 Signed-off-by: Kyle MacLeod --- distributedcloud/dccommon/subcloud_install.py | 6 ++++++ .../dcmanager/api/controllers/v1/subclouds.py | 17 +++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/distributedcloud/dccommon/subcloud_install.py b/distributedcloud/dccommon/subcloud_install.py index 8233e6493..1281e7794 100644 --- a/distributedcloud/dccommon/subcloud_install.py +++ b/distributedcloud/dccommon/subcloud_install.py @@ -67,6 +67,7 @@ OPTIONAL_INSTALL_VALUES = [ 'no_check_certificate', 'persistent_size', 'hw_settle', + 'extra_boot_params', ] GEN_ISO_OPTIONS = { @@ -82,6 +83,7 @@ GEN_ISO_OPTIONS = { 'no_check_certificate': '--param', 'persistent_size': '--param', 'hw_settle': '--param', + 'extra_boot_params': '--param', } BMC_OPTIONS = { @@ -383,6 +385,10 @@ class SubcloudInstall(object): update_iso_cmd += [GEN_ISO_OPTIONS[key], ('insthwsettle=%s' % str(values[key]))] + elif key == 'extra_boot_params': + update_iso_cmd += [GEN_ISO_OPTIONS[key], + ('extra_boot_params=%s' + % str(values[key]))] else: update_iso_cmd += [GEN_ISO_OPTIONS[key], str(values[key])] diff --git a/distributedcloud/dcmanager/api/controllers/v1/subclouds.py b/distributedcloud/dcmanager/api/controllers/v1/subclouds.py index 95edd7618..827dac2e0 100644 --- a/distributedcloud/dcmanager/api/controllers/v1/subclouds.py +++ b/distributedcloud/dcmanager/api/controllers/v1/subclouds.py @@ -737,6 +737,23 @@ class SubcloudsController(object): if hw_settle < 0: pecan.abort(400, _("hw_settle of %s seconds is less than 0") % (str(hw_settle))) + if 'extra_boot_params' in install_values: + # Validate 'extra_boot_params' boot parameter + # Note: this must be a single string (no spaces). If + # multiple boot parameters are required they can be + # separated by commas. They will be split into separate + # arguments by the miniboot.cfg kickstart. + extra_boot_params = install_values.get('extra_boot_params') + if extra_boot_params in ('', None, 'None'): + msg = "The install value extra_boot_params must not be empty." + pecan.abort(400, _(msg)) + if ' ' in extra_boot_params: + msg = ( + "Invalid install value 'extra_boot_params=" + f"{extra_boot_params}'. Spaces are not allowed " + "(use ',' to separate multiple arguments)" + ) + pecan.abort(400, _(msg)) for k in install_consts.MANDATORY_INSTALL_VALUES: if k not in install_values: