Merge pull request 'refs #1981 use zstd when creating and restoring images' (#38) from use-zstd into main
ogclient/pipeline/head This commit looks good Details
ogclient/pipeline/tag This commit looks good Details

Reviewed-on: #38
pull/39/head 0.9.0
Natalia Serrano 2025-05-09 13:45:51 +02:00
commit cbb978e514
5 changed files with 16 additions and 4 deletions

View File

@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [0.9.0] - 2025-05-09
### Added
- Use zstd when creating and restoring images
## [0.8.4] - 2025-05-09
### Added

View File

@ -101,6 +101,8 @@ def ogCreateImageSyntax (dev, imgfile, tool='partclone', level='gzip'):
'gzip': ' | gzip -c > ',
3: ' | bzip -c > ',
'bzip': ' | bzip -c > ',
4: ' | zstd -c > ',
'zstd': ' | zstd -c > ',
}.get (level, ' > ')
#print (f'param1 ({param1}) param2 ({param2}) param3 ({param3}) imgfile ({imgfile})')
@ -150,6 +152,8 @@ def ogRestoreImageSyntax (imgfile, part, tool=None, level=None):
'gzip': ' gzip -dc ',
3: ' bzip -dc ',
'bzip': ' bzip -dc ',
4: ' zstd -dc ',
'zstd': ' zstd -dc ',
}.get (level, '')
#print (f'tool ({tool}) level ({level}) compressor ({compressor})')
if compressor == '':
@ -595,7 +599,8 @@ def ogGetImageInfo (imgfile):
imgdetect = False
filehead = f'/tmp/{os.path.basename (imgfile)}.infohead'
compressor = subprocess.run (['file', imgfile], capture_output=True, text=True).stdout.split()[1]
if compressor not in ['gzip', 'lzop']:
if 'Zstandard' == compressor: compressor = 'zstd'
if compressor not in ['gzip', 'lzop', 'zstd']:
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_IMAGE, f'Image format is not valid {imgfile}')
return

View File

@ -7,6 +7,7 @@
#*/
import os
import re
import glob
import subprocess

View File

@ -58,7 +58,7 @@ def ogUcastSyntax (op, sess, file=None, device=None, tool=None, level=None):
raise TypeError (f'argument "tool" has unsupported value "{tool}"')
if level is None:
raise TypeError ('missing required argument: "level"')
if level.lower() not in ['lzop', 'gzip', '0', '1']:
if level.lower() not in ['lzop', 'gzip', 'zstd']:
raise TypeError (f'argument "level" has unsupported value "{level}"')
elif 'SENDFILE' == op or 'RECEIVERFILE' == op:
if file is None:
@ -290,7 +290,7 @@ def ogMcastSyntax (op, sess, file=None, device=None, tool=None, level=None):
raise TypeError (f'argument "tool" has unsupported value "{tool}"')
if level is None:
raise TypeError ('missing required argument: "level"')
if level.lower() not in ['lzop', 'gzip', '0', '1']:
if level.lower() not in ['lzop', 'gzip', 'zstd']:
raise TypeError (f'argument "level" has unsupported value "{level}"')
elif 'SENDFILE' == op or 'RECEIVERFILE' == op:
if file is None:

View File

@ -35,7 +35,7 @@ OGLOGCOMMAND='/tmp/command.log'
ACTIONCACHEFULL='NONE' #Que hacer cuando la cache no tenga espacio libre. [ NONE | FORMAT ] ]
RESTOREPROTOCOLNOTCACHE=None #Que protocolo de restauracion usar en el caso de que no exista cache o no exista espacio sufiente. [NONE | UNICAST | MULTICAST].NONE retorna error
IMGPROG='partclone'
IMGCOMP='lzop'
IMGCOMP='zstd'
IMGEXT='img'
IMGREDUCE=True
#OGWINREDUCE=True #Al enviar particion reducir el sistema de archivos previamente.