summaryrefslogtreecommitdiffstats
path: root/src/live
diff options
context:
space:
mode:
authorOpenGnSys Support Team <soporte-og@soleta.eu>2024-07-04 16:33:01 +0200
committerOpenGnSys Support Team <soporte-og@soleta.eu>2024-07-15 09:50:30 +0200
commit9d8a95cc743853b60df47fbb08f51e2605fc2ad7 (patch)
tree7638f0ea86ba037dcf014c0ecddf9fb62bc34f60 /src/live
parent43039749c50a4fadd085418e262a50ea0d4f1357 (diff)
live: add checksum field to image/create response
Report image checksum to ogserver through HTTP response.
Diffstat (limited to 'src/live')
-rw-r--r--src/live/ogOperations.py19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/live/ogOperations.py b/src/live/ogOperations.py
index 2d5146c..9c67728 100644
--- a/src/live/ogOperations.py
+++ b/src/live/ogOperations.py
@@ -157,15 +157,20 @@ class OgLiveOperations:
m.update(buf)
return m.hexdigest()
- def _write_md5_file(self, path):
+ def _md5_file(self, path):
+ if not os.path.exists(path):
+ raise OgError(f'Failed to calculate checksum, image file {path} does not exist')
+
+ return self._compute_md5(path)
+
+ def _write_md5_file(self, path, checksum):
if not os.path.exists(path):
raise OgError(f'Failed to calculate checksum, image file {path} does not exist')
filename = path + ".full.sum"
- dig = self._compute_md5(path)
try:
with open(filename, 'w') as f:
- f.write(dig)
+ f.write(checksum)
except:
logging.error(f'Cannot write checksum {filename}')
return -1
@@ -585,9 +590,15 @@ class OgLiveOperations:
logging.info(f'Writing checksum file {name}.img.full.sum...')
logging.info('*DO NOT REBOOT OR POWEROFF* the client during this time')
- if self._write_md5_file(f'/opt/opengnsys/images/{name}.img') == -1:
+ checksum = self._md5_file(f'/opt/opengnsys/images/{name}.img')
+ if checksum == -1:
+ raise OgError(f'Cannot access {name}.full.sum file')
+
+ if self._write_md5_file(f'/opt/opengnsys/images/{name}.img', checksum) == -1:
raise OgError(f'Cannot write {name}.full.sum file')
+ image_info.checksum = checksum
+
self._restartBrowser(self._url)
logging.info('Image creation command OK')