Ejemplo n.º 1
0
import os

import blivet
from blivet.size import Size
from blivet.util import set_up_logging, create_sparse_tempfile
from blivet.devices.lvm import LVMCacheRequest

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.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")

    b.initialize_disk(disk1)
    b.initialize_disk(disk2)

    pv = b.new_partition(size=Size("50GiB"), fmt_type="lvmpv", parents=[disk1])
    b.create_device(pv)
    pv2 = b.new_partition(size=Size("50GiB"),
                          fmt_type="lvmpv",
                          parents=[disk2])
    b.create_device(pv2)
Ejemplo n.º 2
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)
Ejemplo n.º 3
0
import time

import blivet
from blivet.events.manager import event_manager
from blivet.util import set_up_logging


def print_changes(event, changes):
    print("***", event)
    for change in changes:
        print("***", change)
    print("***")
    print()


set_up_logging(console_logs=["blivet.event"])
b = blivet.Blivet()  # create an instance of Blivet
b.reset()  # detect system storage configuration
print(b.devicetree)

event_manager.notify_cb = print_changes
event_manager.enable()

while True:
    time.sleep(0.5)