Catch permission errors when listing images

Fix #1608
This commit is contained in:
Julien Duponchelle 2016-10-26 10:53:14 +02:00
parent 1080147cf5
commit 048d2c12d0
No known key found for this signature in database
GPG Key ID: CE8B29639E07F5E8

View File

@ -539,15 +539,18 @@ class Compute:
res = yield from self.http_query("GET", "/{}/images".format(type), timeout=120) res = yield from self.http_query("GET", "/{}/images".format(type), timeout=120)
images = res.json images = res.json
if type in ["qemu", "dynamips", "iou"]: try:
for path in scan_for_images(type): if type in ["qemu", "dynamips", "iou"]:
image = os.path.basename(path) for path in scan_for_images(type):
if image not in [i['filename'] for i in images]: image = os.path.basename(path)
images.append({"filename": image, if image not in [i['filename'] for i in images]:
"path": image, images.append({"filename": image,
"md5sum": md5sum(path), "path": image,
"filesize": os.stat(path).st_size "md5sum": md5sum(path),
}) "filesize": os.stat(path).st_size
})
except OSError as e:
raise aiohttp.web.HTTPConflict(text="Can't scan for images: {}".format(str(e)))
return images return images
@asyncio.coroutine @asyncio.coroutine