mirror of
https://github.com/vale981/dirkules
synced 2025-03-05 09:21:38 -05:00
pools are now created dynamically
This commit is contained in:
parent
44fc32bd4f
commit
c3f8aec018
5 changed files with 19 additions and 22 deletions
|
@ -78,7 +78,6 @@ def get_drives():
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
|
|
||||||
# TODO: not able to remove or update pools
|
|
||||||
def pool_gen():
|
def pool_gen():
|
||||||
part_dict = dict()
|
part_dict = dict()
|
||||||
# creates map uuid is key, partitions are values
|
# creates map uuid is key, partitions are values
|
||||||
|
@ -98,8 +97,8 @@ def pool_gen():
|
||||||
drives = drives + str(Drive.query.get(part.drive_id)) + ","
|
drives = drives + str(Drive.query.get(part.drive_id)) + ","
|
||||||
drives = drives[:-1]
|
drives = drives[:-1]
|
||||||
value = value[0]
|
value = value[0]
|
||||||
existence = db.session.query(db.exists().where(db.and_(Pool.drives == drives, Pool.fs == value.fs))).scalar()
|
Pool.query.delete()
|
||||||
if value.fs == "btrfs" and not existence:
|
if value.fs == "btrfs":
|
||||||
if value.mountpoint:
|
if value.mountpoint:
|
||||||
memory_map = btrfsTools.get_space(value.mountpoint)
|
memory_map = btrfsTools.get_space(value.mountpoint)
|
||||||
raid_map = btrfsTools.get_raid(value.mountpoint)
|
raid_map = btrfsTools.get_raid(value.mountpoint)
|
||||||
|
@ -109,11 +108,10 @@ def pool_gen():
|
||||||
['unbekannt', '1.00', 'unbekannt', '1.00'])))
|
['unbekannt', '1.00', 'unbekannt', '1.00'])))
|
||||||
pool_obj = Pool(value.label, memory_map.get("total"), memory_map.get("free"), raid_map.get("data_raid"),
|
pool_obj = Pool(value.label, memory_map.get("total"), memory_map.get("free"), raid_map.get("data_raid"),
|
||||||
raid_map.get("data_ratio"), raid_map.get("meta_raid"), raid_map.get("meta_ratio"), value.fs,
|
raid_map.get("data_ratio"), raid_map.get("meta_raid"), raid_map.get("meta_ratio"), value.fs,
|
||||||
value.mountpoint, "not implemented", drives)
|
value.mountpoint, "not implemented", drives, get_pool_health(drives))
|
||||||
db.session.add(pool_obj)
|
db.session.add(pool_obj)
|
||||||
db.session.commit()
|
|
||||||
|
|
||||||
if value.fs == "ext4" and not existence:
|
elif value.fs == "ext4":
|
||||||
if value.mountpoint:
|
if value.mountpoint:
|
||||||
free_space = ext4Tools.get_free_space(value.name)
|
free_space = ext4Tools.get_free_space(value.name)
|
||||||
else:
|
else:
|
||||||
|
@ -121,6 +119,13 @@ def pool_gen():
|
||||||
pool_obj = Pool(value.label, value.size, free_space, raid, 1.00, raid, 1.00, value.fs, value.mountpoint,
|
pool_obj = Pool(value.label, value.size, free_space, raid, 1.00, raid, 1.00, value.fs, value.mountpoint,
|
||||||
"not implemented", drives)
|
"not implemented", drives)
|
||||||
db.session.add(pool_obj)
|
db.session.add(pool_obj)
|
||||||
db.session.commit()
|
|
||||||
# TODO: too much commits
|
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
|
|
||||||
|
def get_pool_health(drive_list):
|
||||||
|
drive_split = drive_list.split(",")
|
||||||
|
for drive in drive_split:
|
||||||
|
db_drive = db.session.query(Drive).filter(Drive.name == drive).scalar()
|
||||||
|
if db_drive.smart is not True:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
|
@ -18,15 +18,6 @@ def create_cleaning_obj(jobname, path, active):
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
|
|
||||||
def get_pool_health(drive_list):
|
|
||||||
drive_split = drive_list.split(",")
|
|
||||||
for drive in drive_split:
|
|
||||||
db_drive = db.session.query(Drive).filter(Drive.name == drive).scalar()
|
|
||||||
if db_drive.smart is not True:
|
|
||||||
return False
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
def get_empty_drives():
|
def get_empty_drives():
|
||||||
drives = Drive.query.all()
|
drives = Drive.query.all()
|
||||||
choices = list()
|
choices = list()
|
||||||
|
|
|
@ -81,9 +81,10 @@ class Pool(db.Model):
|
||||||
mountpoint = db.Column(db.String)
|
mountpoint = db.Column(db.String)
|
||||||
mountopt = db.Column(db.String)
|
mountopt = db.Column(db.String)
|
||||||
drives = db.Column(db.String)
|
drives = db.Column(db.String)
|
||||||
|
healthy = db.Column(db.Boolean)
|
||||||
|
|
||||||
def __init__(self, label, size, free, data_raid, data_ratio, meta_raid, meta_ratio, fs, mountpoint, mountopt,
|
def __init__(self, label, size, free, data_raid, data_ratio, meta_raid, meta_ratio, fs, mountpoint, mountopt,
|
||||||
drives):
|
drives, healthy):
|
||||||
self.label = label
|
self.label = label
|
||||||
self.size = size
|
self.size = size
|
||||||
self.free = free
|
self.free = free
|
||||||
|
@ -95,6 +96,7 @@ class Pool(db.Model):
|
||||||
self.mountpoint = mountpoint
|
self.mountpoint = mountpoint
|
||||||
self.mountopt = mountopt
|
self.mountopt = mountopt
|
||||||
self.drives = drives
|
self.drives = drives
|
||||||
|
self.healthy = healthy
|
||||||
|
|
||||||
|
|
||||||
class Time(db.Model):
|
class Time(db.Model):
|
||||||
|
|
|
@ -81,7 +81,7 @@
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Gesundheit</td>
|
<td>Gesundheit</td>
|
||||||
{% if health %}
|
{% if pool.healthy %}
|
||||||
<td class="positive"><i class="icon checkmark"></i>Gesund</td>
|
<td class="positive"><i class="icon checkmark"></i>Gesund</td>
|
||||||
{% else %}
|
{% else %}
|
||||||
<td class="negative"><i class="attention icon"></i>Kritisch</td>
|
<td class="negative"><i class="attention icon"></i>Kritisch</td>
|
||||||
|
@ -105,7 +105,7 @@
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if health %}
|
{% if pool.healthy %}
|
||||||
<div class="ui positive message">
|
<div class="ui positive message">
|
||||||
<i class="close icon"></i>
|
<i class="close icon"></i>
|
||||||
<div class="header">
|
<div class="header">
|
||||||
|
|
|
@ -41,8 +41,7 @@ def pool(pool):
|
||||||
db_pool = Pool.query.get(pool)
|
db_pool = Pool.query.get(pool)
|
||||||
if db_pool is None:
|
if db_pool is None:
|
||||||
abort(404, description="Pool with ID {} could not be found.".format(pool))
|
abort(404, description="Pool with ID {} could not be found.".format(pool))
|
||||||
pool_health = viewManager.get_pool_health(db_pool.drives)
|
return render_template('pool.html', pool=db_pool)
|
||||||
return render_template('pool.html', pool=db_pool, health=pool_health)
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/pools/add', methods=['GET', 'POST'])
|
@app.route('/pools/add', methods=['GET', 'POST'])
|
||||||
|
|
Loading…
Add table
Reference in a new issue