Revision 909f415b api/handlers.py
b/api/handlers.py | ||
---|---|---|
7 | 7 |
from piston.handler import BaseHandler, AnonymousBaseHandler |
8 | 8 |
from synnefo.api.faults import fault, noContent, accepted, created |
9 | 9 |
from synnefo.api.helpers import instance_to_server, paginator |
10 |
from synnefo.util.rapi import GanetiRapiClient |
|
10 |
from synnefo.util.rapi import GanetiRapiClient, GanetiApiError
|
|
11 | 11 |
|
12 | 12 |
rapi = GanetiRapiClient(*settings.GANETI_CLUSTER_INFO) |
13 | 13 |
|
... | ... | |
49 | 49 |
return self.read_one(request, id) |
50 | 50 |
|
51 | 51 |
def read_one(self, request, id): |
52 |
instance = rapi.GetInstance(id) |
|
53 |
return { "server": instance_to_server(instance) } |
|
52 |
try: |
|
53 |
instance = rapi.GetInstance(id) |
|
54 |
return { "server": instance_to_server(instance) } |
|
55 |
except GanetiApiError: |
|
56 |
raise fault.itemNotFound |
|
54 | 57 |
|
55 | 58 |
@paginator |
56 | 59 |
def read_all(self, request, detail=False): |
Also available in: Unified diff