Use last digit to determine paritition naming scheme

This matches the behaviour of the linux kernel, see:

d3511f53bb/block/partition-generic.c (L39)

Change-Id: Ic3963e5c4a1886aeabed6c5994599e72040a251e
Story: 2006154
Task: 35656
This commit is contained in:
Will Szumski 2019-07-04 12:31:42 +01:00
parent 924c52251b
commit cd51319528
3 changed files with 14 additions and 6 deletions

View File

@ -201,9 +201,11 @@ def is_iscsi_device(dev, node_uuid):
return iscsi_id in dev
def is_nvme_device(dev):
"""check whether the device path belongs to an NVMe drive. """
return "/dev/nvme" in dev
def is_last_char_digit(dev):
"""check whether device name ends with a digit"""
if len(dev) >= 1:
return dev[-1].isdigit()
return False
def make_partitions(dev, root_mb, swap_mb, ephemeral_mb,
@ -251,7 +253,7 @@ def make_partitions(dev, root_mb, swap_mb, ephemeral_mb,
# the device partitions as /dev/sda1 and not /dev/sda-part1.
if is_iscsi_device(dev, node_uuid):
part_template = dev + '-part%d'
elif is_nvme_device(dev):
elif is_last_char_digit(dev):
part_template = dev + 'p%d'
else:
part_template = dev + '%d'
@ -941,7 +943,7 @@ def create_config_drive_partition(node_uuid, device, configdrive):
if is_iscsi_device(device, node_uuid):
config_drive_part = '%s-part%s' % (device, new_part.pop())
elif is_nvme_device(device):
elif is_last_char_digit(device):
config_drive_part = '%sp%s' % (device, new_part.pop())
else:
config_drive_part = '%s%s' % (device, new_part.pop())

View File

@ -1432,7 +1432,7 @@ class WholeDiskConfigDriveTestCases(base.IronicLibTestCase):
self.node_uuid)
expected_part = '%s-part4' % self.dev
elif is_nvme_device:
self.dev = '/dev/nvmefake'
self.dev = '/dev/nvmefake0'
expected_part = '%sp4' % self.dev
else:
expected_part = '/dev/fake4'

View File

@ -0,0 +1,6 @@
---
fixes:
- |
Fixes an issue where the incorrect partition naming was used for metadisk (md)
devices. See `Story 2006154 <https://storyboard.openstack.org/#!/story/2006154>`_
for details.