summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorTeran McKinney <teran.mckinney@rackspace.com>2013-06-05 12:36:37 +0000
committerTeran McKinney <teran.mckinney@rackspace.com>2013-08-22 17:22:36 +0000
commit9a24ae88da1692dcf7f0b119e693b538074aa902 (patch)
treebd63a1a689b3f6dd00047e6ff9ada50712d21bcb /plugins
parent2a2c7bdd0641e22aa3d145f848d6861cb1436bd3 (diff)
downloadnova-9a24ae88da1692dcf7f0b119e693b538074aa902.tar.gz
nova.conf configurable gzip compression level
Currently only used by XenAPI. Sets GZIP environment variable before spawning tar -cz to force the compression level. Defaults to none, which means the GZIP environment variable is not set and the default (usually -6) is used. Implements: blueprint image-compression-mode Change-Id: I02e136b7215a4f2cefc259f40bde9c1b205737ed
Diffstat (limited to 'plugins')
-rwxr-xr-xplugins/xenserver/xenapi/etc/xapi.d/plugins/glance5
-rw-r--r--plugins/xenserver/xenapi/etc/xapi.d/plugins/utils.py8
2 files changed, 10 insertions, 3 deletions
diff --git a/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance b/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance
index dad9acb4a4..d5984c65d8 100755
--- a/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance
+++ b/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance
@@ -181,8 +181,11 @@ def _upload_tarball(staging_path, image_id, glance_host, glance_port,
except Exception, error:
raise RetryableError(error)
+ compression_level = properties.get('xenapi_image_compression_level')
+
utils.create_tarball(
- None, staging_path, callback=send_chunked_transfer_encoded)
+ None, staging_path, callback=send_chunked_transfer_encoded,
+ compression_level=compression_level)
try:
conn.send("0\r\n\r\n") # Chunked-Transfer terminator
diff --git a/plugins/xenserver/xenapi/etc/xapi.d/plugins/utils.py b/plugins/xenserver/xenapi/etc/xapi.d/plugins/utils.py
index 8404fd961b..e3945236ac 100644
--- a/plugins/xenserver/xenapi/etc/xapi.d/plugins/utils.py
+++ b/plugins/xenserver/xenapi/etc/xapi.d/plugins/utils.py
@@ -355,16 +355,20 @@ def prepare_staging_area(sr_path, staging_path, vdi_uuids, seq_num=0):
seq_num += 1
-def create_tarball(fileobj, path, callback=None):
+def create_tarball(fileobj, path, callback=None, compression_level=None):
"""Create a tarball from a given path.
:param fileobj: a file-like object holding the tarball byte-stream.
If None, then only the callback will be used.
:param path: path to create tarball from
:param callback: optional callback to call on each chunk written
+ :param compression_level: compression level, e.g., 9 for gzip -9.
"""
tar_cmd = ["tar", "-zc", "--directory=%s" % path, "."]
- tar_proc = make_subprocess(tar_cmd, stdout=True, stderr=True)
+ env = os.environ.copy()
+ if compression_level and 1 <= compression_level <= 9:
+ env["GZIP"] = "-%d" % compression_level
+ tar_proc = make_subprocess(tar_cmd, stdout=True, stderr=True, env=env)
while True:
chunk = tar_proc.stdout.read(CHUNK_SIZE)