mirror of https://git.48k.eu/ogcp
Add client hardware action
This action lists all the hardware items in a client.multi-ogserver
parent
93ffa115fe
commit
e978c30b9f
|
@ -29,6 +29,10 @@ class PartitionForm(FlaskForm):
|
|||
modify = SubmitField(label=_('Modify'))
|
||||
delete = SubmitField(label=_('Delete'))
|
||||
|
||||
class HardwareForm(FlaskForm):
|
||||
ips = HiddenField()
|
||||
refresh = SubmitField(label=_('Refresh'))
|
||||
|
||||
class ClientDetailsForm(FlaskForm):
|
||||
name = StringField(label=_('Name'))
|
||||
ip = StringField(label=_('IP'))
|
||||
|
|
|
@ -40,6 +40,8 @@
|
|||
formaction="{{ url_for('action_reboot') }}" formmethod="post">
|
||||
<input class="dropdown-item" type="submit" value="{{ _('Refresh') }}"
|
||||
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="{{ _('Setup') }}"
|
||||
formaction="{{ url_for('action_setup_show') }}" formmethod="get">
|
||||
<input class="dropdown-item" type="submit" value="{{ _('Details') }}"
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
from flask import g, render_template, url_for, request, jsonify, make_response
|
||||
from ogcp.forms.action_forms import WOLForm, PartitionForm, ClientDetailsForm
|
||||
from ogcp.forms.action_forms import (
|
||||
WOLForm, PartitionForm, ClientDetailsForm, HardwareForm
|
||||
)
|
||||
from ogcp.og_server import OGServer
|
||||
from flask_babel import _
|
||||
from ogcp import app
|
||||
|
@ -195,6 +197,23 @@ def action_setup_delete():
|
|||
return make_response("200 OK", 200)
|
||||
return make_response("400 Bad Request", 400)
|
||||
|
||||
@app.route('/action/hardware', methods=['GET', 'POST'])
|
||||
def action_hardware():
|
||||
form = HardwareForm(request.form)
|
||||
if request.method == 'POST':
|
||||
ips = form.ips.data.split(' ')
|
||||
r = g.server.post('/hardware', payload={'clients': ips})
|
||||
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('/hardware', payload={'client': list(ips)})
|
||||
hardware = r.json()['hardware']
|
||||
return render_template('actions/hardware.html', form=form,
|
||||
hardware=hardware)
|
||||
|
||||
@app.route('/action/client/info', methods=['GET'])
|
||||
def action_client_info():
|
||||
form = ClientDetailsForm()
|
||||
|
|
Loading…
Reference in New Issue