mirror of https://git.48k.eu/ogcp
Ask for reference when partitioning several clients
Allow the user to choose a computer as reference to display the partition scheme form.multi-ogserver
parent
bb39f67a46
commit
52a06822b2
|
@ -58,6 +58,12 @@ class PartitionForm(FlaskForm):
|
|||
size = IntegerField(label=_l('Size (KB)'))
|
||||
format_partition = BooleanField(label=_l('Format'))
|
||||
|
||||
class SelectClientForm(FlaskForm):
|
||||
ips = HiddenField()
|
||||
selected_client = SelectField(label=_l('Select one client as reference to '
|
||||
'define the partition scheme'))
|
||||
ok = SubmitField(label=_l('Ok'))
|
||||
|
||||
class SetupForm(FlaskForm):
|
||||
ips = HiddenField()
|
||||
disk = HiddenField()
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
{% extends 'commands.html' %}
|
||||
{% import 'bootstrap/wtf.html' as wtf %}
|
||||
{% import 'macros.html' as macros %}
|
||||
|
||||
{% set sidebar_state = 'disabled' %}
|
||||
{% set btn_back = true %}
|
||||
|
||||
{% block nav_image %} active{% endblock %}
|
||||
{% block nav_image_restore %} active{% endblock %}
|
||||
{% block content %}
|
||||
|
||||
{% set ip_list = form.ips.data.split(' ') %}
|
||||
{% set ip_count = ip_list | length %}
|
||||
<h1 class="m-5">
|
||||
{{ _('Partitioning %(ip_count)d client(s)', ip_count=ip_count) }}
|
||||
</h1>
|
||||
|
||||
{{ macros.cmd_selected_clients(selected_clients) }}
|
||||
|
||||
{{ wtf.quick_form(form,
|
||||
action=url_for('action_setup_show'),
|
||||
method='get',
|
||||
button_map={'restore': 'primary'},
|
||||
extra_classes='m-5') }}
|
||||
|
||||
{% endblock %}
|
|
@ -41,7 +41,7 @@
|
|||
<input class="btn btn-light dropdown-item{% block nav_setup_set_oglive %}{% endblock %}" type="submit" value="{{ _('Set ogLive') }}"
|
||||
form="scopesForm" formaction="{{ url_for('action_oglive') }}" formmethod="get">
|
||||
<input class="btn btn-light dropdown-item{% block nav_setup_setup %}{% endblock %}" type="submit" value="{{ _('Partition & Format') }}"
|
||||
form="scopesForm" formaction="{{ url_for('action_setup_show') }}" formmethod="get">
|
||||
form="scopesForm" formaction="{{ url_for('action_setup_select') }}" formmethod="get">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ from ogcp.forms.action_forms import (
|
|||
WOLForm, SetupForm, ClientDetailsForm, ImageDetailsForm, HardwareForm,
|
||||
SessionForm, ImageRestoreForm, ImageCreateForm, SoftwareForm, BootModeForm,
|
||||
RoomForm, DeleteRoomForm, CenterForm, DeleteCenterForm, OgliveForm,
|
||||
GenericForm
|
||||
GenericForm, SelectClientForm
|
||||
)
|
||||
from flask_login import (
|
||||
current_user, LoginManager,
|
||||
|
@ -335,6 +335,32 @@ def action_wol():
|
|||
else:
|
||||
return redirect(url_for('commands'))
|
||||
|
||||
|
||||
@app.route('/action/setup/select', methods=['GET'])
|
||||
@login_required
|
||||
def action_setup_select():
|
||||
args = request.args.copy()
|
||||
|
||||
ips = parse_elements(args.to_dict())
|
||||
if not validate_elements(ips):
|
||||
return redirect(url_for('commands'))
|
||||
|
||||
if len(ips) == 1:
|
||||
ip = list(ips)[0]
|
||||
return redirect(url_for('action_setup_show', ip=ip))
|
||||
|
||||
form = SelectClientForm()
|
||||
form.ips.data = " ".join(ips)
|
||||
form.selected_client.choices = list(ips)
|
||||
|
||||
scopes, _ = get_scopes(ips)
|
||||
selected_clients = list(get_selected_clients(scopes['scope']).items())
|
||||
|
||||
return render_template('actions/select_client.html',
|
||||
selected_clients=selected_clients,
|
||||
form=form, scopes=scopes)
|
||||
|
||||
|
||||
@app.route('/action/setup', methods=['GET'])
|
||||
@login_required
|
||||
def action_setup_show():
|
||||
|
@ -343,12 +369,15 @@ def action_setup_show():
|
|||
default_disk = 1
|
||||
selected_disk = int(args.pop('disk', default_disk))
|
||||
|
||||
ips = parse_elements(args.to_dict())
|
||||
if not validate_elements(ips):
|
||||
return redirect(url_for('commands'))
|
||||
if args.get('ip'):
|
||||
ips = {args['ip']}
|
||||
ips_str = base_client = args['ip']
|
||||
else:
|
||||
ips_str = args['ips']
|
||||
ips = set(args['ips'].split(' '))
|
||||
base_client = args['selected_client']
|
||||
|
||||
ip = list(ips)[0]
|
||||
db_partitions = get_client_setup(ip)
|
||||
db_partitions = get_client_setup(base_client)
|
||||
filtered_partitions = [p for p in db_partitions
|
||||
if p.get('disk') == selected_disk]
|
||||
|
||||
|
@ -357,7 +386,7 @@ def action_setup_show():
|
|||
if d.get('partition') == disk_partition]
|
||||
|
||||
form = SetupForm()
|
||||
form.ips.data = " ".join(ips)
|
||||
form.ips.data = ips_str
|
||||
form.disk.data = selected_disk
|
||||
# If partition table is empty, set MSDOS
|
||||
form.disk_type.data = filtered_partitions[0]['code'] or 1
|
||||
|
|
Loading…
Reference in New Issue