Merge pull request #1796 from mwhudson/reusing-raid
include api-only data when sending storage objects from client to server
This commit is contained in:
commit
30cbd28152
|
@ -28,7 +28,12 @@ from subiquity.common.types import (
|
||||||
ProbeStatus,
|
ProbeStatus,
|
||||||
StorageResponseV2,
|
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 import FilesystemView, GuidedDiskSelectionView
|
||||||
from subiquity.ui.views.filesystem.probing import ProbingFailed, SlowProbing
|
from subiquity.ui.views.filesystem.probing import ProbingFailed, SlowProbing
|
||||||
from subiquitycore.async_helpers import run_bg_task
|
from subiquitycore.async_helpers import run_bg_task
|
||||||
|
@ -288,4 +293,8 @@ class FilesystemController(SubiquityTuiController, FilesystemManipulator):
|
||||||
|
|
||||||
def finish(self):
|
def finish(self):
|
||||||
log.debug("FilesystemController.finish next_screen")
|
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)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
|
@ -1336,6 +1336,10 @@ class ActionRenderMode(enum.Enum):
|
||||||
# information that is only used by client/server communication,
|
# information that is only used by client/server communication,
|
||||||
# not curtin.
|
# not curtin.
|
||||||
FOR_API = enum.auto()
|
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 means to just render actions for setting up block
|
||||||
# devices, e.g. partitioning disks and assembling RAIDs but not
|
# devices, e.g. partitioning disks and assembling RAIDs but not
|
||||||
# any format or mount actions.
|
# any format or mount actions.
|
||||||
|
@ -1346,6 +1350,12 @@ class ActionRenderMode(enum.Enum):
|
||||||
# by path.
|
# by path.
|
||||||
FORMAT_MOUNT = enum.auto()
|
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:
|
class FilesystemModel:
|
||||||
target = None
|
target = None
|
||||||
|
@ -1785,7 +1795,7 @@ class FilesystemModel:
|
||||||
obj.name,
|
obj.name,
|
||||||
obj.size,
|
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)
|
emitted_ids.add(obj.id)
|
||||||
|
|
||||||
def ensure_partitions(dev):
|
def ensure_partitions(dev):
|
||||||
|
@ -1826,7 +1836,7 @@ class FilesystemModel:
|
||||||
mountpoints = {m.path: m.id for m in self.all_mountlikes()}
|
mountpoints = {m.path: m.id for m in self.all_mountlikes()}
|
||||||
log.debug("mountpoints %s", mountpoints)
|
log.debug("mountpoints %s", mountpoints)
|
||||||
|
|
||||||
if mode == ActionRenderMode.FOR_API:
|
if mode.include_all():
|
||||||
work = list(self._actions)
|
work = list(self._actions)
|
||||||
else:
|
else:
|
||||||
work = [a for a in self._actions if not getattr(a, "preserve", False)]
|
work = [a for a in self._actions if not getattr(a, "preserve", False)]
|
||||||
|
|
Loading…
Reference in New Issue