summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlejandro Sirgo Rica <asirgo@soleta.eu>2024-06-17 14:09:49 +0200
committerAlejandro Sirgo Rica <asirgo@soleta.eu>2024-06-17 14:09:49 +0200
commit74c55987ef5662d666e0844b3e18c824cd9dcee2 (patch)
tree7a90c097bcbaefc1340e3efd503f77a8fd8d9f1d
parent4a74de1064c6cf0ef9ce10934efa24b63e661083 (diff)
views: fix image restore cache checks1.1.3-22
Fix the scope of the has_cache variable to reset the value for each client. Check the partition type based on the PART_TYPE_CODES string version instead of the numerical value of the partition type.
-rw-r--r--ogcp/views.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/ogcp/views.py b/ogcp/views.py
index 0133954..886ff13 100644
--- a/ogcp/views.py
+++ b/ogcp/views.py
@@ -837,7 +837,6 @@ 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]})
@@ -846,6 +845,8 @@ def action_image_restore():
if r.status_code != requests.codes.ok:
return ogserver_error('commands')
+ has_cache = False
+
partitions = r.json()['partitions']
parts = []
for partition in partitions:
@@ -854,7 +855,7 @@ 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':
+ if PART_TYPE_CODES.get(int(part_code), 'UNKNOWN') == 'CACHE':
has_cache = True
filesystem = partition['filesystem']
part_size = partition['size']