Warn if clients have different boot modes

Show user, when attempting to change the bootmode of more than one
client with different boot modes, a warning and a table with said
bootmodes.
master
Javier Hernandez 2023-12-22 12:08:49 +01:00 committed by OpenGnSys Support Team
parent 01977dcd66
commit 1497e500cb
2 changed files with 41 additions and 1 deletions

View File

@ -15,6 +15,32 @@
{{ _('Changing boot mode of %(ip_count)d computer(s)', ip_count=ip_count) }}
</h1>
{% if modes_set|length > 1 %}
<h3 class="text-danger">WARNING</h3>
<p>Selected clients have different boot modes set</p>
<table class="table table-hover">
<thead class="thead-light">
<tr>
<th>Boot modes</th>
<th>Clients</th>
</tr>
</thead>
<tbody class="text-left">
{% for mode, clients in modes_set.items() %}
<tr>
<th>{{mode}}</th>
<td>
{% for client in clients %}
{{client}}
{% endfor %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
{{ macros.cmd_selected_clients(selected_clients) }}
{{ wtf.quick_form(form,

View File

@ -1172,6 +1172,19 @@ def action_client_delete():
else:
return redirect(url_for('scopes'))
def get_clients_modes(ips, server):
modes = {}
for ip in ips:
r = server.get('/client/info', payload={"client": [ip]})
resp = r.json()
current_boot = resp['boot']
client_name = resp['name']
if current_boot not in modes:
modes[current_boot] = [client_name]
else:
modes[current_boot].append(client_name)
return modes
@app.route('/action/mode', methods=['GET', 'POST'])
@login_required
def action_mode():
@ -1195,6 +1208,7 @@ def action_mode():
return redirect(url_for('commands'))
server = get_server_from_clients(ips)
modes_set = get_clients_modes(ips, server)
r = server.get('/mode')
available_modes = [(mode, mode) for mode in r.json()['modes']]
form.boot.choices = list(available_modes)
@ -1204,7 +1218,7 @@ def action_mode():
selected_clients = list(get_selected_clients(scopes['scope']).items())
return render_template('actions/mode.html', form=form, scopes=scopes,
selected_clients=selected_clients,
clients=clients)
clients=clients, modes_set=modes_set)
@app.route('/action/oglive', methods=['GET', 'POST'])