Skip to content
Open
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
22 changes: 20 additions & 2 deletions subiquity/client/controllers/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
)
from subiquity.ui.views import FilesystemView, GuidedDiskSelectionView
from subiquity.ui.views.filesystem.probing import ProbingFailed, SlowProbing
from subiquitycore.async_helpers import run_bg_task
from subiquitycore.async_helpers import connect_async_signal, run_bg_task
from subiquitycore.lsb_release import lsb_release
from subiquitycore.view import BaseView

Expand Down Expand Up @@ -206,6 +206,11 @@ async def _answers_action(self, action):
)
from subiquitycore.ui.stretchy import StretchyOverlay

form_submitted = asyncio.Event()

async def on_form_closed(*args, **kwargs):
form_submitted.set()

log.debug("_answers_action %r", action)
if "obj" in action:
obj = self._action_get(action["obj"])
Expand All @@ -219,11 +224,18 @@ async def _answers_action(self, action):
meth = getattr(
self.ui.body.avail_list, "_{}_{}".format(obj.type, action_name)
)
meth(obj)
maybe_coro = meth(obj)
if asyncio.iscoroutine(maybe_coro):
await maybe_coro
self.ui.body.request_redraw()

yield
body = self.ui.body._w
if not isinstance(body, StretchyOverlay):
return

connect_async_signal(body.stretchy, "closed", on_form_closed)

if isinstance(
body.stretchy, (ConfirmDeleteStretchy, ConfirmReformatStretchy)
):
Expand All @@ -234,28 +246,34 @@ async def _answers_action(self, action):
body.stretchy.form, action["data"], action.get("submit", True)
):
pass

await form_submitted.wait()
elif action["action"] == "create-raid":
self.ui.body.create_raid()
yield
body = self.ui.body._w
connect_async_signal(body.stretchy, "closed", on_form_closed)
async for _ in self._enter_form_data(
body.stretchy.form,
action["data"],
action.get("submit", True),
clean_suffix="raid",
):
pass
await form_submitted.wait()
elif action["action"] == "create-vg":
self.ui.body.create_vg()
yield
body = self.ui.body._w
connect_async_signal(body.stretchy, "closed", on_form_closed)
async for _ in self._enter_form_data(
body.stretchy.form,
action["data"],
action.get("submit", True),
clean_suffix="vg",
):
pass
await form_submitted.wait()
elif action["action"] == "done":
if not self.ui.body.done_btn.enabled:
raise Exception("answers did not provide complete fs config")
Expand Down
22 changes: 12 additions & 10 deletions subiquity/common/filesystem/boot.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def new_partition_count(self) -> int:
return 0

@abc.abstractmethod
def apply(self, manipulator):
async def apply(self, manipulator):
pass


Expand All @@ -84,8 +84,10 @@ class CreatePartPlan(MakeBootDevicePlan):
def new_partition_count(self) -> int:
return 1

def apply(self, manipulator):
manipulator.create_partition(self.gap.device, self.gap, self.spec, **self.args)
async def apply(self, manipulator):
await manipulator.create_partition(
self.gap.device, self.gap, self.spec, **self.args
)


def _can_resize_part(inst, field, part):
Expand All @@ -100,7 +102,7 @@ class ResizePlan(MakeBootDevicePlan):
size_delta: int = 0
allow_resize_preserved: bool = False

def apply(self, manipulator):
async def apply(self, manipulator):
self.part.size += self.size_delta
if self.part.preserve:
self.part.resize = True
Expand All @@ -118,7 +120,7 @@ class SlidePlan(MakeBootDevicePlan):
parts: list = attr.ib(validator=_no_preserve_parts)
offset_delta: int = 0

def apply(self, manipulator):
async def apply(self, manipulator):
for part in self.parts:
part.offset += self.offset_delta

Expand All @@ -131,7 +133,7 @@ class SetAttrPlan(MakeBootDevicePlan):
attr: str
val: Any

def apply(self, manipulator):
async def apply(self, manipulator):
setattr(self.device, self.attr, self.val)


Expand All @@ -141,15 +143,15 @@ class MountBootEfiPlan(MakeBootDevicePlan):

part: object

def apply(self, manipulator):
async def apply(self, manipulator):
manipulator._mount_esp(self.part)


@attr.s(auto_attribs=True)
class NoOpBootPlan(MakeBootDevicePlan):
"""Do nothing, successfully"""

def apply(self, manipulator):
async def apply(self, manipulator):
pass


Expand All @@ -159,9 +161,9 @@ class MultiStepPlan(MakeBootDevicePlan):

plans: list

def apply(self, manipulator):
async def apply(self, manipulator):
for plan in self.plans:
plan.apply(manipulator)
await plan.apply(manipulator)

# TODO add @typing.override decorator when we switch to core24.
def new_partition_count(self) -> int:
Expand Down
Loading