Skip to content

Commit 60d3bd1

Browse files
committed
storage: make storage manipulator async ready
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 <olivier.gayot@canonical.com>
1 parent 4fc5378 commit 60d3bd1

File tree

13 files changed

+241
-197
lines changed

13 files changed

+241
-197
lines changed

subiquity/common/filesystem/boot.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class MakeBootDevicePlan(abc.ABC):
6464
"""
6565

6666
@abc.abstractmethod
67-
def apply(self, manipulator):
67+
async def apply(self, manipulator):
6868
pass
6969

7070

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

80-
def apply(self, manipulator):
81-
manipulator.create_partition(self.gap.device, self.gap, self.spec, **self.args)
80+
async def apply(self, manipulator):
81+
await manipulator.create_partition(
82+
self.gap.device, self.gap, self.spec, **self.args
83+
)
8284

8385

8486
def _can_resize_part(inst, field, part):
@@ -93,7 +95,7 @@ class ResizePlan(MakeBootDevicePlan):
9395
size_delta: int = 0
9496
allow_resize_preserved: bool = False
9597

96-
def apply(self, manipulator):
98+
async def apply(self, manipulator):
9799
self.part.size += self.size_delta
98100
if self.part.preserve:
99101
self.part.resize = True
@@ -111,7 +113,7 @@ class SlidePlan(MakeBootDevicePlan):
111113
parts: list = attr.ib(validator=_no_preserve_parts)
112114
offset_delta: int = 0
113115

114-
def apply(self, manipulator):
116+
async def apply(self, manipulator):
115117
for part in self.parts:
116118
part.offset += self.offset_delta
117119

@@ -124,7 +126,7 @@ class SetAttrPlan(MakeBootDevicePlan):
124126
attr: str
125127
val: Any
126128

127-
def apply(self, manipulator):
129+
async def apply(self, manipulator):
128130
setattr(self.device, self.attr, self.val)
129131

130132

@@ -134,15 +136,15 @@ class MountBootEfiPlan(MakeBootDevicePlan):
134136

135137
part: object
136138

137-
def apply(self, manipulator):
139+
async def apply(self, manipulator):
138140
manipulator._mount_esp(self.part)
139141

140142

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

145-
def apply(self, manipulator):
147+
async def apply(self, manipulator):
146148
pass
147149

148150

@@ -152,9 +154,9 @@ class MultiStepPlan(MakeBootDevicePlan):
152154

153155
plans: list
154156

155-
def apply(self, manipulator):
157+
async def apply(self, manipulator):
156158
for plan in self.plans:
157-
plan.apply(manipulator)
159+
await plan.apply(manipulator)
158160

159161

160162
def get_boot_device_plan_bios(device) -> Optional[MakeBootDevicePlan]:

0 commit comments

Comments
 (0)