mirror of https://git.48k.eu/ogcp
Add session action
This action provides the functionality to run one of the installed OSs in a client.multi-ogserver
parent
e978c30b9f
commit
c5a4ccff55
|
@ -1,6 +1,6 @@
|
|||
from wtforms import (
|
||||
Form, SubmitField, HiddenField, SelectField, BooleanField, IntegerField,
|
||||
StringField
|
||||
StringField, RadioField
|
||||
)
|
||||
from flask_wtf import FlaskForm
|
||||
from flask_babel import _
|
||||
|
@ -33,6 +33,11 @@ class HardwareForm(FlaskForm):
|
|||
ips = HiddenField()
|
||||
refresh = SubmitField(label=_('Refresh'))
|
||||
|
||||
class SessionForm(FlaskForm):
|
||||
ips = HiddenField()
|
||||
os = RadioField(label=_('Session'), choices=[])
|
||||
run = SubmitField(label=_('Run'))
|
||||
|
||||
class ClientDetailsForm(FlaskForm):
|
||||
name = StringField(label=_('Name'))
|
||||
ip = StringField(label=_('IP'))
|
||||
|
|
|
@ -42,6 +42,8 @@
|
|||
formaction="{{ url_for('action_refresh') }}" formmethod="post">
|
||||
<input class="dropdown-item" type="submit" value="{{ _('Hardware') }}"
|
||||
formaction="{{ url_for('action_hardware') }}" formmethod="get">
|
||||
<input class="dropdown-item" type="submit" value="{{ _('Sessions') }}"
|
||||
formaction="{{ url_for('action_session') }}" formmethod="get">
|
||||
<input class="dropdown-item" type="submit" value="{{ _('Setup') }}"
|
||||
formaction="{{ url_for('action_setup_show') }}" formmethod="get">
|
||||
<input class="dropdown-item" type="submit" value="{{ _('Details') }}"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from flask import g, render_template, url_for, request, jsonify, make_response
|
||||
from ogcp.forms.action_forms import (
|
||||
WOLForm, PartitionForm, ClientDetailsForm, HardwareForm
|
||||
WOLForm, PartitionForm, ClientDetailsForm, HardwareForm, SessionForm
|
||||
)
|
||||
from ogcp.og_server import OGServer
|
||||
from flask_babel import _
|
||||
|
@ -214,6 +214,29 @@ def action_hardware():
|
|||
return render_template('actions/hardware.html', form=form,
|
||||
hardware=hardware)
|
||||
|
||||
@app.route('/action/session', methods=['GET', 'POST'])
|
||||
def action_session():
|
||||
form = SessionForm(request.form)
|
||||
if request.method == 'POST':
|
||||
ips = form.ips.data.split(' ')
|
||||
disk, partition = form.os.data.split(' ')
|
||||
r = g.server.post('/session', payload={'clients': ips,
|
||||
'disk': str(disk),
|
||||
'partition': str(partition)})
|
||||
if r.status_code == requests.codes.ok:
|
||||
return make_response("200 OK", 200)
|
||||
return make_response("400 Bad Request", 400)
|
||||
else:
|
||||
ips = parse_ips(request.args.to_dict())
|
||||
form.ips.data = ' '.join(ips)
|
||||
r = g.server.get('/session', payload={'client': list(ips)})
|
||||
sessions = r.json()['sessions']
|
||||
for os in sessions:
|
||||
choice = (f"{os['disk']} {os['partition']}",
|
||||
f"{os['name']} ({os['disk']},{os['partition']})")
|
||||
form.os.choices.append(choice)
|
||||
return render_template('actions/session.html', form=form)
|
||||
|
||||
@app.route('/action/client/info', methods=['GET'])
|
||||
def action_client_info():
|
||||
form = ClientDetailsForm()
|
||||
|
|
Loading…
Reference in New Issue