mirror of
https://github.com/ComputerScienceHouse/proxstar.git
synced 2025-03-09 15:40:09 +00:00
add rq dashboard for RTPs
This commit is contained in:
parent
786fd8ee2d
commit
635e4c0f9f
4 changed files with 28 additions and 3 deletions
|
@ -4,6 +4,7 @@ import psutil
|
||||||
import atexit
|
import atexit
|
||||||
import psycopg2
|
import psycopg2
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import rq_dashboard
|
||||||
from rq import Queue
|
from rq import Queue
|
||||||
from redis import Redis
|
from redis import Redis
|
||||||
from rq_scheduler import Scheduler
|
from rq_scheduler import Scheduler
|
||||||
|
@ -20,6 +21,7 @@ from proxstar.ldapdb import *
|
||||||
from proxstar.proxmox import *
|
from proxstar.proxmox import *
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
app.config.from_object(rq_dashboard.default_settings)
|
||||||
if os.path.exists(
|
if os.path.exists(
|
||||||
os.path.join(
|
os.path.join(
|
||||||
app.config.get('ROOT_DIR', os.getcwd()), "config.local.py")):
|
app.config.get('ROOT_DIR', os.getcwd()), "config.local.py")):
|
||||||
|
@ -84,6 +86,19 @@ if 'cleanup_vnc' not in scheduler:
|
||||||
interval=3600)
|
interval=3600)
|
||||||
|
|
||||||
|
|
||||||
|
def add_rq_dashboard_auth(blueprint):
|
||||||
|
@blueprint.before_request
|
||||||
|
@auth.oidc_auth
|
||||||
|
def rq_dashboard_auth(*args, **kwargs):
|
||||||
|
if 'rtp' not in session['userinfo']['groups']:
|
||||||
|
return '', 403
|
||||||
|
|
||||||
|
|
||||||
|
rq_dashboard_blueprint = rq_dashboard.blueprint
|
||||||
|
add_rq_dashboard_auth(rq_dashboard_blueprint)
|
||||||
|
app.register_blueprint(rq_dashboard_blueprint, url_prefix="/rq")
|
||||||
|
|
||||||
|
|
||||||
@app.route("/")
|
@app.route("/")
|
||||||
@app.route("/user/<string:user_view>")
|
@app.route("/user/<string:user_view>")
|
||||||
@auth.oidc_auth
|
@auth.oidc_auth
|
||||||
|
@ -97,7 +112,8 @@ def list_vms(user_view=None):
|
||||||
user_view = User(user_view)
|
user_view = User(user_view)
|
||||||
vms = user_view.vms
|
vms = user_view.vms
|
||||||
for pending_vm in user_view.pending_vms:
|
for pending_vm in user_view.pending_vms:
|
||||||
vm = next((vm for vm in vms if vm['name'] == pending_vm['name']), None)
|
vm = next((vm for vm in vms if vm['name'] == pending_vm['name']),
|
||||||
|
None)
|
||||||
if vm:
|
if vm:
|
||||||
vms[vms.index(vm)]['status'] = pending_vm['status']
|
vms[vms.index(vm)]['status'] = pending_vm['status']
|
||||||
vms[vms.index(vm)]['pending'] = True
|
vms[vms.index(vm)]['pending'] = True
|
||||||
|
@ -111,7 +127,8 @@ def list_vms(user_view=None):
|
||||||
if user.active:
|
if user.active:
|
||||||
vms = user.vms
|
vms = user.vms
|
||||||
for pending_vm in user.pending_vms:
|
for pending_vm in user.pending_vms:
|
||||||
vm = next((vm for vm in vms if vm['name'] == pending_vm['name']), None)
|
vm = next((vm for vm in vms
|
||||||
|
if vm['name'] == pending_vm['name']), None)
|
||||||
if vm:
|
if vm:
|
||||||
vms[vms.index(vm)]['status'] = pending_vm['status']
|
vms[vms.index(vm)]['status'] = pending_vm['status']
|
||||||
vms[vms.index(vm)]['pending'] = True
|
vms[vms.index(vm)]['pending'] = True
|
||||||
|
|
|
@ -41,6 +41,12 @@
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{% if user.rtp %}
|
{% if user.rtp %}
|
||||||
|
<li>
|
||||||
|
<a href="/rq">
|
||||||
|
<span class="glyphicon glyphicon-eye-open"></span>
|
||||||
|
RQ Dashboard
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="/settings">
|
<a href="/settings">
|
||||||
<span class="glyphicon glyphicon-cog"></span>
|
<span class="glyphicon glyphicon-cog"></span>
|
||||||
|
|
|
@ -33,7 +33,8 @@ class User(object):
|
||||||
|
|
||||||
@lazy_property
|
@lazy_property
|
||||||
def pending_vms(self):
|
def pending_vms(self):
|
||||||
jobs = StartedJobRegistry('default', connection=redis_conn).get_job_ids()
|
jobs = StartedJobRegistry(
|
||||||
|
'default', connection=redis_conn).get_job_ids()
|
||||||
for job_id in q.job_ids:
|
for job_id in q.job_ids:
|
||||||
jobs.append(job_id)
|
jobs.append(job_id)
|
||||||
pending_vms = []
|
pending_vms = []
|
||||||
|
|
|
@ -14,3 +14,4 @@ websockify
|
||||||
sshtunnel
|
sshtunnel
|
||||||
psutil
|
psutil
|
||||||
requests
|
requests
|
||||||
|
rq_dashboard
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue