live: report permissions and last update when creating image

add .permissions and .lastupdate to json to report to ogserver.
master v1.3.2-3
OpenGnSys Support Team 2023-12-12 17:11:48 +01:00
parent b97c4d157a
commit 6c49815d73
3 changed files with 14 additions and 3 deletions

View File

@ -10,6 +10,7 @@ import datetime
import hashlib import hashlib
import logging import logging
import os import os
import stat
import subprocess import subprocess
import shlex import shlex
import shutil import shutil
@ -479,13 +480,19 @@ class OgLiveOperations:
raise ValueError('Error: Incorrect command value') raise ValueError('Error: Incorrect command value')
try: try:
stat = os.stat(image_path) st = os.stat(image_path)
size = stat.st_size size = st.st_size
perms = st.st_mode & (stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO)
mtime = int(st.st_mtime)
except: except:
logging.info(f'cannot retrieve size from {image_path}') logging.info(f'cannot retrieve stats from {image_path}')
size = 0 size = 0
perms = 0
mtime = 0
image_info.size = size image_info.size = size
image_info.perms = perms
image_info.mtime = mtime
self._write_md5_file(f'/opt/opengnsys/images/{name}.img') self._write_md5_file(f'/opt/opengnsys/images/{name}.img')

View File

@ -207,6 +207,8 @@ class ogThread():
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) json_body.add_element('size', image_info.size)
json_body.add_element('perms', image_info.perms)
json_body.add_element('lastupdate', image_info.mtime)
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())

View File

@ -26,6 +26,8 @@ class ImageInfo:
self.filesystem = filesystem self.filesystem = filesystem
self.datasize = datasize self.datasize = datasize
self.size = 0 self.size = 0
self.mtime = 0
self.perms = 0
self.clonator = 'PARTCLONE' self.clonator = 'PARTCLONE'
self.compressor = 'LZOP' self.compressor = 'LZOP'