summaryrefslogtreecommitdiffstats
path: root/src/utils/legacy.py
diff options
context:
space:
mode:
authorAlejandro Sirgo Rica <asirgo@soleta.eu>2024-02-14 12:20:46 +0100
committerOpenGnSys Support Team <soporte-og@soleta.eu>2024-02-14 12:28:28 +0100
commit478c4447be20380c5b173f8e150d2373cf6d021b (patch)
tree20a498b81f8dfa0073606388b46161fb2b6983d4 /src/utils/legacy.py
parentc1529c5eec2d782a38e07077388e780970788ffe (diff)
src: improve error check in image_create and image_restore
cover more error cases where exceptions need to be raised. check return code in the invoked subprocess. restoreImageCustom has been intentionally left behind, it is unclear what this custom script returns on success and error.
Diffstat (limited to 'src/utils/legacy.py')
-rw-r--r--src/utils/legacy.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/utils/legacy.py b/src/utils/legacy.py
index 0f6c53c..a272e4c 100644
--- a/src/utils/legacy.py
+++ b/src/utils/legacy.py
@@ -130,7 +130,7 @@ def ogGetImageInfo(image_path):
return image_info
-def cambiar_acceso(mode='rw', user='opengnsys', pwd='og'):
+def change_access(mode='rw', user='opengnsys', pwd='og'):
"""
'CambiarAcceso' (admin/Interface/CambiarAcceso) rewrite into native Python.
@@ -138,14 +138,14 @@ def cambiar_acceso(mode='rw', user='opengnsys', pwd='og'):
Specify access mode ('rw', or 'ro') with mode parameter (default 'rw').
Specify samba credentials with user and pwd parameter.
- Return True if exit-code was 0. Return False otherwise.
+ Return 0 if exit-code was 0. Return -1 otherwise.
"""
- if mode not in ['rw', 'ro']:
- raise ValueError('Invalid remount mode option')
+ assert mode in ['rw', 'ro'], 'Invalid remount mode option'
cmd = shlex.split(f'mount -o remount,{mode},username={user},password={pwd} /opt/opengnsys/images')
p = subprocess.run(cmd, stdout=DEVNULL, stderr=DEVNULL)
- return p.returncode == 0
+
+ return 0 if p.returncode == 0 else -1
def ogChangeRepo(ip, smb_user='opengnsys', smb_pass='og'):
"""