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,6 +539,7 @@ 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
try:
if type in ["qemu", "dynamips", "iou"]: if type in ["qemu", "dynamips", "iou"]:
for path in scan_for_images(type): for path in scan_for_images(type):
image = os.path.basename(path) image = os.path.basename(path)
@ -548,6 +549,8 @@ class Compute:
"md5sum": md5sum(path), "md5sum": md5sum(path),
"filesize": os.stat(path).st_size "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