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

b/snf-app/synnefo/api/servers.py
230 230
        except AssertionError:
231 231
            raise faults.BadRequest("Malformed personality in request")
232 232
    
233
    image = util.get_image(image_id, owner)
233
    image = {}
234
    try:
235
        img = util.get_image(image_id, owner)
236
        image['backend_id'] = img.backend_id
237
        image['format'] = img.format
238
        image['metadata'] = dict((m.meta_key, m.meta_value)
239
                for m in img.metadata.all())
240
    except faults.ItemNotFound:
241
        img = util.get_backend_image(image_id, owner)
242
        image['backend_id'] = img['location']
243
        image['format'] = img['disk_format']
244
        image['metadata'] = img.get('properties', {})
245
    
234 246
    flavor = util.get_flavor(flavor_id)
235 247
    password = util.random_password()
236 248
    
......
242 254
    vm = VirtualMachine.objects.create(
243 255
        name=name,
244 256
        owner=owner,
245
        imageid=image.id,
257
        imageid=image_id,
246 258
        flavor=flavor)
247 259
    
248 260
    try:

Also available in: Unified diff