Revision ac7188e6
b/api/handlers.py | ||
---|---|---|
29 | 29 |
{ |
30 | 30 |
"status": "CURRENT", |
31 | 31 |
"id": "v1.0", |
32 |
"docURL" : "http://docs.rackspacecloud.com/servers/api/v1.0/cs-devguide-20090714.pdf ",
|
|
32 |
"docURL" : "http://docs.rackspacecloud.com/servers/api/v1.0/cs-devguide-20110112.pdf",
|
|
33 | 33 |
"wadl" : "http://docs.rackspacecloud.com/servers/api/v1.0/application.wadl" |
34 | 34 |
}, |
35 | 35 |
{ |
... | ... | |
425 | 425 |
'size': image.size, |
426 | 426 |
'serverId': image.sourcevm and image.sourcevm.id or "" |
427 | 427 |
} for image in images] |
428 |
if rapi: # Images info is stored in the DB. Ganeti is not aware of this |
|
429 |
if id == "detail": |
|
430 |
return { "images": images_list } |
|
431 |
elif id is None: |
|
432 |
return { "images": [ { "id": s['id'], "name": s['name'] } for s in images_list ] } |
|
433 |
else: |
|
434 |
try: |
|
435 |
image = images.get(id=id) |
|
436 |
except Image.DoesNotExist: |
|
437 |
raise fault.itemNotFound |
|
438 |
except Image.MultipleObjectsReturned: |
|
439 |
raise fault.serviceUnavailable |
|
440 |
except Exception, e: |
|
441 |
log.error('Unexpected error: %s' % e) |
|
442 |
raise fault.serviceUnavailable |
|
443 |
|
|
444 |
return { "image": {'created': image.created.isoformat(), |
|
445 |
'id': image.id, |
|
446 |
'name': image.name, |
|
447 |
'updated': image.updated.isoformat(), |
|
448 |
'description': image.description, |
|
449 |
'status': image.state, |
|
450 |
'size': image.size, |
|
451 |
'serverId': image.sourcevm and image.sourcevm.id or "" |
|
452 |
} } |
|
453 |
|
|
428 |
# Images info is stored in the DB. Ganeti is not aware of this |
|
429 |
if id == "detail": |
|
430 |
return { "images": images_list } |
|
431 |
elif id is None: |
|
432 |
return { "images": [ { "id": s['id'], "name": s['name'] } for s in images_list ] } |
|
454 | 433 |
else: |
455 |
raise fault.serviceUnavailable |
|
434 |
try: |
|
435 |
image = images.get(id=id) |
|
436 |
except Image.DoesNotExist: |
|
437 |
raise fault.itemNotFound |
|
438 |
except Image.MultipleObjectsReturned: |
|
439 |
raise fault.serviceUnavailable |
|
440 |
except Exception, e: |
|
441 |
log.error('Unexpected error: %s' % e) |
|
442 |
raise fault.serviceUnavailable |
|
443 |
return { "image": {'created': image.created.isoformat(), |
|
444 |
'id': image.id, |
|
445 |
'name': image.name, |
|
446 |
'updated': image.updated.isoformat(), |
|
447 |
'description': image.description, |
|
448 |
'status': image.state, |
|
449 |
'size': image.size, |
|
450 |
'serverId': image.sourcevm and image.sourcevm.id or "" |
|
451 |
} } |
|
452 |
|
|
456 | 453 |
|
457 | 454 |
def create(self, request): |
458 | 455 |
"""Create a new image""" |
... | ... | |
490 | 487 |
'name': vmgroup.name, \ |
491 | 488 |
'server_id': [machine.id for machine in vmgroup.machines.all()] \ |
492 | 489 |
} for vmgroup in vmgroups] |
493 |
if rapi: # Group info is stored in the DB. Ganeti is not aware of this
|
|
494 |
if id == "detail":
|
|
495 |
return { "groups": vmgroups }
|
|
496 |
elif id is None:
|
|
497 |
return { "groups": [ { "id": s['id'], "name": s['name'] } for s in vmgroups ] }
|
|
498 |
else:
|
|
499 |
return { "groups": vmgroups[0] }
|
|
490 |
# Group info is stored in the DB. Ganeti is not aware of this |
|
491 |
if id == "detail": |
|
492 |
return { "groups": vmgroups } |
|
493 |
elif id is None: |
|
494 |
return { "groups": [ { "id": s['id'], "name": s['name'] } for s in vmgroups ] } |
|
495 |
else: |
|
496 |
return { "groups": vmgroups[0] } |
|
500 | 497 |
|
501 | 498 |
|
502 | 499 |
def create(self, request, id): |
Also available in: Unified diff