summaryrefslogtreecommitdiff
path: root/ironic_python_agent/raid_utils.py
diff options
context:
space:
mode:
authorRiccardo Pittau <elfosardo@gmail.com>2020-04-08 17:22:47 +0200
committerRiccardo Pittau <elfosardo@gmail.com>2020-04-08 17:32:38 +0200
commitf32a4a2b29df01cb100b6fdda59dac5d964a1107 (patch)
treed45c31b580cc777e10deb9ffe23974e7d2a13f5a /ironic_python_agent/raid_utils.py
parentbdc5e9448decaa8e4ebc9e1d6b62508cba967ad4 (diff)
downloadironic-python-agent-f32a4a2b29df01cb100b6fdda59dac5d964a1107.tar.gz
Move logic for raid start sector to raid_utils
A starting tentative in reducing size of raid related functions. Change-Id: I81f912d0dc0ad138d8cc776cdb4ee3b5251ec3ba
Diffstat (limited to 'ironic_python_agent/raid_utils.py')
-rw-r--r--ironic_python_agent/raid_utils.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/ironic_python_agent/raid_utils.py b/ironic_python_agent/raid_utils.py
index 7f718ac4..b50164e8 100644
--- a/ironic_python_agent/raid_utils.py
+++ b/ironic_python_agent/raid_utils.py
@@ -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