mirror of https://git.48k.eu/ogcp
Add legacy log
Future patches will deprecate this log functionality in favour of more robust solutions.multi-ogserver
parent
c493d24349
commit
20a94dbc3e
|
@ -0,0 +1,10 @@
|
|||
{% extends 'base.html' %}
|
||||
{% import "bootstrap/wtf.html" as wtf %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<h1 class="m-5">{{_('Client log')}}</h1>
|
||||
|
||||
<pre>{{ log }}</pre>
|
||||
|
||||
{% endblock %}
|
|
@ -40,5 +40,7 @@
|
|||
form="scopesForm" formaction="{{ url_for('action_image_create') }}" formmethod="get">
|
||||
<input class="btn btn-light" type="submit" value="{{ _('Set boot mode') }}"
|
||||
form="scopesForm" formaction="{{ url_for('action_mode') }}" formmethod="get">
|
||||
<input class="btn btn-light" type="submit" value="{{ _('Log') }}"
|
||||
form="scopesForm" formaction="{{ url_for('action_legacy_log') }}" formmethod="get">
|
||||
{% endblock %}
|
||||
|
||||
|
|
|
@ -19,6 +19,8 @@ from flask_login import (
|
|||
login_required
|
||||
)
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from ogcp.models import User
|
||||
from ogcp.forms.auth import LoginForm
|
||||
from ogcp.og_server import OGServer
|
||||
|
@ -832,3 +834,17 @@ def action_image_delete():
|
|||
flash(_('Delete client request processed successfully'), category='info')
|
||||
return redirect(url_for('images'))
|
||||
|
||||
@app.route('/action/log', methods=['GET'])
|
||||
@login_required
|
||||
def action_legacy_log():
|
||||
ips = parse_elements(request.args.to_dict())
|
||||
if not validate_elements(ips, max_len=1):
|
||||
return redirect(url_for('commands'))
|
||||
ip = ips.pop()
|
||||
log_file = Path("/opt/opengnsys/log/clients/" + str(ip) + ".log")
|
||||
log = log_file.read_text()
|
||||
if log:
|
||||
return render_template('actions/legacy/log.html', log=log)
|
||||
else:
|
||||
return redirect(url_for('commands'))
|
||||
|
||||
|
|
Loading…
Reference in New Issue