diff --git a/resallocserver/manager.py b/resallocserver/manager.py index 353d650..3e6fa1f 100644 --- a/resallocserver/manager.py +++ b/resallocserver/manager.py @@ -465,6 +465,7 @@ def run(self): class Pool(object): + description = None max = 4 max_starting = 1 max_prealloc = 2 diff --git a/resallocwebui/app.py b/resallocwebui/app.py index b025318..388b1f5 100644 --- a/resallocwebui/app.py +++ b/resallocwebui/app.py @@ -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 @@ -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) @@ -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. diff --git a/resallocwebui/templates/pools.html b/resallocwebui/templates/pools.html index b03235b..6c2d333 100644 --- a/resallocwebui/templates/pools.html +++ b/resallocwebui/templates/pools.html @@ -12,6 +12,7 @@

Resalloc pools

Pool + Description Max Up Ready @@ -25,6 +26,7 @@

Resalloc pools

{% for pool, info in information.items()|sort(attribute='0') %} {{ pool }} + {{ info['DESCRIPTION'] |default(omit, True) }} {{ info['MAX'] }} {{ info['UP'] }} {{ info['READY'] }}