Revision b3fd98ae snf-cyclades-app/synnefo/api/util.py
b/snf-cyclades-app/synnefo/api/util.py | ||
---|---|---|
63 | 63 |
from synnefo.db.pools import EmptyPool |
64 | 64 |
|
65 | 65 |
from synnefo.lib.astakos import get_user |
66 |
from synnefo.plankton.backend import ImageBackend, NotAllowedError
|
|
66 |
from synnefo.plankton.utils import image_backend
|
|
67 | 67 |
from synnefo.settings import MAX_CIDR_BLOCK |
68 | 68 |
|
69 | 69 |
|
... | ... | |
189 | 189 |
def get_image(image_id, user_id): |
190 | 190 |
"""Return an Image instance or raise ItemNotFound.""" |
191 | 191 |
|
192 |
backend = ImageBackend(user_id) |
|
193 |
try: |
|
192 |
with image_backend(user_id) as backend: |
|
194 | 193 |
image = backend.get_image(image_id) |
195 | 194 |
if not image: |
196 | 195 |
raise faults.ItemNotFound('Image not found.') |
197 | 196 |
return image |
198 |
finally: |
|
199 |
backend.close() |
|
200 | 197 |
|
201 | 198 |
|
202 | 199 |
def get_image_dict(image_id, user_id): |
Also available in: Unified diff