summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémi Duraffort <remi.duraffort@linaro.org>2014-11-18 12:13:28 (GMT)
committerRémi Duraffort <remi.duraffort@linaro.org>2014-11-18 12:16:37 (GMT)
commitf8005b0519ace9a66c1bd91a285a48e2d501cccd (patch)
treef7b7de38880d4f50d0b2385988ed118894fe452a
parentb60aed2eb2441d1ad22f5b7cd2019462c22a6705 (diff)
downloadlava-dispatcher-f8005b0519ace9a66c1bd91a285a48e2d501cccd.tar.gz
lava-dispatcher-f8005b0519ace9a66c1bd91a285a48e2d501cccd.tar.xz
Make compression format explicit
The deploy action should now specify the image compression format using the 'compression' parameter. Change-Id: I1fd56e4663e3e8a7f44be065eb927d7dd3779c8e
-rw-r--r--lava_dispatcher/pipeline/actions/deploy/download.py31
-rw-r--r--lava_dispatcher/pipeline/test/sample_jobs/kvm.yaml1
2 files changed, 16 insertions, 16 deletions
diff --git a/lava_dispatcher/pipeline/actions/deploy/download.py b/lava_dispatcher/pipeline/actions/deploy/download.py
index 4d049af..9440f71 100644
--- a/lava_dispatcher/pipeline/actions/deploy/download.py
+++ b/lava_dispatcher/pipeline/actions/deploy/download.py
@@ -107,24 +107,18 @@ class DownloadHandler(Action):
@contextlib.contextmanager
def _decompressor_stream(self):
- # FIXME: should decompression be a different DownloadAction?
fd = None
- decompressor = None
- decompress = False
- if self.key == 'image':
- decompress = True # FIXME: get from job.parameters
-
- fname, suffix = self._url_to_fname_suffix(self.path) # FIXME: use the context tmpdir
+ fname, _ = self._url_to_fname_suffix(self.path) # FIXME: use the context tmpdir
- if suffix == 'gz' and decompress:
- decompressor = zlib.decompressobj(16 + zlib.MAX_WBITS)
- elif suffix == 'bz2' and decompress:
- decompressor = bz2.BZ2Decompressor()
- elif suffix == 'xz' and decompress:
- decompressor = lzma.LZMADecompressor()
- elif suffix is not None:
- # don't remove the file's real suffix
- fname = '%s.%s' % (fname, suffix)
+ decompressor = None
+ compression = self.parameters.get('compression', None)
+ if compression is not None:
+ if compression == 'gz':
+ decompressor = zlib.decompressobj(16 + zlib.MAX_WBITS)
+ elif compression == 'bz2':
+ decompressor = bz2.BZ2Decompressor()
+ elif compression == 'xz':
+ decompressor = lzma.LZMADecompressor()
def write(buff):
if decompressor:
@@ -146,6 +140,11 @@ class DownloadHandler(Action):
self.data.setdefault('download_action', {self.key: {}})
self.data['download_action'].update({self.key: {'file': fname}})
+ compression = self.parameters.get('compression', None)
+ if compression is not None:
+ if compression not in ['gz', 'bz2', 'xz']:
+ self.errors = "Unknown 'compression' format '%s'" % (compression)
+
def run(self, connection, args=None):
# self.cookies = self.job.context.config.lava_cookies # FIXME: work out how to restore
md5 = hashlib.md5()
diff --git a/lava_dispatcher/pipeline/test/sample_jobs/kvm.yaml b/lava_dispatcher/pipeline/test/sample_jobs/kvm.yaml
index 8be1b27..ecd9a1b 100644
--- a/lava_dispatcher/pipeline/test/sample_jobs/kvm.yaml
+++ b/lava_dispatcher/pipeline/test/sample_jobs/kvm.yaml
@@ -13,6 +13,7 @@ actions:
timeout: 20m
to: tmpfs
image: http://images.validation.linaro.org/kvm-debian-wheezy.img.gz
+ compression: gz
os: debian
# if root_partition partition is not present:
# - look for a partitions labelled "root" or "ROOT" or "Root" (i.e. case insensitive)