From ce676979a4d588bfd6592f004e4570fbd81e0d8a Mon Sep 17 00:00:00 2001 From: Steve Baker Date: Tue, 24 Aug 2021 10:40:11 +1200 Subject: [PATCH] Add --boot-mode to import and configure The commands `openstack overcloud node import` and `openstack overcloud node configure` now have a --boot-mode arguement which allows the boot mode for all affected nodes to be set to UEFI boot (uefi) or legacy BIOS boot (bios). It is expected --boot-mode=bios will only be required when specific nodes have issues with UEFI boot, or on architectures which don't support it (Power) Change-Id: Idee25f23652a8e7435a31842d4a2d838543607ae Depends-On: https://review.opendev.org/c/openstack/tripleo-heat-templates/+/805732 Blueprint: whole-disk-default (cherry picked from commit ae6958a86216c5ffd1b1513ec110c4cb08f54b00) --- .../notes/boot_mode-ef25d1a032dcae56.yaml | 7 +++++ tripleoclient/v1/overcloud_node.py | 6 ++++ tripleoclient/v2/overcloud_node.py | 9 ++++-- tripleoclient/workflows/baremetal.py | 28 +++++++++++++++---- 4 files changed, 42 insertions(+), 8 deletions(-) create mode 100644 releasenotes/notes/boot_mode-ef25d1a032dcae56.yaml diff --git a/releasenotes/notes/boot_mode-ef25d1a032dcae56.yaml b/releasenotes/notes/boot_mode-ef25d1a032dcae56.yaml new file mode 100644 index 000000000..319586599 --- /dev/null +++ b/releasenotes/notes/boot_mode-ef25d1a032dcae56.yaml @@ -0,0 +1,7 @@ +--- +features: + - | + The commands `openstack overcloud node import` and `openstack overcloud node + configure` now have a --boot-mode arguement which allows the boot mode for + all affected nodes to be set to UEFI boot (uefi) or legacy BIOS boot (bios). + This allows some nodes to have a different boot mode to the default (uefi). \ No newline at end of file diff --git a/tripleoclient/v1/overcloud_node.py b/tripleoclient/v1/overcloud_node.py index 5e3c44bf4..4351b6994 100644 --- a/tripleoclient/v1/overcloud_node.py +++ b/tripleoclient/v1/overcloud_node.py @@ -306,6 +306,10 @@ class ConfigureNode(command.Command): help=_('Whether to set instances for booting from ' 'local hard drive (local) or network ' '(netboot).')) + parser.add_argument('--boot-mode', + choices=['uefi', 'bios'], + help=_('Whether to set the boot mode to UEFI ' + '(uefi) or legacy BIOS (bios)')) parser.add_argument('--root-device', help=_('Define the root device for nodes. ' 'Can be either a list of device names ' @@ -333,6 +337,7 @@ class ConfigureNode(command.Command): kernel_name=parsed_args.deploy_kernel, ramdisk_name=parsed_args.deploy_ramdisk, instance_boot_option=parsed_args.instance_boot_option, + boot_mode=parsed_args.boot_mode, root_device=parsed_args.root_device, root_device_minimum_size=parsed_args.root_device_minimum_size, overwrite_root_device_hints=( @@ -344,6 +349,7 @@ class ConfigureNode(command.Command): kernel_name=parsed_args.deploy_kernel, ramdisk_name=parsed_args.deploy_ramdisk, instance_boot_option=parsed_args.instance_boot_option, + boot_mode=parsed_args.boot_mode, root_device=parsed_args.root_device, root_device_minimum_size=parsed_args.root_device_minimum_size, overwrite_root_device_hints=( diff --git a/tripleoclient/v2/overcloud_node.py b/tripleoclient/v2/overcloud_node.py index 5e4460ba1..a0e8fbbba 100644 --- a/tripleoclient/v2/overcloud_node.py +++ b/tripleoclient/v2/overcloud_node.py @@ -72,7 +72,11 @@ class ImportNode(command.Command): choices=['local', 'netboot'], default=None, help=_('Whether to set instances for booting from' ' local hard drive (local) or network ' - ' (netboot).')) + ' (netboot)')) + parser.add_argument('--boot-mode', + choices=['uefi', 'bios'], default=None, + help=_('Whether to set the boot mode to UEFI ' + '(uefi) or legacy BIOS (bios)')) parser.add_argument("--http-boot", default=os.environ.get( 'HTTP_BOOT', @@ -104,7 +108,8 @@ class ImportNode(command.Command): nodes = baremetal.register_or_update( self.app.client_manager, nodes_json=nodes_config, - instance_boot_option=parsed_args.instance_boot_option + instance_boot_option=parsed_args.instance_boot_option, + boot_mode=parsed_args.boot_mode ) nodes_uuids = [node.uuid for node in nodes] diff --git a/tripleoclient/workflows/baremetal.py b/tripleoclient/workflows/baremetal.py index 1d273e60f..1701311ab 100644 --- a/tripleoclient/workflows/baremetal.py +++ b/tripleoclient/workflows/baremetal.py @@ -50,7 +50,8 @@ def validate_nodes(clients, nodes_json): def register_or_update(clients, nodes_json, kernel_name=None, - ramdisk_name=None, instance_boot_option=None): + ramdisk_name=None, instance_boot_option=None, + boot_mode=None): """Node Registration or Update :param clients: Application client object. @@ -69,6 +70,9 @@ def register_or_update(clients, nodes_json, kernel_name=None, local hard drive (local) or network (netboot). :type instance_boot_option: String + :param boot_mode: Whether to set the boot mode to UEFI (uefi) or legacy + BIOS (bios) + :type boot_mode: String :returns: List """ @@ -77,8 +81,10 @@ def register_or_update(clients, nodes_json, kernel_name=None, for node in nodes_json: caps = node.get('capabilities', {}) caps = node_utils.capabilities_to_dict(caps) - if instance_boot_option is not None: + if instance_boot_option: caps.setdefault('boot_option', instance_boot_option) + if boot_mode: + caps.setdefault('boot_mode', boot_mode) node['capabilities'] = node_utils.dict_to_capabilities(caps) registered_nodes = node_utils.register_all_nodes( @@ -232,7 +238,8 @@ def introspect_manageable_nodes(clients, run_validations, concurrency, def _configure_boot(clients, node_uuid, kernel_name=None, ramdisk_name=None, - instance_boot_option=None): + instance_boot_option=None, + boot_mode=None): baremetal_client = clients.baremetal image_ids = {'kernel': kernel_name, 'ramdisk': ramdisk_name} node = baremetal_client.node.get(node_uuid) @@ -240,6 +247,8 @@ def _configure_boot(clients, node_uuid, capabilities = node_utils.capabilities_to_dict(capabilities) if instance_boot_option is not None: capabilities['boot_option'] = instance_boot_option + if boot_mode is not None: + capabilities['boot_mode'] = boot_mode capabilities = node_utils.dict_to_capabilities(capabilities) baremetal_client.node.update(node.uuid, [ @@ -366,7 +375,7 @@ def _apply_root_device_strategy(clients, node_uuid, strategy, def configure(clients, node_uuids, kernel_name=None, ramdisk_name=None, instance_boot_option=None, - root_device=None, root_device_minimum_size=4, + boot_mode=None, root_device=None, root_device_minimum_size=4, overwrite_root_device_hints=False): """Configure Node boot options. @@ -382,6 +391,9 @@ def configure(clients, node_uuids, kernel_name=None, :param instance_boot_option: Boot options to use :type instance_boot_option: String + :param boot_mode: Boot mode to use + :type instance_boot_option: String + :param root_device: Path (name) of the root device. :type root_device: String @@ -396,7 +408,7 @@ def configure(clients, node_uuids, kernel_name=None, for node_uuid in node_uuids: _configure_boot(clients, node_uuid, kernel_name, - ramdisk_name, instance_boot_option) + ramdisk_name, instance_boot_option, boot_mode) if root_device: _apply_root_device_strategy( clients, node_uuid, @@ -408,7 +420,7 @@ def configure(clients, node_uuids, kernel_name=None, def configure_manageable_nodes(clients, kernel_name='bm-deploy-kernel', ramdisk_name='bm-deploy-ramdisk', - instance_boot_option=None, + instance_boot_option=None, boot_mode=None, root_device=None, root_device_minimum_size=4, overwrite_root_device_hints=False): """Configure all manageable Nodes. @@ -429,6 +441,9 @@ def configure_manageable_nodes(clients, kernel_name='bm-deploy-kernel', :param instance_boot_option: Boot options to use :type instance_boot_option: String + :param boot_mode: Boot mode to use + :type instance_boot_option: String + :param root_device: Path (name) of the root device. :type root_device: String @@ -450,6 +465,7 @@ def configure_manageable_nodes(clients, kernel_name='bm-deploy-kernel', kernel_name=kernel_name, ramdisk_name=ramdisk_name, instance_boot_option=instance_boot_option, + boot_mode=boot_mode, root_device=root_device, root_device_minimum_size=root_device_minimum_size, overwrite_root_device_hints=overwrite_root_device_hints