storage/v2: add guided equivalent
This commit is contained in:
parent
84b0df3f8f
commit
010fdecd2c
|
@ -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: ...
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue