Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions resallocserver/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@ def run(self):


class Pool(object):
description = None
max = 4
max_starting = 1
max_prealloc = 2
Expand Down
24 changes: 23 additions & 1 deletion resallocwebui/app.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import os
import yaml
from flask import Flask, render_template
from resallocserver.app import session_scope
from resallocserver.logic import QResources
Expand All @@ -11,6 +11,20 @@
app.static_folder = staticdir


def load_config():
"""
A simpler version of `manager.py:reload_config`.
The `reload_config` function does some logging which causes permission
errors, it is misleading because it logs as the manager, etc.
"""
try:
config_file = "/etc/resallocserver/pools.yaml"
with open(config_file, "r", encoding="utf-8") as fp:
return yaml.safe_load(fp)
except OSError:
return {}


@app.route("/")
def home():
return render_template("home.html", resources=resources)
Expand All @@ -37,12 +51,20 @@ def pools():
# e.g. result["copr_hv_x86_64_01_prod"]["STARTING"]
result = {}

pools_from_config = load_config()

# Prepare the two-dimensional array, and fill it with zeros
with session_scope() as session:
for pool in session.query(models.Pool).all():
result[pool.name] = dict.fromkeys(columns, 0)
result[pool.name]["MAX"] = pool.max

if pool.name not in pools_from_config:
continue

result[pool.name]["DESCRIPTION"] =\
pools_from_config[pool.name].get("description")

with session_scope() as session:
# Iterate over running resources and calculate how many is starting,
# deleting, etc.
Expand Down
2 changes: 2 additions & 0 deletions resallocwebui/templates/pools.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ <h1 class="resource--title">Resalloc pools</h1>
<thead class="thead-dark">
<tr>
<th scope="col">Pool</th>
<th scope="col">Description</th>
<th scope="col">Max</th>
<th scope="col">Up</th>
<th scope="col">Ready</th>
Expand All @@ -25,6 +26,7 @@ <h1 class="resource--title">Resalloc pools</h1>
{% for pool, info in information.items()|sort(attribute='0') %}
<tr>
<th scope="row">{{ pool }}</th>
<td class="col-sm-4">{{ info['DESCRIPTION'] |default(omit, True) }}</td>
<td>{{ info['MAX'] }}</td>
<td>{{ info['UP'] }}</td>
<td>{{ info['READY'] }}</td>
Expand Down
Loading