Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lunar 2023 04 04 #1635

Merged
merged 2 commits into from
Apr 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions subiquity/common/apidef.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,16 +306,10 @@ class reformat_disk:
def POST(data: Payload[ReformatDisk]) \
-> StorageResponseV2: ...

class potential_boot_disks:
"""Obtain the list of disks which can be made bootable.
This list can be empty if there are no disks or if none of them
are plausible sources of a boot disk."""
def GET() -> List[str]: ...

class add_boot_partition:
"""Mark a given disk as bootable, which may cause a partition
to be added to the disk. It is an error to call this for a
disk not in the list from potential_boot_disks."""
disk for which can_be_boot_device is False."""
def POST(disk_id: str) -> StorageResponseV2: ...

class add_partition:
Expand Down
1 change: 1 addition & 0 deletions subiquity/common/filesystem/labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ def _for_client_disk(disk, *, min_size=0):
usage_labels=usage_labels(disk),
partitions=[for_client(p) for p in gaps.parts_and_gaps(disk)],
boot_device=boot.is_boot_device(disk),
can_be_boot_device=boot.can_be_boot_device(disk),
ok_for_guided=disk.size >= min_size,
model=getattr(disk, 'model', None),
vendor=getattr(disk, 'vendor', None))
Expand Down
1 change: 1 addition & 0 deletions subiquity/common/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ class Disk:
preserve: bool
path: Optional[str]
boot_device: bool
can_be_boot_device: bool
model: Optional[str] = None
vendor: Optional[str] = None

Expand Down
5 changes: 0 additions & 5 deletions subiquity/server/controllers/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -710,11 +710,6 @@ async def v2_reformat_disk_POST(self, data: ReformatDisk) \
self.reformat(self.model._one(id=data.disk_id), data.ptable)
return await self.v2_GET()

async def v2_potential_boot_disks_GET(self) -> List[str]:
disks = self.potential_boot_disks(check_boot=True,
with_reformatting=False)
return [disk.id for disk in disks]

async def v2_add_boot_partition_POST(self, disk_id: str) \
-> StorageResponseV2:
disk = self.model._one(id=disk_id)
Expand Down
36 changes: 20 additions & 16 deletions subiquity/server/controllers/tests/test_filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,27 +510,30 @@ def _setup(self, bootloader, ptable, **kw):
self.app = make_app()
self.app.opts.bootloader = bootloader.value
self.fsc = FilesystemController(app=self.app)
self.fsc.calculate_suggested_install_min = mock.Mock()
self.fsc.calculate_suggested_install_min.return_value = 10 << 30
self.fsc.model = self.model = make_model(bootloader)
self.model.storage_version = 2
self.fsc._probe_task.task = mock.Mock()
self.fsc._get_system_task.task = mock.Mock()

@parameterized.expand(bootloaders_and_ptables)
async def test_get_boot_disks_only(self, bootloader, ptable):
self._setup(bootloader, ptable)
disk = make_disk(self.model)
self.assertEqual([disk.id],
await self.fsc.v2_potential_boot_disks_GET())

@parameterized.expand(bootloaders_and_ptables)
async def test_get_boot_disks_none(self, bootloader, ptable):
self._setup(bootloader, ptable)
self.assertEqual([], await self.fsc.v2_potential_boot_disks_GET())
make_disk(self.model)
resp = await self.fsc.v2_GET()
[d] = resp.disks
self.assertTrue(d.can_be_boot_device)

@parameterized.expand(bootloaders_and_ptables)
async def test_get_boot_disks_all(self, bootloader, ptable):
self._setup(bootloader, ptable)
d1 = make_disk(self.model)
d2 = make_disk(self.model)
self.assertEqual(set([d1.id, d2.id]),
set(await self.fsc.v2_potential_boot_disks_GET()))
make_disk(self.model)
make_disk(self.model)
resp = await self.fsc.v2_GET()
[d1, d2] = resp.disks
self.assertTrue(d1.can_be_boot_device)
self.assertTrue(d2.can_be_boot_device)

@parameterized.expand(bootloaders_and_ptables)
async def test_get_boot_disks_some(self, bootloader, ptable):
Expand All @@ -542,11 +545,12 @@ async def test_get_boot_disks_some(self, bootloader, ptable):
preserve=True)
if bootloader == Bootloader.NONE:
# NONE will always pass the boot check, even on a full disk
expected = set([d1.id, d2.id])
bootable = set([d1.id, d2.id])
else:
expected = set([d2.id])
self.assertEqual(expected,
set(await self.fsc.v2_potential_boot_disks_GET()))
bootable = set([d2.id])
resp = await self.fsc.v2_GET()
for d in resp.disks:
self.assertEqual(d.id in bootable, d.can_be_boot_device)


class TestCoreBootInstallMethods(IsolatedAsyncioTestCase):
Expand Down