mirror of https://git.48k.eu/ogclient
live: report image size when creating image
add .size json field to report the real size of the image file.master
parent
d34ef0ab25
commit
b97c4d157a
|
@ -478,6 +478,15 @@ class OgLiveOperations:
|
||||||
logging.exception('Exception when running "image create" subprocess')
|
logging.exception('Exception when running "image create" subprocess')
|
||||||
raise ValueError('Error: Incorrect command value')
|
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._write_md5_file(f'/opt/opengnsys/images/{name}.img')
|
||||||
|
|
||||||
self._restartBrowser(self._url)
|
self._restartBrowser(self._url)
|
||||||
|
|
|
@ -206,6 +206,7 @@ class ogThread():
|
||||||
json_body.add_element('compressor', image_info.compressor)
|
json_body.add_element('compressor', image_info.compressor)
|
||||||
json_body.add_element('filesystem', image_info.filesystem)
|
json_body.add_element('filesystem', image_info.filesystem)
|
||||||
json_body.add_element('datasize', datasize)
|
json_body.add_element('datasize', datasize)
|
||||||
|
json_body.add_element('size', image_info.size)
|
||||||
|
|
||||||
response = restResponse(ogResponses.OK, json_body, seq=client.seq)
|
response = restResponse(ogResponses.OK, json_body, seq=client.seq)
|
||||||
client.send(response.get())
|
client.send(response.get())
|
||||||
|
|
|
@ -25,6 +25,7 @@ class ImageInfo:
|
||||||
def __init__(self, filesystem=None, datasize=None):
|
def __init__(self, filesystem=None, datasize=None):
|
||||||
self.filesystem = filesystem
|
self.filesystem = filesystem
|
||||||
self.datasize = datasize
|
self.datasize = datasize
|
||||||
|
self.size = 0
|
||||||
self.clonator = 'PARTCLONE'
|
self.clonator = 'PARTCLONE'
|
||||||
self.compressor = 'LZOP'
|
self.compressor = 'LZOP'
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue