Skip to content

Commit

Permalink
storage: make storage manipulator async ready
Browse files Browse the repository at this point in the history
Going forward, the client storage/filesystem controller should perform
all of the storage actions by making async calls to the API. These calls
will be implemented using coroutines functions that will call aiohttp.

At the start, these new coroutine functions will override the methods
from the manipulator. However, the functions defined by the manipulator
are not coroutines functions so there is a mismatch.

Move the needed functions to coroutine functions so that we can properly
override them with coroutine functions.

Signed-off-by: Olivier Gayot <[email protected]>
  • Loading branch information
ogayot committed Jun 20, 2024
1 parent 0d36d89 commit 5ecaba6
Show file tree
Hide file tree
Showing 13 changed files with 240 additions and 196 deletions.
22 changes: 12 additions & 10 deletions subiquity/common/filesystem/boot.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class MakeBootDevicePlan(abc.ABC):
"""

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


Expand All @@ -77,8 +77,10 @@ class CreatePartPlan(MakeBootDevicePlan):
spec: dict = attr.ib(factory=dict)
args: dict = attr.ib(factory=dict)

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 @@ -93,7 +95,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 @@ -111,7 +113,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 @@ -124,7 +126,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 @@ -134,15 +136,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 @@ -152,9 +154,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)


def get_boot_device_plan_bios(device) -> Optional[MakeBootDevicePlan]:
Expand Down
Loading

0 comments on commit 5ecaba6

Please sign in to comment.