storage/v2: mark grub_device on BIOS 'partition'
This commit is contained in:
parent
5181e4a4ac
commit
c8a5a224a9
|
@ -275,19 +275,21 @@ def _for_client_disk(disk, *, min_size=0):
|
|||
|
||||
@for_client.register(Partition)
|
||||
def _for_client_partition(partition, *, min_size=0):
|
||||
format = ""
|
||||
mount = ""
|
||||
format = ''
|
||||
mount = ''
|
||||
if partition._fs:
|
||||
format = partition._fs.fstype
|
||||
if partition._fs._mount:
|
||||
mount = partition._fs._mount.path
|
||||
grub_device = partition.grub_device or \
|
||||
partition.flag in ('bios_grub', 'prep')
|
||||
|
||||
return types.Partition(
|
||||
size=partition.size,
|
||||
number=partition._number,
|
||||
wipe=partition.wipe,
|
||||
preserve=partition.preserve,
|
||||
grub_device=partition.grub_device,
|
||||
grub_device=grub_device,
|
||||
annotations=annotations(partition) + usage_labels(partition),
|
||||
mount=mount,
|
||||
format=format)
|
||||
|
|
|
@ -295,6 +295,15 @@ class TestAdd(TestAPI):
|
|||
await inst.post('/storage/v2/add_boot_partition',
|
||||
disk_id=disk_id)
|
||||
|
||||
@timeout(5)
|
||||
async def test_v2_deny_multiple_add_boot_partition_BIOS(self):
|
||||
async with start_server('examples/simple.json', 'bios') as inst:
|
||||
disk_id = 'disk-sda'
|
||||
await inst.post('/storage/v2/add_boot_partition', disk_id=disk_id)
|
||||
with self.assertRaises(ClientResponseError):
|
||||
await inst.post('/storage/v2/add_boot_partition',
|
||||
disk_id=disk_id)
|
||||
|
||||
@timeout(5)
|
||||
async def test_v2_free_for_partitions(self):
|
||||
async with start_server('examples/simple.json') as inst:
|
||||
|
@ -353,6 +362,16 @@ class TestAdd(TestAPI):
|
|||
sda2 = first(sda['partitions'], 'number', 2)
|
||||
self.assertEqual(expected_total, sda1['size'] + sda2['size'])
|
||||
|
||||
@timeout(5)
|
||||
async def test_v2_add_boot_BIOS(self):
|
||||
async with start_server('examples/simple.json', 'bios') as inst:
|
||||
disk_id = 'disk-sda'
|
||||
resp = await inst.post('/storage/v2/add_boot_partition',
|
||||
disk_id=disk_id)
|
||||
sda = first(resp['disks'], 'id', disk_id)
|
||||
sda1 = first(sda['partitions'], 'number', 1)
|
||||
self.assertTrue(sda1['grub_device'])
|
||||
|
||||
|
||||
class TestDelete(TestAPI):
|
||||
@timeout(5)
|
||||
|
|
Loading…
Reference in New Issue