From 33d4c31f462e1e20f537908de3e516a0451a4dbe Mon Sep 17 00:00:00 2001 From: Alejandro Sirgo Rica Date: Wed, 17 Jul 2024 12:54:46 +0200 Subject: views: exclude clients with no partition in image/restore Clients cannot have an image restore when no partition configuration is available. Shown an error listing all the clients with no partitions. --- ogcp/views.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ogcp/views.py b/ogcp/views.py index 875d0ec..4bd1eae 100644 --- a/ogcp/views.py +++ b/ogcp/views.py @@ -943,6 +943,7 @@ def action_image_restore(): form.image.choices.append((image['id'], image['name'])) part_choices = [] + empty_clients = [] for ip in ips: r = server.get('/client/setup', payload={'client': [ip]}) if not r: @@ -968,12 +969,22 @@ def action_image_restore(): choice_value = (disk_id, part_id, part_code, filesystem, part_size) parts.append(choice_value) + if not parts: + empty_clients.append(ip) + + if empty_clients: + continue + if not part_choices: # Use first computer as reference part setup conf part_choices = [part for part in parts] elif part_choices != parts: flash(_(f'Computers have different partition setup'), category='error') return redirect(url_for('commands')) + if empty_clients: + flash(_(f'The following clients have not partitions: {" ".join(empty_clients)}'), category='error') + return redirect(url_for('commands')) + invalid_part_types = get_invalid_image_partition_types() for disk_id, part_id, part_code, filesystem, part_size in part_choices: -- cgit v1.2.3-18-g5258