Commit 8677c3a9 authored by Hrvoje Ribicic's avatar Hrvoje Ribicic
Browse files

Extend offered compression types



This patch adds a few new types of compression supported by Ganeti:
gzip-fast (gzip -1), gzip-slow (ordinary gzip), and lzop. gzip now
becomes a shorthand for gzip-fast kept for compatibility.
Signed-off-by: default avatarHrvoje Ribicic <riba@google.com>
Reviewed-by: default avatarThomas Thrainer <thomasth@google.com>
parent 821dbb5f
......@@ -298,16 +298,29 @@ class CommandBuilder(object):
if self._mode == constants.IEM_IMPORT:
parts.append(socat_cmd)
if compr == constants.IEC_GZIP:
if compr in [constants.IEC_GZIP, constants.IEC_GZIP_FAST,
constants.IEC_GZIP_SLOW]:
parts.append("gunzip -c")
elif compr == constants.IEC_LZOP:
parts.append("lzop -d -c")
else:
# No compression
pass
parts.append(dd_cmd)
elif self._mode == constants.IEM_EXPORT:
parts.append(dd_cmd)
if compr == constants.IEC_GZIP:
if compr == constants.IEC_GZIP_SLOW:
parts.append("gzip -c")
elif compr in [constants.IEC_GZIP_FAST, constants.IEC_GZIP]:
parts.append("gzip -1 -c")
elif compr == constants.IEC_LZOP:
parts.append("lzop -c")
else:
# No compression
pass
parts.append(socat_cmd)
......
......@@ -586,11 +586,20 @@ iemImport = "import"
iecGzip :: String
iecGzip = "gzip"
iecGzipFast :: String
iecGzipFast = "gzip-fast"
iecGzipSlow :: String
iecGzipSlow = "gzip-slow"
iecLzop :: String
iecLzop = "lzop"
iecNone :: String
iecNone = "none"
iecAll :: [String]
iecAll = [iecGzip, iecNone]
iecAll = [iecGzip, iecGzipFast, iecGzipSlow, iecLzop, iecNone]
ieCustomSize :: String
ieCustomSize = "fd"
......
......@@ -878,6 +878,12 @@ $(THH.declareLADT ''String "ImportExportCompression"
("None", "none")
-- gzip compression
, ("GZip", "gzip")
-- fast gzip compression
, ("GZipFast", "gzip-fast")
-- slow gzip compression
, ("GZipSlow", "gzip-slow")
-- lzop compression
, ("LZop", "lzop")
])
$(THH.makeJSONInstance ''ImportExportCompression)
......
......@@ -67,9 +67,15 @@ class TestCommandBuilder(unittest.TestCase):
# The commands various compressions should use
compress_import = {
constants.IEC_GZIP: "gunzip",
constants.IEC_GZIP_FAST: "gunzip",
constants.IEC_GZIP_SLOW: "gunzip",
constants.IEC_LZOP: "lzop -d",
}
compress_export = {
constants.IEC_GZIP: "gzip",
constants.IEC_GZIP: "gzip -1",
constants.IEC_GZIP_FAST: "gzip -1",
constants.IEC_GZIP_SLOW: "gzip",
constants.IEC_LZOP: "lzop",
}
for mode in [constants.IEM_IMPORT, constants.IEM_EXPORT]:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment