filesystem: guided_method refactoring

Update the guided_methods, particularly guided_direct.  It now does a
direct call to create_partition, bypassing the increasingly complicated
partition_disk_handler, making it more similar to guided_lvm, and making
way for guided partitioning into a gap.
This commit is contained in:
Dan Bungert 2022-06-16 17:27:37 -06:00
parent ddecd59dba
commit b2d5fffcc0
2 changed files with 22 additions and 22 deletions

View File

@ -152,20 +152,22 @@ class FilesystemManipulator:
return
getattr(self, 'delete_' + obj.type)(obj)
def clear(self, obj):
def clear(self, obj, wipe=None):
if obj.type == "disk":
obj.preserve = False
obj.wipe = 'superblock'
if wipe is None:
wipe = 'superblock'
obj.wipe = wipe
for subobj in obj.fs(), obj.constructed_device():
self.delete(subobj)
def reformat(self, disk, ptable=None):
def reformat(self, disk, ptable=None, wipe=None):
disk.grub_device = False
if ptable is not None:
disk.ptable = ptable
for p in list(disk.partitions()):
self.delete_partition(p, True)
self.clear(disk)
self.clear(disk, wipe)
def can_resize_partition(self, partition):
if not partition.preserve:

View File

@ -133,28 +133,26 @@ class FilesystemController(SubiquityController, FilesystemManipulator):
"autoinstall config did not create needed bootloader "
"partition")
def guided_direct(self, disk):
self.reformat(disk)
gap = gaps.largest_gap(disk)
spec = {
"size": gap.size,
"fstype": "ext4",
"mount": "/",
}
self.partition_disk_handler(disk, spec, gap=gap)
def guided_lvm(self, disk, lvm_options=None):
self.reformat(disk)
def setup_disk_for_guided(self, disk):
self.reformat(disk, wipe='superblock-recursive')
if DeviceAction.TOGGLE_BOOT in DeviceAction.supported(disk):
self.add_boot_disk(disk)
gap = gaps.largest_gap(disk)
size = sizes.get_bootfs_size(gap.size)
gap_boot, gap_rest = gap.split(size)
spec = dict(size=size, fstype="ext4", mount='/boot')
return gaps.largest_gap(disk)
def guided_direct(self, disk):
gap = self.setup_disk_for_guided(disk)
spec = dict(fstype="ext4", mount="/")
self.create_partition(device=disk, gap=gap, spec=spec)
def guided_lvm(self, disk, lvm_options=None):
gap = self.setup_disk_for_guided(disk)
gap_boot, gap_rest = gap.split(sizes.get_bootfs_size(gap.size))
spec = dict(fstype="ext4", mount='/boot')
self.create_partition(device=disk, gap=gap_boot, spec=spec)
spec = dict(size=gap_rest.size, fstype=None)
part = self.create_partition(device=disk, gap=gap_rest, spec=spec)
part = self.create_partition(
device=disk, gap=gap_rest, spec=dict(fstype=None))
vg_name = 'ubuntu-vg'
i = 0
while self.model._one(type='lvm_volgroup', name=vg_name) is not None: