Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

include api-only data when sending storage objects from client to server #1796

Merged
merged 1 commit into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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