示例#1
0
    def arm_efi_test(self, arch):
        """Test the ARM EFI platform."""
        self._reset_arch(arch)
        arch.is_efi.return_value = True
        arch.is_aarch64.return_value = True

        self._check_platform(
            platform_cls=Aarch64EFI,
            non_linux_format_types=["vfat", "ntfs"]
        )

        self._check_partitions(
            PartSpec(mountpoint="/boot/efi", fstype="efi", grow=True,
                     size=Size("200MiB"), max_size=Size("600MiB")),
            PartSpec(mountpoint="/boot", size=Size("1GiB"))
        )

        self._check_constraints(
            constraints={
                "format_types": ["efi"],
                "device_types": ["partition", "mdarray"],
                "mountpoints": ["/boot/efi"],
                "raid_levels": [raid.RAID1],
                "raid_metadata": ["1.0"]
            },
            descriptions={
                "partition": "EFI System Partition",
                "mdarray": "RAID Device"
            },
            error_message=str(
                "For a UEFI installation, you must include "
                "an EFI System Partition on a GPT-formatted "
                "disk, mounted at /boot/efi."
            )
        )
示例#2
0
    def pseries_ppc_test(self, arch):
        """Test the pSeries PPC platform."""
        self._reset_arch(arch)
        arch.is_ppc.return_value = True
        arch.get_ppc_machine.return_value = "pSeries"

        self._check_platform(
            platform_cls=IPSeriesPPC
        )

        self._check_partitions(
            PartSpec(fstype="prepboot", size=Size("4MiB")),
            PartSpec(mountpoint="/boot", size=Size("1GiB"))
        )

        self._check_constraints(
            constraints={
                "device_types": ["partition"],
                "format_types": ["prepboot"],
                "max_end": Size("4 GiB")
            },
            descriptions={
                "partition": "PReP Boot Partition"
            },
            error_message=str(
                "You must include a PReP Boot Partition "
                "within the first 4GiB of an MBR- "
                "or GPT-formatted disk."
            )
        )
示例#3
0
    def new_world_ppc_test(self, arch):
        """Test the New World PPC platform."""
        self._reset_arch(arch)
        arch.is_ppc.return_value = True
        arch.get_ppc_machine.return_value = "PMac"
        arch.get_ppc_mac_gen.return_value = "NewWorld"

        self._check_platform(
            platform_cls=NewWorldPPC,
            non_linux_format_types=["hfs", "hfs+"]
        )

        self._check_partitions(
            PartSpec(fstype="appleboot", size=Size("1MiB")),
            PartSpec(mountpoint="/boot", size=Size("1GiB"))
        )

        self._check_constraints(
            constraints={
                "device_types": ["partition"],
                "format_types": ["appleboot"],

            },
            descriptions={
                "partition": "Apple Bootstrap Partition"
            },
            error_message=str(
                "You must include an Apple Bootstrap "
                "Partition on an Apple Partition Map-"
                "formatted disk."
            )
        )
示例#4
0
    def x86_test(self, arch):
        """Test the x86 platform."""
        self._reset_arch(arch)
        arch.is_x86.return_value = True

        self._check_platform(
            platform_cls=X86,
            non_linux_format_types=["vfat", "ntfs", "hpfs"],
        )

        self._check_partitions(
            PartSpec(fstype="biosboot", size=Size("1MiB")),
            PartSpec(mountpoint="/boot", size=Size("1GiB")),
        )

        self._check_constraints(
            constraints={
                "device_types": ["disk"],
            },
            descriptions={
                "disk": "Master Boot Record",
                "partition": "First sector of boot partition",
                "mdarray": "RAID Device"
            },
            error_message=str(
                "You must include at least one MBR- or "
                "GPT-formatted disk as an install target."
            )
        )
示例#5
0
def get_default_partitioning():
    """Get the default partitioning requests.

    :return: a list of partitioning specs
    """
    # Get the platform-specific partitioning.
    partitioning = list(platform.set_default_partitioning())

    # Get the product-specific partitioning.
    for attrs in conf.storage.default_partitioning:
        name = attrs.get("name")
        swap = name == "swap"
        spec = PartSpec(
            mountpoint=name if not swap else None,
            fstype=None if not swap else "swap",
            lv=True,
            thin=not swap,
            btr=not swap,
            size=attrs.get("min") or attrs.get("size"),
            max_size=attrs.get("max"),
            grow="min" in attrs,
            required_space=attrs.get("free") or 0,
            encrypted=attrs.get("encrypted") or False,
        )

        partitioning.append(spec)

    return partitioning
示例#6
0
    def arm_test(self, arch):
        """Test the ARM platform."""
        self._reset_arch(arch)
        arch.is_arm.return_value = True

        self._check_platform(
            platform_cls=ARM
        )

        self._check_partitions(
            PartSpec(mountpoint="/boot", size=Size("1GiB"))
        )

        self._check_constraints(
            constraints={
                "device_types": ["disk"]
            },
            descriptions={
                "disk": "Master Boot Record",
                "partition": "First sector of boot partition",
            },
            error_message=str(
                "You must include at least one MBR-formatted "
                "disk as an install target."
            )
        )
示例#7
0
    def power_nv_ppc_test(self, arch):
        """Test the Power NV PPC platform."""
        self._reset_arch(arch)
        arch.is_ppc.return_value = True
        arch.get_ppc_machine.return_value = "PowerNV"

        self._check_platform(
            platform_cls=PowerNV
        )

        self._check_partitions(
            PartSpec(mountpoint="/boot", size=Size("1GiB"))
        )

        self._check_constraints(
            constraints={
                "device_types": ["partition"],
            },
            descriptions={
                "partition": "First sector of boot partition"
            },
            error_message=str(
                "You must include at least one disk as an install target."
            )
        )
示例#8
0
 def _boot_partition(self):
     """The default /boot partition for this platform."""
     return PartSpec(
         mountpoint="/boot",
         size=Size("1GiB"),
         lv=False
     )
示例#9
0
    def test_get_partitioning(self, platform, suggest_swap_size):
        storage = create_storage()

        # Set the platform specs.
        platform.partitions = [PartSpec(mountpoint="/boot", size=Size("1GiB"))]

        # Set the file system type for /boot.
        storage._bootloader = Mock(stage2_format_types=["xfs"])

        # Set the swap size.
        suggest_swap_size.return_value = Size("1024MiB")

        # Collect the requests.
        requests = AutomaticPartitioningTask._get_partitioning(
            storage=storage, excluded_mount_points=["/home", "/boot", "swap"])

        assert ["/"] == [spec.mountpoint for spec in requests]

        requests = AutomaticPartitioningTask._get_partitioning(
            storage=storage, excluded_mount_points=[])

        assert ["/boot", "/", "/home"] == \
            [spec.mountpoint for spec in requests]
        assert ["xfs", "ext4", "ext4"] == \
            [spec.fstype for spec in requests]
        assert [Size("1GiB"), Size("1GiB"), Size("500MiB")] == \
            [spec.size for spec in requests]
示例#10
0
    def s390x_test(self, arch):
        """Test the s390x platform."""
        self._reset_arch(arch)
        arch.is_s390.return_value = True

        self._check_platform(
            platform_cls=S390
        )

        self._check_partitions(
            PartSpec(mountpoint="/boot", size=Size("1GiB"), lv=False),
        )

        self._check_constraints(
            constraints={
                "device_types": ["disk", "partition"],
            },
            descriptions={
                "dasd": "DASD",
                "zfcp": "zFCP",
                "disk": "Master Boot Record",
                "partition": "First sector of boot partition"
            },
            error_message=str(
                "You must include at least one MBR- or "
                "DASD-formatted disk as an install target."
            )
        )
示例#11
0
 def _bootloader_partition(self):
     """The default bootloader partition for this platform."""
     return PartSpec(
         mountpoint="/boot/efi",
         fstype="macefi",
         size=Size("200MiB"),
         max_size=Size("600MiB"),
         grow=True,
     )
示例#12
0
 def set_platform_bootloader_reqs(self):
     ret = super().set_platform_bootloader_reqs()
     ret.append(
         PartSpec(mountpoint="/boot/efi",
                  fstype="macefi",
                  size=Size("200MiB"),
                  max_size=Size("600MiB"),
                  grow=True))
     return ret
示例#13
0
    def _boot_partition(self):
        """The default /boot partition for this platform.

        :return: a specification or None
        """
        return PartSpec(
            mountpoint="/boot",
            size=Size("1GiB")
        )
示例#14
0
    def get_default_partitioning_test(self, platform):
        platform.set_default_partitioning.return_value = [PartSpec("/boot")]

        requests = get_default_partitioning(PartitioningType.WORKSTATION)
        self.assertEqual(["/boot", "/", "/home", None],
                         [spec.mountpoint for spec in requests])

        requests = get_default_partitioning(PartitioningType.SERVER)
        self.assertEqual(["/boot", "/", None],
                         [spec.mountpoint for spec in requests])
示例#15
0
 def test_is_partition(self):
     """Test the is_partition method."""
     spec = PartSpec("/")
     assert spec.is_partition(AUTOPART_TYPE_PLAIN) == True
     assert spec.is_partition(AUTOPART_TYPE_LVM) == True
     assert spec.is_partition(AUTOPART_TYPE_LVM_THINP) == True
     assert spec.is_partition(AUTOPART_TYPE_BTRFS) == True
示例#16
0
 def is_partition_test(self):
     """Test the is_partition method."""
     spec = PartSpec("/")
     self.assertEqual(spec.is_partition(AUTOPART_TYPE_PLAIN), True)
     self.assertEqual(spec.is_partition(AUTOPART_TYPE_LVM), True)
     self.assertEqual(spec.is_partition(AUTOPART_TYPE_LVM_THINP), True)
     self.assertEqual(spec.is_partition(AUTOPART_TYPE_BTRFS), True)
示例#17
0
    def mac_efi_test(self, arch):
        """Test the Mac EFI platform."""
        self._reset_arch(arch)
        arch.is_efi.return_value = True
        arch.is_mactel.return_value = True

        self._check_platform(
            platform_cls=MacEFI,
            packages=["mactel-boot"],
            non_linux_format_types=["macefi"],
        )

        self._check_partitions(
            PartSpec(mountpoint="/boot/efi", fstype="macefi", grow=True,
                     size=Size("200MiB"), max_size=Size("600MiB")),
            PartSpec(mountpoint="/boot", size=Size("1GiB")),
        )

        self._check_constraints(
            constraints={
                "format_types": ["macefi"],
                "device_types": ["partition", "mdarray"],
                "mountpoints": ["/boot/efi"],
                "raid_levels": [raid.RAID1],
                "raid_metadata": ["1.0"]
            },
            descriptions={
                "partition": "Apple EFI Boot Partition",
                "mdarray": "RAID Device"
            },
            error_message=str(
                "For a UEFI installation, you must include "
                "a Linux HFS+ ESP on a GPT-formatted "
                "disk, mounted at /boot/efi."
            )
        )
示例#18
0
    def test_get_disks_for_implicit_partitions(self):
        """Test the get_disks_for_implicit_partitions function."""
        # The /boot partition always requires a slot.
        requests = [
            PartSpec(mountpoint="/boot", size=Size("1GiB")),
            PartSpec(mountpoint="/",
                     size=Size("2GiB"),
                     max_size=Size("15GiB"),
                     grow=True,
                     btr=True,
                     lv=True,
                     thin=True,
                     encrypted=True),
            PartSpec(fstype="swap", grow=False, lv=True, encrypted=True)
        ]

        # No implicit partitions to schedule.
        disk_1 = Mock()
        disk_2 = Mock()

        parted_disk_1 = disk_1.format.parted_disk
        parted_disk_2 = disk_2.format.parted_disk

        assert get_disks_for_implicit_partitions(
                scheme=AUTOPART_TYPE_PLAIN,
                disks=[disk_1, disk_2],
                requests=requests
            ) == \
            []

        # Extended partitions are supported by the first disk.
        parted_disk_1.supportsFeature.return_value = True
        parted_disk_1.maxPrimaryPartitionCount = 3
        parted_disk_1.primaryPartitionCount = 3

        parted_disk_2.supportsFeature.return_value = False
        parted_disk_2.maxPrimaryPartitionCount = 3
        parted_disk_2.primaryPartitionCount = 2

        assert get_disks_for_implicit_partitions(
                scheme=AUTOPART_TYPE_LVM_THINP,
                disks=[disk_1, disk_2],
                requests=requests
            ) == \
            [disk_1, disk_2]

        # Extended partitions are not supported by the first disk.
        parted_disk_1.supportsFeature.return_value = False
        parted_disk_1.maxPrimaryPartitionCount = 3
        parted_disk_1.primaryPartitionCount = 2

        assert get_disks_for_implicit_partitions(
                scheme=AUTOPART_TYPE_LVM_THINP,
                disks=[disk_1, disk_2],
                requests=requests
            ) == \
            [disk_2]

        # Not empty slots for implicit partitions.
        parted_disk_1.supportsFeature.return_value = False
        parted_disk_1.maxPrimaryPartitionCount = 3
        parted_disk_1.primaryPartitionCount = 3

        assert get_disks_for_implicit_partitions(
                scheme=AUTOPART_TYPE_LVM_THINP,
                disks=[disk_1, disk_2],
                requests=requests
            ) == \
            []
示例#19
0
 def _bootloader_partition(self):
     """The default bootloader partition for this platform."""
     return PartSpec(
         fstype="appleboot",
         size=Size("1MiB")
     )
示例#20
0
    def test_get_default_partitioning(self, platform):
        platform.partitions = [PartSpec("/boot")]
        requests = get_default_partitioning()

        assert ["/boot", "/",
                "/home"] == [spec.mountpoint for spec in requests]
示例#21
0
from pyanaconda.modules.storage.partitioning.automatic.utils import get_default_partitioning
from pyanaconda.modules.storage.partitioning.specification import PartSpec

from pyanaconda.core.configuration.anaconda import AnacondaConfiguration
from pyanaconda.core.configuration.base import ConfigurationError, create_parser, read_config
from pyanaconda.core.configuration.product import ProductLoader
from pyanaconda.product import trim_product_version_for_ui

PRODUCT_DIR = os.path.join(os.environ.get("ANACONDA_DATA"), "product.d")

SERVER_PARTITIONING = [
    PartSpec(
        mountpoint="/",
        size=Size("2GiB"),
        max_size=Size("15GiB"),
        grow=True,
        btr=True,
        lv=True,
        thin=True,
        encrypted=True,
    )
]

WORKSTATION_PARTITIONING = [
    PartSpec(
        mountpoint="/",
        size=Size("1GiB"),
        max_size=Size("70GiB"),
        grow=True,
        btr=True,
        lv=True,
        thin=True,
示例#22
0
    def get_default_partitioning_test(self, platform):
        platform.partitions = [PartSpec("/boot")]
        requests = get_default_partitioning()

        self.assertEqual(["/boot", "/", "/home"],
                         [spec.mountpoint for spec in requests])
示例#23
0
    def test_is_lvm_thin_volume(self):
        """Test the is_lvm_thin_volume method."""
        spec = PartSpec("/", lv=True)
        assert spec.is_lvm_thin_volume(AUTOPART_TYPE_PLAIN) == False
        assert spec.is_lvm_thin_volume(AUTOPART_TYPE_LVM) == False
        assert spec.is_lvm_thin_volume(AUTOPART_TYPE_LVM_THINP) == False
        assert spec.is_lvm_thin_volume(AUTOPART_TYPE_BTRFS) == False

        spec = PartSpec("/", lv=True, thin=True)
        assert spec.is_lvm_thin_volume(AUTOPART_TYPE_PLAIN) == False
        assert spec.is_lvm_thin_volume(AUTOPART_TYPE_LVM) == False
        assert spec.is_lvm_thin_volume(AUTOPART_TYPE_LVM_THINP) == True
        assert spec.is_lvm_thin_volume(AUTOPART_TYPE_BTRFS) == False
示例#24
0
 def set_platform_boot_partition(self):
     """Return the default /boot partition for this platform."""
     return [PartSpec(mountpoint="/boot", size=Size("1GiB"))]
示例#25
0
 def set_platform_bootloader_reqs(self):
     """Return the default platform-specific partitioning information."""
     ret = super().set_platform_bootloader_reqs()
     ret.append(PartSpec(fstype="biosboot", size=Size("1MiB")))
     return ret
示例#26
0
 def set_platform_bootloader_reqs(self):
     ret = PPC.set_platform_bootloader_reqs(self)
     ret.append(PartSpec(fstype="prepboot", size=Size("4MiB")))
     return ret
示例#27
0
 def set_platform_bootloader_reqs(self):
     ret = super().set_platform_bootloader_reqs()
     ret.append(PartSpec(fstype="appleboot", size=Size("1MiB")))
     return ret
示例#28
0
 def set_platform_boot_partition(self):
     """Return the default platform-specific partitioning information."""
     return [PartSpec(mountpoint="/boot", size=Size("1GiB"), lv=False)]
示例#29
0
    def is_lvm_thin_volume_test(self):
        """Test the is_lvm_thin_volume method."""
        spec = PartSpec("/", lv=True)
        self.assertEqual(spec.is_lvm_thin_volume(AUTOPART_TYPE_PLAIN), False)
        self.assertEqual(spec.is_lvm_thin_volume(AUTOPART_TYPE_LVM), False)
        self.assertEqual(spec.is_lvm_thin_volume(AUTOPART_TYPE_LVM_THINP),
                         False)
        self.assertEqual(spec.is_lvm_thin_volume(AUTOPART_TYPE_BTRFS), False)

        spec = PartSpec("/", lv=True, thin=True)
        self.assertEqual(spec.is_lvm_thin_volume(AUTOPART_TYPE_PLAIN), False)
        self.assertEqual(spec.is_lvm_thin_volume(AUTOPART_TYPE_LVM), False)
        self.assertEqual(spec.is_lvm_thin_volume(AUTOPART_TYPE_LVM_THINP),
                         True)
        self.assertEqual(spec.is_lvm_thin_volume(AUTOPART_TYPE_BTRFS), False)