mirror of
https://github.com/vale981/dirkules
synced 2025-03-05 09:21:38 -05:00
pool is now critical if drives are absent
This commit is contained in:
parent
0534b387a5
commit
cbb4b0ea97
3 changed files with 51 additions and 16 deletions
|
@ -80,6 +80,7 @@ def get_drives():
|
|||
|
||||
def pool_gen():
|
||||
part_dict = dict()
|
||||
Pool.query.delete()
|
||||
# creates map uuid is key, partitions are values
|
||||
for part in Partitions.query.all():
|
||||
if part.uuid in part_dict:
|
||||
|
@ -97,7 +98,9 @@ def pool_gen():
|
|||
drives = drives + str(Drive.query.get(part.drive_id)) + ","
|
||||
drives = drives[:-1]
|
||||
value = value[0]
|
||||
Pool.query.delete()
|
||||
missing = absent_drive(drives)
|
||||
if missing is not None:
|
||||
missing = ",".join(str(x.name) for x in missing)
|
||||
if value.fs == "btrfs":
|
||||
if value.mountpoint:
|
||||
memory_map = btrfsTools.get_space(value.mountpoint)
|
||||
|
@ -108,7 +111,7 @@ def pool_gen():
|
|||
['unbekannt', '1.00', 'unbekannt', '1.00'])))
|
||||
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,
|
||||
value.mountpoint, "not implemented", drives, get_pool_health(drives))
|
||||
value.mountpoint, "not implemented", drives, get_pool_health(drives), missing)
|
||||
db.session.add(pool_obj)
|
||||
|
||||
elif value.fs == "ext4":
|
||||
|
@ -117,7 +120,7 @@ def pool_gen():
|
|||
else:
|
||||
free_space = 2
|
||||
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, get_pool_health(drives), missing)
|
||||
db.session.add(pool_obj)
|
||||
db.session.commit()
|
||||
|
||||
|
@ -137,6 +140,23 @@ def get_pool_health(drive_list):
|
|||
return True
|
||||
|
||||
|
||||
def absent_drive(drive_list):
|
||||
"""
|
||||
:param drive_list: contains drives which belongs to pool
|
||||
:return: List of absent drives or None
|
||||
"""
|
||||
missing = 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.missing:
|
||||
missing.append(db_drive)
|
||||
if not missing:
|
||||
return None
|
||||
else:
|
||||
return missing
|
||||
|
||||
|
||||
def delete_drive(drive):
|
||||
"""
|
||||
removes a given drive object (including cascades) from db
|
||||
|
|
|
@ -78,9 +78,10 @@ class Pool(db.Model):
|
|||
mountopt = db.Column(db.String)
|
||||
drives = db.Column(db.String)
|
||||
healthy = db.Column(db.Boolean)
|
||||
missing = db.Column(db.String)
|
||||
|
||||
def __init__(self, label, size, free, data_raid, data_ratio, meta_raid, meta_ratio, fs, mountpoint, mountopt,
|
||||
drives, healthy):
|
||||
drives, healthy, missing):
|
||||
self.label = label
|
||||
self.size = size
|
||||
self.free = free
|
||||
|
@ -93,6 +94,7 @@ class Pool(db.Model):
|
|||
self.mountopt = mountopt
|
||||
self.drives = drives
|
||||
self.healthy = healthy
|
||||
self.missing = missing
|
||||
|
||||
|
||||
class Time(db.Model):
|
||||
|
|
|
@ -81,7 +81,7 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<td>Gesundheit</td>
|
||||
{% if pool.healthy %}
|
||||
{% if pool.healthy and pool.missing is none %}
|
||||
<td class="positive"><i class="icon checkmark"></i>Gesund</td>
|
||||
{% else %}
|
||||
<td class="negative"><i class="attention icon"></i>Kritisch</td>
|
||||
|
@ -99,13 +99,14 @@
|
|||
</div>
|
||||
<p>
|
||||
Die RAID Level von Data und Metadata unterscheiden sich. Normalerweise sollten beide gleich
|
||||
konfiguriert werden, da es sonst unter Umständen zu <b>Datenverlust</b> kommen kann, wenn ein
|
||||
konfiguriert werden, da es sonst unter Umständen zu <b>Datenverlust</b> kommen kann, wenn
|
||||
ein
|
||||
Laufwerk ausfällt.<br>
|
||||
Solltest du einen guten Grund dafür haben, ignoriere einfach diese Meldung.
|
||||
</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if pool.healthy %}
|
||||
{% if pool.healthy and pool.missing is none %}
|
||||
<div class="ui positive message">
|
||||
<i class="close icon"></i>
|
||||
<div class="header">
|
||||
|
@ -116,6 +117,7 @@
|
|||
</p>
|
||||
</div>
|
||||
{% else %}
|
||||
{% if not pool.healthy %}
|
||||
<div class="ui negative message">
|
||||
<i class="close icon"></i>
|
||||
<div class="header">
|
||||
|
@ -126,6 +128,17 @@
|
|||
dieses schnellstmöglich tauschen.
|
||||
</p>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="ui negative message">
|
||||
<i class="close icon"></i>
|
||||
<div class="header">
|
||||
Kritischer Zustand
|
||||
</div>
|
||||
<p>
|
||||
Folgende Laufwerke wurden nicht gefunden: {{ pool.missing }}
|
||||
</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Reference in a new issue