Merge "Move logic for raid start sector to raid_utils"
This commit is contained in:
commit
83b5a8b202
@ -1630,35 +1630,8 @@ class GenericHardwareManager(HardwareManager):
|
||||
dev_name, e)
|
||||
raise errors.SoftwareRAIDError(msg)
|
||||
|
||||
# TODO(rg): TBD, several options regarding boot part slots here:
|
||||
# 1. Create boot partitions in prevision
|
||||
# 2. Just leave space
|
||||
# 3. Do nothing: rely on the caller to specify target_raid_config
|
||||
# correctly according to what they intend to do (e.g. not set MAX
|
||||
# if they know they will need some space for bios boot or efi
|
||||
# parts). Best option imo, if we accept that the target volume
|
||||
# granularity is GiB, so you lose up to 1GiB just for a bios boot
|
||||
# partition...
|
||||
if target_boot_mode == 'uefi':
|
||||
# Leave 129MiB - start_sector s for the esp (approx 128MiB)
|
||||
# NOTE: any image efi partition is expected to be less
|
||||
# than 128MiB
|
||||
# TBD: 129MiB is a waste in most cases.
|
||||
raid_start = '129MiB'
|
||||
else:
|
||||
if partition_table_type == 'gpt':
|
||||
# Leave 8MiB - start_sector s (approx 7MiB)
|
||||
# for the bios boot partition or the ppc prepboot part
|
||||
# This should avoid grub errors saying that it cannot
|
||||
# install boot stage 1.5/2 (since the mbr gap does not
|
||||
# exist on disk holders with gpt tables)
|
||||
raid_start = '8MiB'
|
||||
else:
|
||||
# sgdisk works fine for display data on mbr tables too
|
||||
out, _u = utils.execute('sgdisk', '-F', dev_name)
|
||||
raid_start = "{}s".format(out.splitlines()[-1])
|
||||
|
||||
parted_start_dict[dev_name] = raid_start
|
||||
parted_start_dict[dev_name] = raid_utils.calculate_raid_start(
|
||||
target_boot_mode, partition_table_type, dev_name)
|
||||
|
||||
LOG.debug("First available sectors per devices %s", parted_start_dict)
|
||||
|
||||
|
@ -15,6 +15,7 @@ import copy
|
||||
from ironic_lib import utils as il_utils
|
||||
|
||||
from ironic_python_agent import errors
|
||||
from ironic_python_agent import utils
|
||||
|
||||
|
||||
def get_block_devices_for_raid(block_devices, logical_disks):
|
||||
@ -63,3 +64,42 @@ def get_block_devices_for_raid(block_devices, logical_disks):
|
||||
logical_disk['block_devices'] = matching
|
||||
|
||||
return result, logical_disks
|
||||
|
||||
|
||||
def calculate_raid_start(target_boot_mode, partition_table_type, dev_name):
|
||||
"""Define the start sector for the raid partition.
|
||||
|
||||
:param target_boot_mode: the node boot mode.
|
||||
:param partition_table_type: the node partition label, gpt or msdos.
|
||||
:param dev_name: block device in the raid configuration.
|
||||
:return: The start sector for the raid partition.
|
||||
"""
|
||||
# TODO(rg): TBD, several options regarding boot part slots here:
|
||||
# 1. Create boot partitions in prevision
|
||||
# 2. Just leave space
|
||||
# 3. Do nothing: rely on the caller to specify target_raid_config
|
||||
# correctly according to what they intend to do (e.g. not set MAX
|
||||
# if they know they will need some space for bios boot or efi
|
||||
# parts). Best option imo, if we accept that the target volume
|
||||
# granularity is GiB, so you lose up to 1GiB just for a bios boot
|
||||
# partition...
|
||||
if target_boot_mode == 'uefi':
|
||||
# Leave 129MiB - start_sector s for the esp (approx 128MiB)
|
||||
# NOTE: any image efi partition is expected to be less
|
||||
# than 128MiB
|
||||
# TBD: 129MiB is a waste in most cases.
|
||||
raid_start = '129MiB'
|
||||
else:
|
||||
if partition_table_type == 'gpt':
|
||||
# Leave 8MiB - start_sector s (approx 7MiB)
|
||||
# for the bios boot partition or the ppc prepboot part
|
||||
# This should avoid grub errors saying that it cannot
|
||||
# install boot stage 1.5/2 (since the mbr gap does not
|
||||
# exist on disk holders with gpt tables)
|
||||
raid_start = '8MiB'
|
||||
else:
|
||||
# sgdisk works fine for display data on mbr tables too
|
||||
out, _u = utils.execute('sgdisk', '-F', dev_name)
|
||||
raid_start = "{}s".format(out.splitlines()[-1])
|
||||
|
||||
return raid_start
|
||||
|
Loading…
x
Reference in New Issue
Block a user