diff options
Diffstat (limited to 'ogcp/views.py')
-rw-r--r-- | ogcp/views.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/ogcp/views.py b/ogcp/views.py index 131686c..3bbd933 100644 --- a/ogcp/views.py +++ b/ogcp/views.py @@ -735,7 +735,14 @@ def action_image_restore(): form = ImageRestoreForm(request.form) if request.method == 'POST': ips = form.ips.data.split(' ') - disk, partition = form.partition.data.split(' ') + disk, partition, part_code = form.partition.data.split(' ') + + part_type = PART_TYPE_CODES.get(int(part_code), 'UNKNOWN') + invalid_part_types = ['EMPTY', 'LINUX-SWAP', 'CACHE', 'EFI', 'WIN-RECOV'] + if part_type in invalid_part_types: + flash(_(f'Cannot restore image on partition type {part_type}'), category='error') + return redirect(url_for('commands')) + image_id = form.image.data server = get_server_from_clients(ips) r = server.get('/images') @@ -829,7 +836,7 @@ def action_image_restore(): return redirect(url_for('commands')) form.partition.choices = [ - (f"{disk_id} {part_id}", + (f"{disk_id} {part_id} {part_code}", f"Disk {disk_id} | Partition {part_id} " f"| {PART_TYPE_CODES.get(part_code, 'UNKNOWN')} " f"{FS_CODES.get(filesystem, 'UNKNOWN')}") |