From c33fe3ca77ebf9a8fab209a4ee7ff0928bc3aec6 Mon Sep 17 00:00:00 2001 From: Alejandro Sirgo Rica Date: Fri, 7 Feb 2025 12:20:06 +0100 Subject: [PATCH] views: report no valid partitions in image create/restore/update Inform the user when the selected clients don't have a valid partition type for an image create/restore/update operation and return to the commands view. --- ogcp/views.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ogcp/views.py b/ogcp/views.py index d31538c..54b26c8 100644 --- a/ogcp/views.py +++ b/ogcp/views.py @@ -1124,6 +1124,10 @@ def action_image_restore(): f"{fs_type}") ) + if not form.partition.choices: + flash(_(f'No valid partition available'), category='error') + return redirect(url_for('commands')) + return render_template('actions/image_restore.html', form=form, selected_clients=selected_clients, scopes=scopes) @@ -2386,6 +2390,11 @@ def action_image_create(): f"| {PART_TYPE_CODES.get(part.get('code'), 'UNKNOWN')} " f"{FS_CODES.get(part.get('filesystem'), 'UNKNOWN')}") ) + + if not form.os.choices: + flash(_(f'No valid partition available'), category='error') + return redirect(url_for('commands')) + r = server.get('/client/info', payload={'client': list(ips)}) client_repo_id = r.json()['repo_id'] @@ -2494,6 +2503,10 @@ def action_image_update(): part_content[partition_value] = part['image'] break + if not form.os.choices: + flash(_(f'No valid partition available'), category='error') + return redirect(url_for('commands')) + scopes, _clients = get_scopes(set(ips)) selected_clients = list(get_selected_clients(scopes['scope']).items())