From 6feffeab5ddc1c8ba903a08015c8f36566d1eb30 Mon Sep 17 00:00:00 2001 From: Alejandro Sirgo Rica Date: Thu, 26 Sep 2024 14:45:04 +0200 Subject: views: ignore unsuported part types in /image/restore checks Evaluate only the viable partitions for a restore operation during checks for partition uniformity. --- ogcp/views.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'ogcp') diff --git a/ogcp/views.py b/ogcp/views.py index b6a0cd7..c890782 100644 --- a/ogcp/views.py +++ b/ogcp/views.py @@ -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} " -- cgit v1.2.3-18-g5258