From 20a94dbc3e3e6e36655982a5569a6d7e4d0abedd Mon Sep 17 00:00:00 2001 From: Javier Sánchez Parra Date: Thu, 21 Oct 2021 13:06:06 +0200 Subject: Add legacy log Future patches will deprecate this log functionality in favour of more robust solutions. --- ogcp/templates/actions/legacy/log.html | 10 ++++++++++ ogcp/templates/commands.html | 2 ++ ogcp/views.py | 16 ++++++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 ogcp/templates/actions/legacy/log.html (limited to 'ogcp') diff --git a/ogcp/templates/actions/legacy/log.html b/ogcp/templates/actions/legacy/log.html new file mode 100644 index 0000000..08d3328 --- /dev/null +++ b/ogcp/templates/actions/legacy/log.html @@ -0,0 +1,10 @@ +{% extends 'base.html' %} +{% import "bootstrap/wtf.html" as wtf %} + +{% block content %} + +

{{_('Client log')}}

+ +
{{ log }}
+ +{% endblock %} diff --git a/ogcp/templates/commands.html b/ogcp/templates/commands.html index 1e7dc84..b965867 100644 --- a/ogcp/templates/commands.html +++ b/ogcp/templates/commands.html @@ -40,5 +40,7 @@ form="scopesForm" formaction="{{ url_for('action_image_create') }}" formmethod="get"> + {% endblock %} diff --git a/ogcp/views.py b/ogcp/views.py index 77e63ac..525532f 100644 --- a/ogcp/views.py +++ b/ogcp/views.py @@ -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')) + -- cgit v1.2.3-18-g5258