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.
master 1.1.3-25
Alejandro Sirgo Rica 2024-07-17 12:54:46 +02:00
parent ea28a4baf1
commit 33d4c31f46
1 changed files with 11 additions and 0 deletions

View File

@ -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: