Revision b4368e33 kamaki/clients/commissioning_client.py
b/kamaki/clients/commissioning_client.py | ||
---|---|---|
31 | 31 |
# interpreted as representing official policies, either expressed |
32 | 32 |
# or implied, of GRNET S.A. |
33 | 33 |
|
34 |
from synnefo.lib.commissioning import Callpoint, CallError
|
|
35 |
from synnefo.lib.commissioning.utils.debug import debug
|
|
36 |
from . import Client
|
|
34 |
from kamaki.clients.commissioning import Callpoint, CallError
|
|
35 |
from kamaki.clients.commissioning.utils.debug import debug
|
|
36 |
from kamaki.clients import Client
|
|
37 | 37 |
|
38 | 38 |
from json import loads as json_loads, dumps as json_dumps |
39 | 39 |
|
40 |
|
|
40 | 41 |
class CommissioningClient(Callpoint): |
41 | 42 |
|
42 | 43 |
def __init__(self, base_url, token): |
... | ... | |
46 | 47 |
def do_make_call(self, api_call, data): |
47 | 48 |
|
48 | 49 |
_kc = self._kc |
49 |
|
|
50 |
|
|
50 | 51 |
gettable = ['list', 'get', 'read'] |
51 | 52 |
method = (_kc.get if any(api_call.startswith(x) for x in gettable) |
52 | 53 |
else _kc.post) |
... | ... | |
54 | 55 |
path = api_call |
55 | 56 |
json_data = json_dumps(data) |
56 | 57 |
debug("%s %s\n%s\n<<<\n", method.func_name, path, json_data) |
57 |
|
|
58 |
resp = method(path, data=json_data, success=(200,450,500))
|
|
58 |
|
|
59 |
resp = method(path, data=json_data, success=(200, 450, 500))
|
|
59 | 60 |
debug(">>>\nStatus: %s", resp.status_code) |
60 |
|
|
61 |
|
|
61 | 62 |
body = resp.text |
62 | 63 |
debug("\n%s\n<<<\n", body[:128] if body else None) |
63 | 64 |
|
Also available in: Unified diff