Revision 3a9b3cde snf-app/synnefo/api/util.py

b/snf-app/synnefo/api/util.py
54 54

  
55 55
from synnefo.api.faults import (Fault, BadRequest, BuildInProgress,
56 56
                                ItemNotFound, ServiceUnavailable, Unauthorized)
57
from synnefo.db.models import (SynnefoUser, Flavor, Image, ImageMetadata,
57
from synnefo.db.models import (Flavor, Image, ImageMetadata,
58 58
                                VirtualMachine, VirtualMachineMetadata,
59 59
                                Network, NetworkInterface)
60
from synnefo.plankton.backend import ImageBackend
60 61
from synnefo.util.log import getLogger
61 62

  
62 63

  
......
149 150
            raise ItemNotFound('Image not found.')
150 151
        return image
151 152
    except ValueError:
152
        raise BadRequest('Invalid image ID.')
153
        raise ItemNotFound('Image not found.')
153 154
    except Image.DoesNotExist:
154 155
        raise ItemNotFound('Image not found.')
155 156

  
157
def get_backend_image(image_id, owner):
158
    backend = ImageBackend(owner.uniq)
159
    try:
160
        image = backend.get_meta(image_id)
161
        if not image:
162
            raise ItemNotFound('Image not found.')
163
        return image
164
    finally:
165
        backend.close()
166

  
156 167
def get_image_meta(image, key):
157 168
    """Return a ImageMetadata instance or raise ItemNotFound."""
158 169

  

Also available in: Unified diff