live: report image size when creating image

add .size json field to report the real size of the image file.
master
OpenGnSys Support Team 2023-12-12 11:15:44 +01:00
parent d34ef0ab25
commit b97c4d157a
3 changed files with 11 additions and 0 deletions

View File

@ -478,6 +478,15 @@ class OgLiveOperations:
logging.exception('Exception when running "image create" subprocess')
raise ValueError('Error: Incorrect command value')
try:
stat = os.stat(image_path)
size = stat.st_size
except:
logging.info(f'cannot retrieve size from {image_path}')
size = 0
image_info.size = size
self._write_md5_file(f'/opt/opengnsys/images/{name}.img')
self._restartBrowser(self._url)

View File

@ -206,6 +206,7 @@ class ogThread():
json_body.add_element('compressor', image_info.compressor)
json_body.add_element('filesystem', image_info.filesystem)
json_body.add_element('datasize', datasize)
json_body.add_element('size', image_info.size)
response = restResponse(ogResponses.OK, json_body, seq=client.seq)
client.send(response.get())

View File

@ -25,6 +25,7 @@ class ImageInfo:
def __init__(self, filesystem=None, datasize=None):
self.filesystem = filesystem
self.datasize = datasize
self.size = 0
self.clonator = 'PARTCLONE'
self.compressor = 'LZOP'