summaryrefslogtreecommitdiffstats
path: root/src/live/ogOperations.py
Commit message (Collapse)AuthorAgeFilesLines
* live: use correct variable name in restore unicast cachev1.3.2-18OpenGnSys Support Team2024-09-091-1/+1
| | | | | | | | | | | | | | fe40f9c5 ('src: add POST cache/fetch method') broke unicast cache restore. (2024-09-09 10:05:22) ogClient: [ERROR] - name 'image_name' is not defined Traceback (most recent call last): File "/opt/opengnsys/ogClient/src/ogRest.py", line 175, in image_restore payload = ogRest.operations.image_restore(request, ogRest) File "/opt/opengnsys/ogClient/src/live/ogOperations.py", line 520, in image_restore self._restore_image_unicast(repo, name, partdev, cache) File "/opt/opengnsys/ogClient/src/live/ogOperations.py", line 242, in _restore_image_unicast image_path = f'{OG_CACHE_IMAGE_PATH}{image_name}.img' NameError: name 'image_name' is not defined
* live: incorrect indentationv1.3.2-17OpenGnSys Support Team2024-09-031-4/+4
| | | | | f2a2f5307464 ('live: remove file from cache with no checksum file') broke indentation which breaks ogClient.
* live: add disk index bounds checkv1.3.2-16Alejandro Sirgo Rica2024-09-021-4/+10
| | | | | Add disk index bounds checks for setup() and image_create(). Prevent backtrace logging when an invalid disk index is used.
* live: remove file from cache with no checksum fileOpenGnSys Support Team2024-09-021-1/+10
| | | | | Maybe result of a partial download? then, remove it to leave cache in consistent state.
* src: append .img to log that report image fetchingOpenGnSys Support Team2024-08-291-1/+1
|
* src: use logging.warning()OpenGnSys Support Team2024-08-271-2/+2
| | | | | | | logging.warn() is deprecated since 3.3. And use .error() instead when command is unsupported or client is busy, that should not ever happen.
* live: report that up-to-date image already exists in cachev1.3.2-15OpenGnSys Support Team2024-08-211-0/+1
|
* src: remove call to restoreImageCustom scriptOpenGnSys Support Team2024-08-211-2/+3
| | | | remove call to custom version of legacy script, display warning.
* live: clean files after a failed cache image copyAlejandro Sirgo Rica2024-08-091-0/+7
| | | | Remove image files after a failed image copy operation.
* src: add POST cache/fetch methodAlejandro Sirgo Rica2024-08-091-16/+39
| | | | | | | | | | | | | | | | | | | | | | Add API REST method to fetch an image. Consolidate image fetch loging for cache/fetch and image/restore. Resquest payload structure: { 'image': 'linux.img' 'type': 'TIPTORRENT' 'repository': '12.141.10.2' } The client will try to fetch'image' from 'repository' into cache. Resquest response structure: { 'cache': [ {'name': 'windows.img', 'size': 2432370213, checksum: '5d4dcc677bc19f40a647d0002f4ade90'}, {'name': 'linux.img', 'size': 243234534213, checksum: '3eb22f888f88a55ad954f55644e1192e'} ] }
* live: move filesystem expansion out of OS configurationOpenGnSys Support Team2024-08-061-0/+2
| | | | just a clean up.
* live: use correct loglevel when reporting issues with listing cache contentsv1.3.2-14OpenGnSys Support Team2024-07-311-2/+2
| | | | instead of using info to report errors.
* live: validate checksum only once if image is already in cacheOpenGnSys Support Team2024-07-301-10/+15
| | | | | | | | | | | | | if image already exists in the cache, skip a second checksum validation. log shows duplicated entries: Verifying checksum for example.img, please wait... Checksum is OK for example.img Verifying checksum for example.img, please wait... Checksum is OK for example.img because tip_check_csum() is called twice in this case.
* live: remove old image and checksum file on downloadOpenGnSys Support Team2024-07-301-1/+9
| | | | | | | Restoring an updated image file (with different checksum) could fail while the old checksum file could remain in place. Remove image and checksum file before fetching the new files.
* live: unicast-direct does not validate checksumOpenGnSys Support Team2024-07-301-0/+1
| | | | this restore method is unreliable, add warning to the logs.
* live: validate file existence and checksum for unicast cacheOpenGnSys Support Team2024-07-301-0/+5
| | | | | after copying file to cache, validate that file exists in cache and checksum correct.
* utils: add postinstall.pyAlejandro Sirgo Rica2024-07-291-4/+5
| | | | | | | | | | | | | | | Replace ConfigureOs script by native calls to: - update BCD via hivex using bcd.py and winreg.py infrastructure. - restore efi bootloader restore_windows_efi_bootloader(). Call legacy scripts for remaining postinstall procedures to replace them incrementally. Define variable CONFIGUREOS_LEGACY_ENABLED as False by default. Run legacy configureOs when CONFIGUREOS_LEGACY_ENABLED = True. This serves as a auxiliar method to keep the restoration functional in case of problems with the new configure_os logic.
* utils: rename ogExtendFs to extend_filesystemAlejandro Sirgo Rica2024-07-291-1/+1
| | | | Use a more consistent name format for the ogExtendFs function.
* utils: fs: error out if mkfs failsOpenGnSys Support Team2024-07-291-2/+5
| | | | | | | | | | If formatting fails, log shows: mkfs.ntfs reports return code 1 for /dev/sda2 but ogclient reports success to the ogserver. Raise an exception so front-end gets an indication that formatting has failed.
* live: improve logging for file removal from cacheOpenGnSys Support Team2024-07-211-2/+8
| | | | Provide a bit more logging to make it easier to debug issues.
* live: add logging to indicate image file copy from sambaOpenGnSys Support Team2024-07-211-0/+2
| | | | For consistency with tiptorrent download.
* live: add checksum field to image/create responseOpenGnSys Support Team2024-07-151-4/+15
| | | | Report image checksum to ogserver through HTTP response.
* live: check permissions when trying to fetch file via unicastv1.3.2-12OpenGnSys Support Team2024-06-271-0/+4
| | | | check sufficient permissions and bail out in case of issues.
* live: revisit error log when failing to validate checksumOpenGnSys Support Team2024-06-271-1/+1
| | | | | | | | Add explicit check for .full.sum after downloading it. Rewrite errors log, one of them is misleading when checksum validation fails, it refers to missing .full.sum, but it could be a different reason.
* live: add restricted execution mode to shell/runAlejandro Sirgo Rica2024-06-251-4/+19
| | | | | | | | | | | | | | | Try to find the script to run for a shell/run request in /opt/opengnsys/shell/, restricted mode is enabled if the script is found. Excute the script without shell=True and executable=OG_SHELL in restricted mode. Restricted mode is a safer execution method as it only executes code manually defined by the administrator. Each script needs to define a shebang, this way more than just bash is supported.
* rest: add cmd field to POST /shell/runOpenGnSys Support Team2024-06-211-1/+1
| | | | | echo command that has been run for storage in ogserver, until GET /shell/output is invoked.
* rest: add retcode field to POST /shell/runOpenGnSys Support Team2024-06-211-1/+1
| | | | | | | | provide return code as result to ogserver. Update virtual mode driver to return dummy value, although this command is unimplemented, this seems to be broken due to possible TypeError when accessing result from caller.
* live: handle no cache in tiptorrent and unicast restorev1.3.2-11Alejandro Sirgo Rica2024-06-071-1/+4
| | | | | | Properly report the lack of cache partition when restoring an image using TIPTORRENT and UNICAST as methods. Abort any restore in case of no cache partition.
* utils: fix get_image_info regressionv1.3.2-10Alejandro Sirgo Rica2024-06-031-1/+0
| | | | | | | Fix image size, permissions and creation time. Improve error report related to these parameters now showing the exact cause of the problem if any occurred during the definition of image size, file permissions or image creation time values.
* live: revisit logging for checksum file creationv1.3.2-9OpenGnSys Support Team2024-05-311-4/+8
| | | | | Add logging before calculating checksum to provide a hint to user on what is going on while ogClient is still busy.
* src: cleanup ogGetImageInfoAlejandro Sirgo Rica2024-05-301-16/+1
| | | | | | Rename ogGetImageInfo to get_image_info. Move code from ogOperations.py to obtain image data into get_image_info.
* src: rename legacy.py into image.pyAlejandro Sirgo Rica2024-05-301-1/+1
| | | | | legacy.py contais mostly functions related to system images. Rename the file to better represent the contents in it.
* src: stop using hardcoded paths to cache image directoryAlejandro Sirgo Rica2024-05-301-5/+4
| | | | | | Use the constant OG_CACHE_IMAGE_PATH from cache.py to obtain the location of the directory where images are stored. This way the path can be changed from one single point.
* src: add cache info to the image/restore responseAlejandro Sirgo Rica2024-05-301-0/+8
| | | | | | | | | | | | | | | | Add a 'cache' field into the json payload the client sends to the server after a restore operation so the server can update the new cache contents. Resquest response structure: { ... 'cache': [ {'name': 'windows.img', 'size': 2432370213, checksum: '5d4dcc677bc19f40a647d0002f4ade90'}, {'name': 'linux.img', 'size': 243234534213, checksum: '3eb22f888f88a55ad954f55644e1192e'} ] ... }
* src: add POST cache/delete methodAlejandro Sirgo Rica2024-05-301-0/+40
| | | | | | | | | | | | | | | | | | | | Add API REST method to delete cache contents. Resquest payload structure: { 'images': ['windows.img', 'linux.img'] } The client will try to delete as many images in cache as available with names matching the list of filenames in the 'images' field. Resquest response structure: { 'cache': [ {'name': 'windows.img', 'size': 2432370213, checksum: '5d4dcc677bc19f40a647d0002f4ade90'}, {'name': 'linux.img', 'size': 243234534213, checksum: '3eb22f888f88a55ad954f55644e1192e'} ] }
* live: add cache contents to the /refresh payloadAlejandro Sirgo Rica2024-05-301-1/+41
| | | | | | | | | | | | | | | | | Add the list of images in the client's cache partition in the payload sent to the server. The information sent is a list of {image_name, img_size, checksum} elements where img_size is the size of the respective image in bytes. Resquest response structure: { ... 'cache': [ {'name': 'windows.img', 'size': 2432370213, checksum: '5d4dcc677bc19f40a647d0002f4ade90'}, {'name': 'linux.img', 'size': 243234534213, checksum: '3eb22f888f88a55ad954f55644e1192e'} ] ... }
* live: remove unused return value in image_restore()OpenGnSys Support Team2024-05-271-2/+1
| | | | Never used what configureOs() returns, remove it.
* live: incorrect reference to image checksum file in logsOpenGnSys Support Team2024-05-251-1/+1
| | | | checksum file name end by .img.full.sum, not .full.sum
* live: rename variable that stores json body in refresh()OpenGnSys Support Team2024-05-211-5/+5
| | | | Just a simple cleanup.
* utils: rename cache_probe() to get_cache_dev_path()OpenGnSys Support Team2024-05-091-2/+2
| | | | | | | | This method reports the /dev path to cache partition, rename it. Add explicit check if blkid is successful. And add logging to report that device path to cache is not found.
* live: report LINUX-SWAP instead of SWAPv1.3.2-8OpenGnSys Support Team2024-05-071-0/+3
| | | | | | | ogCP expects LINUX-SWAP to specify a swap filesystem. Add a similar workaround to the one that is done for VFAT for symmetry between inputs and outputs that circulate over the API.
* live: rewrite log in case tiptorrent client failsOpenGnSys Support Team2024-05-061-1/+1
| | | | | Specify that image file cannot be found in cache because tiptorrent has failed, otherwise it is confusing.
* live: restore partprobe before building filesystemOpenGnSys Support Team2024-05-061-1/+4
| | | | Otherwise mkfs silently fails because OS reports out-of-sync partition table.
* live: force flush to disk after partition table is writtenOpenGnSys Support Team2024-05-061-0/+1
|
* live: partprobe breaks with mounted partitionsOpenGnSys Support Team2024-05-061-2/+11
| | | | | | | | | | partprobe requires that all disk partitions are unmounted. partprobe needs to be called to report the OS that the partition table has changed, otherwise ogclient reports incorrect partition information. iterate over the partition list and mount cache after partprobe is called.
* live: umount all partitions before partition setupOpenGnSys Support Team2024-05-061-2/+3
| | | | | If new partition layout is specified, unmount cache and any other partition under /mnt.
* live: fix omited error report in tip_client_getAlejandro Sirgo Rica2024-05-061-7/+6
| | | | | | | tip_client_get raises the proper error exceptions but the except block in _restore_image_tiptorrent overwrites the reported error. Move the raise statements in _restore_image_tiptorrent outside of the except block.
* live: revisit logging for partition setup, image create and restoreOpenGnSys Support Team2024-04-231-7/+5
|
* live: improve exception handling in image_createAlejandro Sirgo Rica2024-04-031-27/+34
| | | | | | | | | | | | | | | | | Reduce the scope of the try except block that controls the case of deleting the image backup in case of error. Now it only covers the section of code after backup creation and up to image verification. Check when the Exception is an OgError to raise with added context. Prevent the deletion of the target image in case of error before the backup creation. Bundle the backup creation on its own try except block to give more feedback on a failed backup creation. Enables a better error management allowing unhandled exceptions to be reported properly.
* src: use explicit exception types in except Exception blocksAlejandro Sirgo Rica2024-04-031-3/+3
| | | | | | | | Capture only the relevant exception types in each except block. The capture of the Exception type means hiding information for unhandled error cases, even for syntax errors in the codebase. Using a more fine grained exception filtering improves error traceability.