Using bootable if set for disk
If nailgun will send as bootable flag for disk we have to use this disk and place '/boot' on it Change-Id: I881d9fd4bb378dec78fd86aff0c314c910525110 Closes-bug: 1567450
This commit is contained in:
parent
0e86a2f0a5
commit
3190de6943
@ -154,6 +154,10 @@ class Nailgun(BaseDataDriver,
|
||||
|
||||
@property
|
||||
def boot_disks(self):
|
||||
"""Property to get suitable list of disks to place '/boot'
|
||||
|
||||
:returns: list of disk where boot partition can be placed
|
||||
"""
|
||||
# FIXME(agordeev): NVMe drives should be skipped as
|
||||
# accessing such drives during the boot typically
|
||||
# requires using UEFI which is still not supported
|
||||
@ -180,9 +184,19 @@ class Nailgun(BaseDataDriver,
|
||||
md_boot_disks = [
|
||||
disk for disk in self.md_os_disks if disk in suitable_disks]
|
||||
if md_boot_disks:
|
||||
return md_boot_disks
|
||||
disks = md_boot_disks
|
||||
else:
|
||||
return suitable_disks
|
||||
disks = suitable_disks
|
||||
bootable_disk = [disk for disk in disks
|
||||
if disk.get('bootable')]
|
||||
if bootable_disk:
|
||||
if len(bootable_disk) >= 2:
|
||||
raise errors.WrongPartitionSchemeError(
|
||||
"More than one bootable disk found! %{0}".
|
||||
format(bootable_disk))
|
||||
return bootable_disk
|
||||
|
||||
return disks
|
||||
|
||||
def _have_boot_partition(self, disks):
|
||||
return any(self._is_boot_disk(d) for d in disks)
|
||||
|
@ -1762,6 +1762,15 @@ class TestNailgunMockedMeta(unittest2.TestCase):
|
||||
drv.partition_scheme.fs_by_mount('/boot').device,
|
||||
'/dev/sda3')
|
||||
|
||||
def test_boot_partition_bootable_flag(self, mock_lbd, mock_image_meta):
|
||||
data = copy.deepcopy(PROVISION_SAMPLE_DATA)
|
||||
data['ks_meta']['pm_data']['ks_spaces'][1]['bootable'] = True
|
||||
mock_lbd.return_value = LIST_BLOCK_DEVICES_SAMPLE
|
||||
drv = nailgun.Nailgun(data)
|
||||
self.assertEqual(
|
||||
drv.partition_scheme.fs_by_mount('/boot').device,
|
||||
'/dev/sdb3')
|
||||
|
||||
def test_elevate_keep_data_single_disk(self, mock_lbd, mock_image_meta):
|
||||
data = copy.deepcopy(PROVISION_SAMPLE_DATA)
|
||||
data['ks_meta']['pm_data']['ks_spaces'] = SINGLE_DISK_KS_SPACES
|
||||
|
Loading…
Reference in New Issue
Block a user