summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOpenGnSys Support Team <soporte-og@soleta.eu>2023-12-12 17:11:48 +0100
committerOpenGnSys Support Team <soporte-og@soleta.eu>2023-12-12 17:51:50 +0100
commit6c49815d73269fb83fb7d5a7b641da2c5a54ceb3 (patch)
tree1c8718c9b9ce6545e860a39ece316b69d692b873
parentb97c4d157adfcbdaa0f7ede40bd68e54c0aaaef3 (diff)
live: report permissions and last update when creating imagev1.3.2-3
add .permissions and .lastupdate to json to report to ogserver.
-rw-r--r--src/live/ogOperations.py13
-rw-r--r--src/ogRest.py2
-rw-r--r--src/utils/legacy.py2
3 files changed, 14 insertions, 3 deletions
diff --git a/src/live/ogOperations.py b/src/live/ogOperations.py
index 66f3024..ff1a099 100644
--- a/src/live/ogOperations.py
+++ b/src/live/ogOperations.py
@@ -10,6 +10,7 @@ import datetime
import hashlib
import logging
import os
+import stat
import subprocess
import shlex
import shutil
@@ -479,13 +480,19 @@ class OgLiveOperations:
raise ValueError('Error: Incorrect command value')
try:
- stat = os.stat(image_path)
- size = stat.st_size
+ st = os.stat(image_path)
+ size = st.st_size
+ perms = st.st_mode & (stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO)
+ mtime = int(st.st_mtime)
except:
- logging.info(f'cannot retrieve size from {image_path}')
+ logging.info(f'cannot retrieve stats from {image_path}')
size = 0
+ perms = 0
+ mtime = 0
image_info.size = size
+ image_info.perms = perms
+ image_info.mtime = mtime
self._write_md5_file(f'/opt/opengnsys/images/{name}.img')
diff --git a/src/ogRest.py b/src/ogRest.py
index f567280..7848c3d 100644
--- a/src/ogRest.py
+++ b/src/ogRest.py
@@ -207,6 +207,8 @@ class ogThread():
json_body.add_element('filesystem', image_info.filesystem)
json_body.add_element('datasize', datasize)
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)
client.send(response.get())
diff --git a/src/utils/legacy.py b/src/utils/legacy.py
index 6e907b4..def5459 100644
--- a/src/utils/legacy.py
+++ b/src/utils/legacy.py
@@ -26,6 +26,8 @@ class ImageInfo:
self.filesystem = filesystem
self.datasize = datasize
self.size = 0
+ self.mtime = 0
+ self.perms = 0
self.clonator = 'PARTCLONE'
self.compressor = 'LZOP'