mirror of https://git.48k.eu/ogcp
views: check target partition size in image restore
Compare image data size with the size of the target partition and show an error if the size is not enough for the operation.master
parent
30562a9af5
commit
0ba0b933e2
|
@ -735,7 +735,7 @@ def action_image_restore():
|
|||
form = ImageRestoreForm(request.form)
|
||||
if request.method == 'POST':
|
||||
ips = form.ips.data.split(' ')
|
||||
disk, partition, part_code = form.partition.data.split(' ')
|
||||
disk, partition, part_code, part_size = form.partition.data.split(' ')
|
||||
|
||||
part_type = PART_TYPE_CODES.get(int(part_code), 'UNKNOWN')
|
||||
invalid_part_types = ['EMPTY', 'LINUX-SWAP', 'CACHE', 'EFI', 'WIN-RECOV']
|
||||
|
@ -756,6 +756,13 @@ def action_image_restore():
|
|||
if not image:
|
||||
flash(_(f'Image to restore was not found'), category='error')
|
||||
return redirect(url_for('commands'))
|
||||
|
||||
image_datasize = int(image['datasize'])
|
||||
part_size = int(part_size) * 1024
|
||||
if image_datasize > part_size:
|
||||
flash(_(f'The image size is bigger than the target partition'), category='error')
|
||||
return redirect(url_for('commands'))
|
||||
|
||||
try:
|
||||
repository = get_repository(image['repo_id'], server)
|
||||
except ServerError:
|
||||
|
@ -825,8 +832,9 @@ def action_image_restore():
|
|||
continue
|
||||
part_code = partition['code']
|
||||
filesystem = partition['filesystem']
|
||||
part_size = partition['size']
|
||||
|
||||
choice_value = (disk_id, part_id, part_code, filesystem)
|
||||
choice_value = (disk_id, part_id, part_code, filesystem, part_size)
|
||||
parts.append(choice_value)
|
||||
|
||||
if not part_choices: # Use first computer as reference part setup conf
|
||||
|
@ -836,11 +844,11 @@ def action_image_restore():
|
|||
return redirect(url_for('commands'))
|
||||
|
||||
form.partition.choices = [
|
||||
(f"{disk_id} {part_id} {part_code}",
|
||||
(f"{disk_id} {part_id} {part_code} {part_size}",
|
||||
f"Disk {disk_id} | Partition {part_id} "
|
||||
f"| {PART_TYPE_CODES.get(part_code, 'UNKNOWN')} "
|
||||
f"{FS_CODES.get(filesystem, 'UNKNOWN')}")
|
||||
for disk_id, part_id, part_code, filesystem in part_choices ]
|
||||
for disk_id, part_id, part_code, filesystem, part_size in part_choices ]
|
||||
scopes, clients = get_scopes(set(ips))
|
||||
selected_clients = list(get_selected_clients(scopes['scope']).items())
|
||||
|
||||
|
|
Loading…
Reference in New Issue