Move logic to calculate raid sectors to raid_utils
Some more raid related logic moved to raid_utils. Change-Id: I08c73ad14e5b01ebac2490b83997c5452506d4a2
This commit is contained in:
parent
83b5a8b202
commit
3966871f47
@ -1670,23 +1670,9 @@ class GenericHardwareManager(HardwareManager):
|
|||||||
disk_names = logical_disk['block_devices']
|
disk_names = logical_disk['block_devices']
|
||||||
for device in disk_names:
|
for device in disk_names:
|
||||||
start = parted_start_dict[device]
|
start = parted_start_dict[device]
|
||||||
|
start_str, end_str, end = (
|
||||||
if isinstance(start, int):
|
raid_utils.calc_raid_partition_sectors(psize, start)
|
||||||
start_str = '%dGiB' % start
|
)
|
||||||
else:
|
|
||||||
start_str = start
|
|
||||||
|
|
||||||
if psize == -1:
|
|
||||||
end_str = '-1'
|
|
||||||
end = '-1'
|
|
||||||
else:
|
|
||||||
if isinstance(start, int):
|
|
||||||
end = start + psize
|
|
||||||
else:
|
|
||||||
# First partition case, start is sth like 2048s
|
|
||||||
end = psize
|
|
||||||
end_str = '%dGiB' % end
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
LOG.debug("Creating partition on {}: {} {}".format(
|
LOG.debug("Creating partition on {}: {} {}".format(
|
||||||
device, start_str, end_str))
|
device, start_str, end_str))
|
||||||
|
@ -103,3 +103,32 @@ def calculate_raid_start(target_boot_mode, partition_table_type, dev_name):
|
|||||||
raid_start = "{}s".format(out.splitlines()[-1])
|
raid_start = "{}s".format(out.splitlines()[-1])
|
||||||
|
|
||||||
return raid_start
|
return raid_start
|
||||||
|
|
||||||
|
|
||||||
|
def calc_raid_partition_sectors(psize, start):
|
||||||
|
"""Calculates end sector and converts start and end sectors including
|
||||||
|
|
||||||
|
the unit of measure, compatible with parted.
|
||||||
|
:param psize: size of the raid partition
|
||||||
|
:param start: start sector of the raid partion in integer format
|
||||||
|
:return: start and end sector in parted compatible format, end sector
|
||||||
|
as integer
|
||||||
|
"""
|
||||||
|
|
||||||
|
if isinstance(start, int):
|
||||||
|
start_str = '%dGiB' % start
|
||||||
|
else:
|
||||||
|
start_str = start
|
||||||
|
|
||||||
|
if psize == -1:
|
||||||
|
end_str = '-1'
|
||||||
|
end = '-1'
|
||||||
|
else:
|
||||||
|
if isinstance(start, int):
|
||||||
|
end = start + psize
|
||||||
|
else:
|
||||||
|
# First partition case, start is sth like 2048s
|
||||||
|
end = psize
|
||||||
|
end_str = '%dGiB' % end
|
||||||
|
|
||||||
|
return start_str, end_str, end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user