Ejemplo n.º 1
0
    def download(self):
        metadata = {
            "type": "vmimage",
            "name": self.name,
            "version": self.version,
            "arch": self.arch,
            "build": self.build,
        }
        if isinstance(self.cache_dir, str):
            cache_dirs = [self.cache_dir]
        else:
            cache_dirs = self.cache_dir
        asset_path = asset.Asset(
            name=self.url,
            asset_hash=self.checksum,
            algorithm=self.algorithm,
            locations=None,
            cache_dirs=cache_dirs,
            expire=None,
            metadata=metadata,
        ).fetch()

        if archive.is_archive(asset_path):
            uncompressed_path = os.path.splitext(asset_path)[0]
            asset_path = archive.uncompress(asset_path, uncompressed_path)
        self._base_image = asset_path
        return self._base_image
Ejemplo n.º 2
0
 def test_gzip_is_archive(self):
     gz_path = os.path.join(BASEDIR, 'selftests', '.data', 'avocado.gz')
     self.assertTrue(archive.is_archive(gz_path))
Ejemplo n.º 3
0
 def test_null_lzma_is_not_archive(self):
     self.assertFalse(archive.is_archive(os.devnull))
Ejemplo n.º 4
0
 def test_lzma_is_archive(self):
     xz_path = os.path.join(BASEDIR, 'selftests', '.data', 'avocado.xz')
     self.assertTrue(archive.is_archive(xz_path))
Ejemplo n.º 5
0
 def test_gzip_is_archive(self):
     gz_path = os.path.join(BASEDIR, 'selftests', '.data', 'avocado.gz')
     self.assertTrue(archive.is_archive(gz_path))
Ejemplo n.º 6
0
 def test_lzma_is_archive(self):
     xz_path = os.path.join(BASEDIR, "selftests", ".data", "avocado.xz")
     self.assertTrue(archive.is_archive(xz_path))
Ejemplo n.º 7
0
 def test_gzip_is_archive(self):
     gz_path = os.path.join(BASEDIR, "selftests", ".data", "avocado.gz")
     self.assertTrue(archive.is_archive(gz_path))