Blame tests/lvm_factory.py
|
|
29a940 |
#!/usr/bin/python3
|
|
|
29a940 |
|
|
|
29a940 |
import argparse
|
|
|
29a940 |
import sys
|
|
|
29a940 |
|
|
|
29a940 |
import blivet
|
|
|
29a940 |
|
|
|
29a940 |
|
|
|
29a940 |
POOL_NAME = "blivet_test"
|
|
|
29a940 |
|
|
|
29a940 |
parser = argparse.ArgumentParser()
|
|
|
29a940 |
parser.add_argument('-d', '--disks', default='')
|
|
|
29a940 |
args = parser.parse_args()
|
|
|
29a940 |
|
|
|
29a940 |
b = blivet.Blivet()
|
|
|
29a940 |
b.reset()
|
|
|
29a940 |
|
|
|
29a940 |
disks = list()
|
|
|
29a940 |
for disk_id in args.disks.split(','):
|
|
|
29a940 |
disk = b.devicetree.resolve_device(disk_id)
|
|
|
29a940 |
if not disk.is_disk:
|
|
|
29a940 |
sys.stderr.write("specified disk '%s' is not a disk\n" % disk_id)
|
|
|
29a940 |
sys.exit(1)
|
|
|
29a940 |
|
|
|
29a940 |
disks.append(disk)
|
|
|
29a940 |
b.initialize_disk(disk)
|
|
|
29a940 |
|
|
|
29a940 |
if len(disks) > 1:
|
|
|
29a940 |
container_raid_level = "raid1"
|
|
|
29a940 |
total_size = min(d.size for d in disks)
|
|
|
29a940 |
else:
|
|
|
29a940 |
container_raid_level = None
|
|
|
29a940 |
total_size = sum(d.size for d in disks)
|
|
|
29a940 |
|
|
|
29a940 |
lv1 = b.factory_device(size=total_size*0.8, disks=disks,
|
|
|
29a940 |
name="lv1", container_name=POOL_NAME,
|
|
|
29a940 |
fstype='xfs', device_type=blivet.devicefactory.DEVICE_TYPE_LVM)
|
|
|
29a940 |
lv2 = b.factory_device(disks=disks, name="lv2",
|
|
|
29a940 |
container_name=POOL_NAME, container_raid_level='raid1',
|
|
|
29a940 |
fstype='ext4', device_type=blivet.devicefactory.DEVICE_TYPE_LVM)
|
|
|
29a940 |
|
|
|
29a940 |
b.do_it()
|