def _do_autopart(storage, scheme, requests, encrypted=False, luks_fmt_args=None):
        """Perform automatic partitioning.

        :param storage: an instance of Blivet
        :param scheme: a type of the partitioning scheme
        :param requests: list of partitioning requests
        :param encrypted: encrypt the scheduled partitions
        :param luks_fmt_args: arguments for the LUKS format constructor
        """
        log.debug("scheme: %s", scheme)
        log.debug("requests:\n%s", "".join([str(p) for p in requests]))
        log.debug("encrypted: %s", encrypted)
        log.debug("storage.disks: %s", [d.name for d in storage.disks])
        log.debug("storage.partitioned: %s", [d.name for d in storage.partitioned if d.format.supported])
        log.debug("all names: %s", [d.name for d in storage.devices])
        log.debug("boot disk: %s", getattr(storage.bootloader.stage1_disk, "name", None))

        disks = get_candidate_disks(storage)
        log.debug("candidate disks: %s", [d.name for d in disks])

        devs = schedule_implicit_partitions(storage, disks, scheme, encrypted, luks_fmt_args)
        devs = schedule_partitions(storage, disks, devs, scheme, requests, encrypted, luks_fmt_args)

        # run the autopart function to allocate and grow partitions
        do_partitioning(storage)
        schedule_volumes(storage, devs, scheme, requests, encrypted)

        # grow LVs
        grow_lvm(storage)

        # only newly added swaps should appear in the fstab
        new_swaps = (dev for dev in storage.swaps if not dev.format.exists)
        storage.set_fstab_swaps(new_swaps)
    def _execute_partition(self, storage, data):
        """Execute the partition command.

        :param storage: an instance of the Blivet's storage object
        :param data: an instance of kickstart data
        """
        for partition_data in data.partition.partitions:
            self._execute_partition_data(storage, data, partition_data)

        if data.partition.partitions:
            do_partitioning(storage, boot_disk=storage.bootloader.stage1_disk)
示例#3
0
    def test_explicit_extended_partitions(self):
        """ Verify that explicitly requested extended partitions work. """
        disk = self.blivet.disks[0]
        p1 = self.blivet.new_partition(size=Size("500 MiB"),
                                       part_type=parted.PARTITION_EXTENDED)
        self.blivet.create_device(p1)
        do_partitioning(self.blivet)

        self.assertEqual(p1.parted_partition.type, parted.PARTITION_EXTENDED)
        self.assertEqual(p1.parted_partition, disk.format.extended_partition)

        p2 = self.blivet.new_partition(size=Size("1 GiB"))
        self.blivet.create_device(p2)
        do_partitioning(self.blivet)

        self.assertEqual(p1.parted_partition, disk.format.extended_partition,
                         "user-specified extended partition was removed")

        self.blivet.do_it()
示例#4
0
    def test_explicit_extended_partitions(self):
        """ Verify that explicitly requested extended partitions work. """
        disk = self.blivet.disks[0]
        p1 = self.blivet.new_partition(size=Size("500 MiB"),
                                       part_type=parted.PARTITION_EXTENDED)
        self.blivet.create_device(p1)
        do_partitioning(self.blivet)

        self.assertEqual(p1.parted_partition.type, parted.PARTITION_EXTENDED)
        self.assertEqual(p1.parted_partition, disk.format.extended_partition)

        p2 = self.blivet.new_partition(size=Size("1 GiB"))
        self.blivet.create_device(p2)
        do_partitioning(self.blivet)

        self.assertEqual(p1.parted_partition, disk.format.extended_partition,
                         "user-specified extended partition was removed")

        self.blivet.do_it()
    def _do_autopart(self, storage, scheme, requests, encrypted=False, luks_fmt_args=None):
        """Perform automatic partitioning.

        :param storage: an instance of Blivet
        :param scheme: a type of the partitioning scheme
        :param requests: list of partitioning requests
        :param encrypted: encrypt the scheduled partitions
        :param luks_fmt_args: arguments for the LUKS format constructor
        """
        log.debug("scheme: %s", scheme)
        log.debug("requests:\n%s", "".join([str(p) for p in requests]))
        log.debug("encrypted: %s", encrypted)
        log.debug("storage.disks: %s", [d.name for d in storage.disks])
        log.debug("storage.partitioned: %s", [d.name for d in storage.partitioned if d.format.supported])
        log.debug("all names: %s", [d.name for d in storage.devices])
        log.debug("boot disk: %s", getattr(storage.bootloader.stage1_disk, "name", None))

        if not any(d.format.supported for d in storage.partitioned):
            raise NoDisksError(_("No usable disks selected"))

        disks = get_candidate_disks(storage)
        devs = schedule_implicit_partitions(storage, disks, scheme, encrypted, luks_fmt_args)
        log.debug("candidate disks: %s", disks)
        log.debug("devs: %s", devs)

        if not disks:
            raise NotEnoughFreeSpaceError(_("Not enough free space on disks for "
                                            "automatic partitioning"))

        devs = schedule_partitions(storage, disks, devs, scheme, requests, encrypted, luks_fmt_args)

        # run the autopart function to allocate and grow partitions
        do_partitioning(storage)
        schedule_volumes(storage, devs, scheme, requests, encrypted)

        # grow LVs
        grow_lvm(storage)

        # only newly added swaps should appear in the fstab
        new_swaps = (dev for dev in storage.swaps if not dev.format.exists)
        storage.set_fstab_swaps(new_swaps)
示例#6
0
    def test_implicit_extended_partitions(self):
        """ Verify management of implicitly requested extended partition. """
        # By running partition allocation multiple times with enough partitions
        # to require an extended partition, we exercise the code that manages
        # the implicit extended partition.
        p1 = self.blivet.new_partition(size=Size("100 MiB"))
        self.blivet.create_device(p1)

        p2 = self.blivet.new_partition(size=Size("200 MiB"))
        self.blivet.create_device(p2)

        p3 = self.blivet.new_partition(size=Size("300 MiB"))
        self.blivet.create_device(p3)

        p4 = self.blivet.new_partition(size=Size("400 MiB"))
        self.blivet.create_device(p4)

        do_partitioning(self.blivet)

        # at this point there should be an extended partition
        self.assertIsNotNone(self.blivet.disks[0].format.extended_partition,
                             "no extended partition was created")

        # remove the last partition request and verify that the extended goes away as a result
        self.blivet.destroy_device(p4)
        do_partitioning(self.blivet)
        self.assertIsNone(
            self.blivet.disks[0].format.extended_partition,
            "extended partition was not removed with last logical")

        p5 = self.blivet.new_partition(size=Size("500 MiB"))
        self.blivet.create_device(p5)

        do_partitioning(self.blivet)

        p6 = self.blivet.new_partition(size=Size("450 MiB"))
        self.blivet.create_device(p6)

        do_partitioning(self.blivet)

        self.assertIsNotNone(self.blivet.disks[0].format.extended_partition,
                             "no extended partition was created")

        self.blivet.do_it()
示例#7
0
    def test_implicit_extended_partitions(self):
        """ Verify management of implicitly requested extended partition. """
        # By running partition allocation multiple times with enough partitions
        # to require an extended partition, we exercise the code that manages
        # the implicit extended partition.
        p1 = self.blivet.new_partition(size=Size("100 MiB"))
        self.blivet.create_device(p1)

        p2 = self.blivet.new_partition(size=Size("200 MiB"))
        self.blivet.create_device(p2)

        p3 = self.blivet.new_partition(size=Size("300 MiB"))
        self.blivet.create_device(p3)

        p4 = self.blivet.new_partition(size=Size("400 MiB"))
        self.blivet.create_device(p4)

        do_partitioning(self.blivet)

        # at this point there should be an extended partition
        self.assertIsNotNone(self.blivet.disks[0].format.extended_partition,
                             "no extended partition was created")

        # remove the last partition request and verify that the extended goes away as a result
        self.blivet.destroy_device(p4)
        do_partitioning(self.blivet)
        self.assertIsNone(self.blivet.disks[0].format.extended_partition,
                          "extended partition was not removed with last logical")

        p5 = self.blivet.new_partition(size=Size("500 MiB"))
        self.blivet.create_device(p5)

        do_partitioning(self.blivet)

        p6 = self.blivet.new_partition(size=Size("450 MiB"))
        self.blivet.create_device(p6)

        do_partitioning(self.blivet)

        self.assertIsNotNone(self.blivet.disks[0].format.extended_partition,
                             "no extended partition was created")

        self.blivet.do_it()
示例#8
0
def do_autopart(storage, data, min_luks_entropy=None):
    """ Perform automatic partitioning.

        :param storage: a :class:`pyanaconda.storage.InstallerStorage` instance
        :type storage: :class:`pyanaconda.storage.InstallerStorage`
        :param data: kickstart data
        :type data: :class:`pykickstart.BaseHandler`
        :param min_luks_entropy: minimum entropy in bits required for
                                 luks format creation; uses default when None
        :type min_luks_entropy: int

        :attr:`Blivet.do_autopart` controls whether this method creates the
        automatic partitioning layout. :attr:`Blivet.autopart_type` controls
        which variant of autopart used. It uses one of the pykickstart
        AUTOPART_TYPE_* constants. The set of eligible disks is defined in
        :attr:`StorageDiscoveryConfig.clear_part_disks`.

        .. note::

            Clearing of partitions is handled separately, in
            :meth:`pyanaconda.storage.InstallerStorage.clear_partitions`.
    """
    # pylint: disable=unused-argument
    log.debug("do_autopart: %s", storage.do_autopart)
    log.debug("encrypted_autopart: %s", storage.encrypted_autopart)
    log.debug("autopart_type: %s", storage.autopart_type)
    log.debug("clear_part_type: %s", storage.config.clear_part_type)
    log.debug("clear_part_disks: %s", storage.config.clear_part_disks)
    log.debug("autopart_requests:\n%s",
              "".join([str(p) for p in storage.autopart_requests]))
    log.debug("storage.disks: %s", [d.name for d in storage.disks])
    log.debug("storage.partitioned: %s",
              [d.name for d in storage.partitioned if d.format.supported])
    log.debug("all names: %s", [d.name for d in storage.devices])
    log.debug("boot disk: %s",
              getattr(storage.bootloader.stage1_disk, "name", None))

    if not storage.do_autopart:
        return

    if not any(d.format.supported for d in storage.partitioned):
        raise NoDisksError(_("No usable disks selected"))

    if min_luks_entropy is not None:
        luks_data.min_entropy = min_luks_entropy

    disks = _get_candidate_disks(storage)
    devs = _schedule_implicit_partitions(storage, disks)
    log.debug("candidate disks: %s", disks)
    log.debug("devs: %s", devs)

    if disks == []:
        raise NotEnoughFreeSpaceError(
            _("Not enough free space on disks for "
              "automatic partitioning"))
    devs = _schedule_partitions(storage, disks, devs)

    # run the autopart function to allocate and grow partitions
    do_partitioning(storage)
    _schedule_volumes(storage, devs)

    # grow LVs
    grow_lvm(storage)

    storage.set_up_bootloader()

    # only newly added swaps should appear in the fstab
    new_swaps = (dev for dev in storage.swaps if not dev.format.exists)
    storage.set_fstab_swaps(new_swaps)
示例#9
0
 def realize(self):
     do_partitioning(self._blivet)
     self._blivet.do_it()
示例#10
0
 def realize(self):
     do_partitioning(self._blivet)
     self._blivet.do_it()
示例#11
0
def do_autopart(storage, data, min_luks_entropy=None):
    """ Perform automatic partitioning.

        :param storage: a :class:`pyanaconda.storage.InstallerStorage` instance
        :type storage: :class:`pyanaconda.storage.InstallerStorage`
        :param data: kickstart data
        :type data: :class:`pykickstart.BaseHandler`
        :param min_luks_entropy: minimum entropy in bits required for
                                 luks format creation; uses default when None
        :type min_luks_entropy: int

        :attr:`Blivet.do_autopart` controls whether this method creates the
        automatic partitioning layout. :attr:`Blivet.autopart_type` controls
        which variant of autopart used. It uses one of the pykickstart
        AUTOPART_TYPE_* constants. The set of eligible disks is defined in
        :attr:`StorageDiscoveryConfig.clear_part_disks`.

        .. note::

            Clearing of partitions is handled separately, in
            :meth:`pyanaconda.storage.InstallerStorage.clear_partitions`.
    """
    # pylint: disable=unused-argument
    log.debug("do_autopart: %s", storage.do_autopart)
    log.debug("encrypted_autopart: %s", storage.encrypted_autopart)
    log.debug("autopart_type: %s", storage.autopart_type)
    log.debug("clear_part_type: %s", storage.config.clear_part_type)
    log.debug("clear_part_disks: %s", storage.config.clear_part_disks)
    log.debug("autopart_requests:\n%s", "".join([str(p) for p in storage.autopart_requests]))
    log.debug("storage.disks: %s", [d.name for d in storage.disks])
    log.debug("storage.partitioned: %s", [d.name for d in storage.partitioned if d.format.supported])
    log.debug("all names: %s", [d.name for d in storage.devices])
    log.debug("boot disk: %s", getattr(storage.bootloader.stage1_disk, "name", None))

    if not storage.do_autopart:
        return

    if not any(d.format.supported for d in storage.partitioned):
        raise NoDisksError(_("No usable disks selected"))

    if min_luks_entropy is not None:
        luks_data.min_entropy = min_luks_entropy

    disks = _get_candidate_disks(storage)
    devs = _schedule_implicit_partitions(storage, disks)
    log.debug("candidate disks: %s", disks)
    log.debug("devs: %s", devs)

    if disks == []:
        raise NotEnoughFreeSpaceError(_("Not enough free space on disks for "
                                        "automatic partitioning"))
    devs = _schedule_partitions(storage, disks, devs)

    # run the autopart function to allocate and grow partitions
    do_partitioning(storage)
    _schedule_volumes(storage, devs)

    # grow LVs
    grow_lvm(storage)

    storage.set_up_bootloader()

    # only newly added swaps should appear in the fstab
    new_swaps = (dev for dev in storage.swaps if not dev.format.exists)
    storage.set_fstab_swaps(new_swaps)