Skip to content

Commit

Permalink
Merge pull request #1796 from mwhudson/reusing-raid
Browse files Browse the repository at this point in the history
include api-only data when sending storage objects from client to server
  • Loading branch information
mwhudson committed Sep 19, 2023
2 parents a4fe424 + 4d24865 commit 30cbd28
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
13 changes: 11 additions & 2 deletions subiquity/client/controllers/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@
ProbeStatus,
StorageResponseV2,
)
from subiquity.models.filesystem import Bootloader, FilesystemModel, raidlevels_by_value
from subiquity.models.filesystem import (
ActionRenderMode,
Bootloader,
FilesystemModel,
raidlevels_by_value,
)
from subiquity.ui.views import FilesystemView, GuidedDiskSelectionView
from subiquity.ui.views.filesystem.probing import ProbingFailed, SlowProbing
from subiquitycore.async_helpers import run_bg_task
Expand Down Expand Up @@ -288,4 +293,8 @@ def cancel(self):

def finish(self):
log.debug("FilesystemController.finish next_screen")
self.app.next_screen(self.endpoint.POST(self.model._render_actions()))
self.app.next_screen(
self.endpoint.POST(
self.model._render_actions(mode=ActionRenderMode.FOR_API_CLIENT)
)
)
14 changes: 12 additions & 2 deletions subiquity/models/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -1336,6 +1336,10 @@ class ActionRenderMode(enum.Enum):
# information that is only used by client/server communication,
# not curtin.
FOR_API = enum.auto()
# FOR_API_CLIENT means render actions for devices that have
# changes and include information that is only used by
# client/server communication, not curtin.
FOR_API_CLIENT = enum.auto()
# DEVICES means to just render actions for setting up block
# devices, e.g. partitioning disks and assembling RAIDs but not
# any format or mount actions.
Expand All @@ -1346,6 +1350,12 @@ class ActionRenderMode(enum.Enum):
# by path.
FORMAT_MOUNT = enum.auto()

def is_api(self):
return self in [ActionRenderMode.FOR_API, ActionRenderMode.FOR_API_CLIENT]

def include_all(self):
return self in [ActionRenderMode.FOR_API]


class FilesystemModel:
target = None
Expand Down Expand Up @@ -1785,7 +1795,7 @@ def emit(obj):
obj.name,
obj.size,
)
r.append(asdict(obj, for_api=mode == ActionRenderMode.FOR_API))
r.append(asdict(obj, for_api=mode.is_api()))
emitted_ids.add(obj.id)

def ensure_partitions(dev):
Expand Down Expand Up @@ -1826,7 +1836,7 @@ def can_emit(obj):
mountpoints = {m.path: m.id for m in self.all_mountlikes()}
log.debug("mountpoints %s", mountpoints)

if mode == ActionRenderMode.FOR_API:
if mode.include_all():
work = list(self._actions)
else:
work = [a for a in self._actions if not getattr(a, "preserve", False)]
Expand Down

0 comments on commit 30cbd28

Please sign in to comment.