summaryrefslogtreecommitdiffstats
path: root/ogcp
diff options
context:
space:
mode:
Diffstat (limited to 'ogcp')
-rw-r--r--ogcp/views.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/ogcp/views.py b/ogcp/views.py
index 60afbd3..bd74515 100644
--- a/ogcp/views.py
+++ b/ogcp/views.py
@@ -747,7 +747,7 @@ def action_image_restore():
form = ImageRestoreForm(request.form)
if request.method == 'POST':
ips = form.ips.data.split(' ')
- disk, partition, part_code, part_size = form.partition.data.split(' ')
+ disk, partition, part_code, part_size, has_cache = form.partition.data.split(' ')
part_type = PART_TYPE_CODES.get(int(part_code), 'UNKNOWN')
invalid_part_types = ['EMPTY', 'LINUX-SWAP', 'CACHE', 'EFI', 'WIN-RECOV']
@@ -755,6 +755,11 @@ def action_image_restore():
flash(_(f'Cannot restore image on partition type {part_type}'), category='error')
return redirect(url_for('commands'))
+ requires_cache = form.method.data == 'TIPTORRENT' or form.method.data == 'UNICAST'
+ if has_cache == 'False' and requires_cache:
+ flash(_(f'Cannot restore image using {form.method.data} on a client without cache'), category='error')
+ return redirect(url_for('commands'))
+
image_id = form.image.data
server = get_server_from_clients(ips)
r = server.get('/images')
@@ -827,6 +832,7 @@ def action_image_restore():
for image in images[repo_id]:
form.image.choices.append((image['id'], image['name']))
+ has_cache = False
part_choices = []
for ip in ips:
r = server.get('/client/setup', payload={'client': [ip]})
@@ -843,6 +849,8 @@ def action_image_restore():
if part_id == 0: # This is the disk data, not a partition.
continue
part_code = partition['code']
+ if part_code == 'CACHE':
+ has_cache = True
filesystem = partition['filesystem']
part_size = partition['size']
@@ -856,7 +864,7 @@ def action_image_restore():
return redirect(url_for('commands'))
form.partition.choices = [
- (f"{disk_id} {part_id} {part_code} {part_size}",
+ (f"{disk_id} {part_id} {part_code} {part_size} {has_cache}",
f"Disk {disk_id} | Partition {part_id} "
f"| {PART_TYPE_CODES.get(part_code, 'UNKNOWN')} "
f"{FS_CODES.get(filesystem, 'UNKNOWN')}")