diff --git a/subiquity/common/apidef.py b/subiquity/common/apidef.py index d161bb01..3104d8d2 100644 --- a/subiquity/common/apidef.py +++ b/subiquity/common/apidef.py @@ -243,6 +243,9 @@ class API: def GET() -> StorageResponseV2: ... def POST(): ... + class guided: + def POST(choice: GuidedChoice) -> StorageResponseV2: ... + class reformat_disk: def POST(disk_id: str) -> StorageResponseV2: ... diff --git a/subiquity/server/controllers/filesystem.py b/subiquity/server/controllers/filesystem.py index 27db7863..242c0021 100644 --- a/subiquity/server/controllers/filesystem.py +++ b/subiquity/server/controllers/filesystem.py @@ -181,6 +181,21 @@ class FilesystemController(SubiquityController, FilesystemManipulator): mount="/", )) + def guided(self, choice): + disk = self.model._one(id=choice.disk_id) + if choice.use_lvm: + lvm_options = None + if choice.password is not None: + lvm_options = { + 'encrypt': True, + 'luks_options': { + 'password': choice.password, + }, + } + self.guided_lvm(disk, lvm_options) + else: + self.guided_direct(disk) + async def _probe_response(self, wait, resp_cls): if self._probe_task.task is None or not self._probe_task.task.done(): if wait: @@ -252,19 +267,7 @@ class FilesystemController(SubiquityController, FilesystemManipulator): async def guided_POST(self, choice: Optional[GuidedChoice]) \ -> StorageResponse: if choice is not None: - disk = self.model._one(id=choice.disk_id) - if choice.use_lvm: - lvm_options = None - if choice.password is not None: - lvm_options = { - 'encrypt': True, - 'luks_options': { - 'password': choice.password, - }, - } - self.guided_lvm(disk, lvm_options) - else: - self.guided_direct(disk) + self.guided(choice) return await self.GET() async def reset_POST(self, context, request) -> StorageResponse: @@ -301,6 +304,10 @@ class FilesystemController(SubiquityController, FilesystemManipulator): async def v2_POST(self): await self.configured() + async def v2_guided_POST(self, choice: GuidedChoice) -> StorageResponseV2: + self.guided(choice) + return await self.v2_GET() + async def v2_reformat_disk_POST(self, disk_id: str) -> StorageResponseV2: self.reformat(self.model._one(id=disk_id)) return await self.v2_GET()