diff --git a/subiquity/common/filesystem/actions.py b/subiquity/common/filesystem/actions.py index 572348db..33b2e792 100644 --- a/subiquity/common/filesystem/actions.py +++ b/subiquity/common/filesystem/actions.py @@ -292,7 +292,7 @@ def _can_delete_partition(partition): if partition.device._has_preexisting_partition(): return _("Cannot delete a single partition from a device that " "already has partitions.") - if partition.is_bootloader_partition: + if boot.is_bootloader_partition(partition): return _("Cannot delete required bootloader partition") return _can_delete_generic(partition) diff --git a/subiquity/common/filesystem/boot.py b/subiquity/common/filesystem/boot.py index 1c155493..6479a9d7 100644 --- a/subiquity/common/filesystem/boot.py +++ b/subiquity/common/filesystem/boot.py @@ -96,3 +96,14 @@ def _is_esp_partition(partition): def all_boot_devices(model): """Return all current boot devices for `model`.""" return [disk for disk in model.all_disks() if is_boot_device(disk)] + + +def is_bootloader_partition(partition): + if partition._m.bootloader == Bootloader.BIOS: + return partition.flag == "bios_grub" + elif partition._m.bootloader == Bootloader.UEFI: + return is_esp(partition) + elif partition._m.bootloader == Bootloader.PREP: + return partition.flag == "prep" + else: + return False diff --git a/subiquity/common/filesystem/manipulator.py b/subiquity/common/filesystem/manipulator.py index d538927a..e24a7166 100644 --- a/subiquity/common/filesystem/manipulator.py +++ b/subiquity/common/filesystem/manipulator.py @@ -296,7 +296,7 @@ class FilesystemManipulator: boot_disk.grub_device = False partitions = [ p for p in boot_disk.partitions() - if p.is_bootloader_partition + if boot.is_bootloader_partition(p) ] remount = False if boot_disk.preserve: diff --git a/subiquity/models/filesystem.py b/subiquity/models/filesystem.py index 2b78beb2..8c31fb31 100644 --- a/subiquity/models/filesystem.py +++ b/subiquity/models/filesystem.py @@ -677,21 +677,10 @@ class Partition(_Formattable): def _path(self): return partition_kname(self.device.path, self._number) - @property - def is_bootloader_partition(self): - from subiquity.common.filesystem import boot - if self._m.bootloader == Bootloader.BIOS: - return self.flag == "bios_grub" - elif self._m.bootloader == Bootloader.UEFI: - return boot.is_esp(self) - elif self._m.bootloader == Bootloader.PREP: - return self.flag == "prep" - else: - return False - @property def ok_for_raid(self): - if self.is_bootloader_partition: + from subiquity.common.filesystem import boot + if boot.is_bootloader_partition(self): return False if self._fs is not None: if self._fs.preserve: @@ -1303,6 +1292,7 @@ class FilesystemModel(object): def add_partition(self, device, size, flag="", wipe=None, grub_device=None): + from subiquity.common.filesystem import boot if size > device.free_for_partitions: raise Exception("%s > %s", size, device.free_for_partitions) real_size = align_up(size) @@ -1312,7 +1302,7 @@ class FilesystemModel(object): p = Partition( m=self, device=device, size=real_size, flag=flag, wipe=wipe, grub_device=grub_device) - if p.is_bootloader_partition: + if boot.is_bootloader_partition(p): device._partitions.insert(0, device._partitions.pop()) device.ptable = device.ptable_for_new_partition() dasd = device.dasd()