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:
parent
ddecd59dba
commit
b2d5fffcc0
|
@ -152,20 +152,22 @@ class FilesystemManipulator:
|
||||||
return
|
return
|
||||||
getattr(self, 'delete_' + obj.type)(obj)
|
getattr(self, 'delete_' + obj.type)(obj)
|
||||||
|
|
||||||
def clear(self, obj):
|
def clear(self, obj, wipe=None):
|
||||||
if obj.type == "disk":
|
if obj.type == "disk":
|
||||||
obj.preserve = False
|
obj.preserve = False
|
||||||
obj.wipe = 'superblock'
|
if wipe is None:
|
||||||
|
wipe = 'superblock'
|
||||||
|
obj.wipe = wipe
|
||||||
for subobj in obj.fs(), obj.constructed_device():
|
for subobj in obj.fs(), obj.constructed_device():
|
||||||
self.delete(subobj)
|
self.delete(subobj)
|
||||||
|
|
||||||
def reformat(self, disk, ptable=None):
|
def reformat(self, disk, ptable=None, wipe=None):
|
||||||
disk.grub_device = False
|
disk.grub_device = False
|
||||||
if ptable is not None:
|
if ptable is not None:
|
||||||
disk.ptable = ptable
|
disk.ptable = ptable
|
||||||
for p in list(disk.partitions()):
|
for p in list(disk.partitions()):
|
||||||
self.delete_partition(p, True)
|
self.delete_partition(p, True)
|
||||||
self.clear(disk)
|
self.clear(disk, wipe)
|
||||||
|
|
||||||
def can_resize_partition(self, partition):
|
def can_resize_partition(self, partition):
|
||||||
if not partition.preserve:
|
if not partition.preserve:
|
||||||
|
|
|
@ -133,28 +133,26 @@ class FilesystemController(SubiquityController, FilesystemManipulator):
|
||||||
"autoinstall config did not create needed bootloader "
|
"autoinstall config did not create needed bootloader "
|
||||||
"partition")
|
"partition")
|
||||||
|
|
||||||
def guided_direct(self, disk):
|
def setup_disk_for_guided(self, disk):
|
||||||
self.reformat(disk)
|
self.reformat(disk, wipe='superblock-recursive')
|
||||||
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)
|
|
||||||
if DeviceAction.TOGGLE_BOOT in DeviceAction.supported(disk):
|
if DeviceAction.TOGGLE_BOOT in DeviceAction.supported(disk):
|
||||||
self.add_boot_disk(disk)
|
self.add_boot_disk(disk)
|
||||||
gap = gaps.largest_gap(disk)
|
return gaps.largest_gap(disk)
|
||||||
size = sizes.get_bootfs_size(gap.size)
|
|
||||||
gap_boot, gap_rest = gap.split(size)
|
def guided_direct(self, disk):
|
||||||
spec = dict(size=size, fstype="ext4", mount='/boot')
|
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)
|
self.create_partition(device=disk, gap=gap_boot, spec=spec)
|
||||||
|
|
||||||
spec = dict(size=gap_rest.size, fstype=None)
|
part = self.create_partition(
|
||||||
part = self.create_partition(device=disk, gap=gap_rest, spec=spec)
|
device=disk, gap=gap_rest, spec=dict(fstype=None))
|
||||||
|
|
||||||
vg_name = 'ubuntu-vg'
|
vg_name = 'ubuntu-vg'
|
||||||
i = 0
|
i = 0
|
||||||
while self.model._one(type='lvm_volgroup', name=vg_name) is not None:
|
while self.model._one(type='lvm_volgroup', name=vg_name) is not None:
|
||||||
|
|
Loading…
Reference in New Issue