views: ignore unsuported part types in /image/restore checks

Evaluate only the viable partitions for a restore operation
during checks for partition uniformity.
master
Alejandro Sirgo Rica 2024-09-26 14:45:04 +02:00
parent 6fecb9d34b
commit 6feffeab5d
1 changed files with 10 additions and 8 deletions

View File

@ -1082,6 +1082,9 @@ def action_image_restore():
part_choices = []
empty_clients = []
invalid_part_types = get_invalid_image_partition_types()
for ip in ips:
r = server.get('/client/setup', payload={'client': [ip]})
if not r:
@ -1101,8 +1104,14 @@ def action_image_restore():
if disk_id != 1:
continue
part_code = partition['code']
if PART_TYPE_CODES.get(int(part_code), 'UNKNOWN') == 'CACHE':
part_type = PART_TYPE_CODES.get(int(part_code), 'UNKNOWN')
if part_type == 'CACHE':
has_cache = True
if part_type in invalid_part_types:
continue
filesystem = partition['filesystem']
part_size = partition['size']
@ -1125,14 +1134,7 @@ def action_image_restore():
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:
part_type = PART_TYPE_CODES.get(int(part_code), 'UNKNOWN')
if part_type in invalid_part_types:
continue
form.partition.choices.append(
(f"{disk_id} {part_id} {part_code} {part_size} {has_cache}",
f"Disk {disk_id} | Partition {part_id} "