def setUp(self):
        if self.device_type is None:
            raise unittest.SkipTest("abstract base class")

        self.b = blivet.Blivet()  # don't populate it
        self.disk_files = [create_sparse_tempfile("factorytest", Size("1 GiB")),
                           create_sparse_tempfile("factorytest", Size("1 GiB"))]
        for filename in self.disk_files:
            disk = DiskFile(filename)
            self.b.devicetree._add_device(disk)
            self.b.initialize_disk(disk)

        self.addCleanup(self._clean_up_disk_files)
    def setUp(self):
        self.addCleanup(self._clean_up)
        self.disk1_file = create_sparse_tempfile("disk1", Size("2GiB"))
        self.plugins = blockdev.plugin_specs_from_names(blockdev.get_available_plugin_names())  # pylint: disable=no-value-for-parameter

        loaded_plugins = self.load_all_plugins()
        if not all(p in loaded_plugins for p in ("btrfs", "crypto", "lvm", "md")):
            # we don't have all plugins needed for this test case
            self.skipTest("Missing libblockdev plugins needed from weak dependencies test.")
    def set_up_disks(self):
        """ Create disk image files to build the test's storage on.

            If you are actually creating the disk image files here don't forget
            to set the initialize_disks flag so they get a fresh disklabel when
            clear_partitions gets called from create_storage later.
        """
        for (name, size) in iter(self.disks.items()):
            path = util.create_sparse_tempfile(name, size)
            self.blivet.disk_images[name] = path

        #
        # set up the disk images with a disklabel
        #
        self.blivet.config.initialize_disks = self.initialize_disks
Beispiel #4
0
    def setUp(self):
        self.storage = InstallerStorage()

        # anaconda first configures disk images
        for (name, size) in iter(self.disks.items()):
            path = util.create_sparse_tempfile(name, size)
            self.storage.disk_images[name] = path

        # at this point the DMLinearDevice has correct size
        self.storage.setup_disk_images()

        # anaconda calls initialize_storage regardless of whether or not
        # this is an image install. Somewhere along the line this will
        # execute setup_disk_images() once more and the DMLinearDevice created
        # in this second execution has size 0
        with patch('blivet.flags'):
            reset_storage(self.storage)
Beispiel #5
0
    def setUp(self):
        self.blivet = Blivet()

        # anaconda first configures disk images
        for (name, size) in iter(self.disks.items()):
            path = util.create_sparse_tempfile(name, size)
            self.blivet.disk_images[name] = path

        # at this point the DMLinearDevice has correct size
        self.blivet.setup_disk_images()

        # emulates setting the anaconda flags which later update
        # blivet flags as the first thing to do in storage_initialize
        flags.image_install = True
        # no kickstart available
        ksdata = kickstart.AnacondaKSHandler([])
        # anaconda calls storage_initialize regardless of whether or not
        # this is an image install. Somewhere along the line this will
        # execute setup_disk_images() once more and the DMLinearDevice created
        # in this second execution has size 0
        storage_initialize(self.blivet, ksdata, [])
Beispiel #6
0
import os

from common import print_devices

import blivet
from blivet.size import Size
from blivet.util import set_up_logging, create_sparse_tempfile

set_up_logging()
b = blivet.Blivet()   # create an instance of Blivet (don't add system devices)

# create a disk image file on which to create new devices
disk1_file = create_sparse_tempfile("disk1", Size("100GiB"))
b.config.diskImages["disk1"] = disk1_file

b.reset()

try:
    disk1 = b.devicetree.getDeviceByName("disk1")

    b.initializeDisk(disk1)

    pv = b.newPartition(size=Size("50GiB"), fmt_type="lvmpv")
    b.createDevice(pv)

    # allocate the partitions (decide where and on which disks they'll reside)
    blivet.partitioning.doPartitioning(b)

    vg = b.newVG(parents=[pv])
    b.createDevice(vg)
Beispiel #7
0
import os

import blivet
from blivet.size import Size
from blivet.util import set_up_logging, create_sparse_tempfile

set_up_logging()
b = blivet.Blivet()  # create an instance of Blivet (don't add system devices)

# create two disk image files on which to create new devices
disk1_file = create_sparse_tempfile("disk1", Size("100GiB"))
b.config.disk_images["disk1"] = disk1_file
disk2_file = create_sparse_tempfile("disk2", Size("100GiB"))
b.config.disk_images["disk2"] = disk2_file

b.reset()

try:
    disk1 = b.devicetree.get_device_by_name("disk1")
    disk2 = b.devicetree.get_device_by_name("disk2")
    disk1.format = blivet.formats.get_format("disklabel", device=disk1.path)
    disk2.format = blivet.formats.get_format("disklabel", device=disk2.path)

    # create an lv named data in a vg named testvg
    device = b.factory_device(blivet.devicefactory.DEVICE_TYPE_LVM,
                              Size("50GiB"),
                              disks=[disk1, disk2],
                              fstype="xfs",
                              mountpoint="/data")
    print(b.devicetree)