everything ready for pool creation testing

This commit is contained in:
Daniel 2019-09-15 14:19:35 +02:00
parent 2d378d5d6c
commit f1b03ad151
3 changed files with 49 additions and 8 deletions

View file

@ -62,5 +62,15 @@ def get_raid(label):
return raid_map
def create_pool():
pass
def create_pool(label, drives, raid, mount_options):
btrfs_drives = ""
for d in drives:
drive_name = "/dev/" + d.name
# stderr and stdout not captured
subprocess.run(["sgdisk", "-Z", drive_name], shell=False, timeout=20, check=True)
subprocess.run(["wipefs", "-a", drive_name], shell=False, timeout=20, check=True)
subprocess.run(["sgdisk", "-o", drive_name], shell=False, timeout=20, check=True)
subprocess.run(["sgdisk", "-N", 1, drive_name], shell=False, timeout=20, check=True)
btrfs_drives = btrfs_drives + drive_name + " "
subprocess.run(["mkfs.btrfs", "-f", "-L", label, "-d", raid, btrfs_drives], shell=False, timeout=20, check=True)

View file

@ -50,19 +50,50 @@ def is_system_drive(drive):
return True
return False
def create_btrfs_pool(form):
label = form.name.data
label = str(form.name.data)
drives = list()
str_drives = form.drives.data.split(",")
for d in str_drives:
drives.append(Drive.query.filter(Drive.name == d).scalar())
if int(form.raid_config.data) == 1:
raid = "single"
elif int(form.raid_config.data) == 2:
raid = "raid0"
elif int(form.raid_config.data) == 3:
raid = "raid1"
drives = form.drives.data.split(",")
# if only one drive has been selected: always use single
if len(drives) == 1:
raid = "single"
mount_options = ["defaults"]
if bool(form.inode_cache.data):
mount_options.append("inode_cache")
if int(form.space_cache.data) == 2:
mount_options.append("space_cache=v1")
elif int(form.space_cache.data) == 3:
mount_options.append("space_cache=v2")
mount_options.append("space_cache=v2")
if int(form.compression.data) == 2:
mount_options.append("compress=zlib")
elif int(form.compression.data) == 3:
mount_options.append("compress=lzo")
if pure_ssd(drives) and not pure_hdd(drives):
mount_options.append("ssd")
elif pure_hdd(drives) and not pure_ssd(drives):
mount_options.append("autodefrag")
# now we are ready to create the pool.
# Warning: drives contains objects, not names!! Use drive.name
def pure_ssd(drives):
for d in drives:
if d.rota or d.hotplug:
return False
return True
def pure_hdd(drives):
for d in drives:
if not d.rota or d.hotplug:
return False
return True

View file

@ -43,9 +43,9 @@
<h4 class="ui dividing header">Kompression</h4>
<div class="ui message">
<div class="header">Hinweis</div>
<p>"zlib" ist stabiler und ab <i>btrfs-progs 0.19</i> verfügbar.<br>"lzo" ist schneller und leicht
höhere Kompression auf, ist jedoch erst ab Kernel Version 3.x verfügbar. Es kann jedoch zum
einfrieren des Systems führen.</p>
<p>ZLIB - langsam, stabil, hohe Kompression<br>
LZO - schnelle Kompression, schlechteres Kompressionsverhältnis als ZLIB
</p>
</div>
<div class="inline fields">
{{ render_field(form.compression) }}