storage: move reset_partition to model

This commit is contained in:
Dan Bungert 2023-08-25 13:28:07 -06:00
parent 443c87dc91
commit ff990df628
3 changed files with 5 additions and 7 deletions

View File

@ -1275,6 +1275,7 @@ class FilesystemModel(object):
self.storage_version = 1
self._probe_data = None
self.dd_target: Optional[Disk] = None
self.reset_partition: Optional[Partition] = None
self.reset()
def reset(self):

View File

@ -62,9 +62,7 @@ from subiquity.models.filesystem import (
ArbitraryDevice,
)
from subiquity.models.filesystem import Disk as ModelDisk
from subiquity.models.filesystem import MiB
from subiquity.models.filesystem import Partition as ModelPartition
from subiquity.models.filesystem import Raid, _Device, align_down, align_up
from subiquity.models.filesystem import MiB, Raid, _Device, align_down, align_up
from subiquity.server import snapdapi
from subiquity.server.controller import SubiquityController
from subiquity.server.mounter import Mounter
@ -244,7 +242,6 @@ class FilesystemController(SubiquityController, FilesystemManipulator):
# If probe data come in while we are doing partitioning, store it in
# this variable. It will be picked up on next reset.
self.queued_probe_data: Optional[Dict[str, Any]] = None
self.reset_partition: Optional[ModelPartition] = None
self.reset_partition_only: bool = False
def is_core_boot_classic(self):
@ -635,7 +632,7 @@ class FilesystemController(SubiquityController, FilesystemManipulator):
reset_size = int(cp.stdout.strip().split()[0])
reset_size = align_up(int(reset_size * 1.10), 256 * MiB)
reset_gap, gap = gap.split(reset_size)
self.reset_partition = self.create_partition(
self.model.reset_partition = self.create_partition(
device=reset_gap.device,
gap=reset_gap,
spec={"fstype": "fat32"},

View File

@ -413,7 +413,7 @@ class InstallController(SubiquityController):
# really write recovery_system={snapd_system_label} to
# {target}/var/lib/snapd/modeenv to get snapd to pick it up on
# first boot. But not needed for now.
rp = fs_controller.reset_partition
rp = fs_controller.model.reset_partition
if rp is not None:
mounter = Mounter(self.app)
rp_target = os.path.join(self.app.root, "factory-reset")
@ -627,7 +627,7 @@ class InstallController(SubiquityController):
fsc = self.app.controllers.Filesystem
for_install_path = self.model.source.get_source(fsc._info.name)
if self.app.controllers.Filesystem.reset_partition:
if self.app.base_model.filesystem.reset_partition:
self.app.package_installer.start_installing_pkg("efibootmgr")
if self.model.target is not None: