Revision 29685b9b kamaki/clients/cyclades.py
b/kamaki/clients/cyclades.py | ||
---|---|---|
31 | 31 |
# interpreted as representing official policies, either expressed |
32 | 32 |
# or implied, of GRNET S.A. |
33 | 33 |
|
34 |
from kamaki.clients.compute import ComputeClient, ClientError |
|
35 |
from kamaki.clients.utils import path4url |
|
36 |
import json |
|
34 |
from kamaki.clients.cyclades_rest_api import CycladesClientApi |
|
35 |
from kamaki.clients import ClientError |
|
37 | 36 |
from time import sleep |
38 | 37 |
|
39 | 38 |
|
40 |
class CycladesClient(ComputeClient):
|
|
39 |
class CycladesClient(CycladesClientApi):
|
|
41 | 40 |
"""GRNet Cyclades API client""" |
42 | 41 |
|
43 |
def networks_get(self, network_id='', command='', **kwargs): |
|
44 |
"""GET base_url/networks[/network_id][/command] request |
|
45 |
@param network_id or '' |
|
46 |
@param command can be 'detail', or '' |
|
47 |
""" |
|
48 |
path = path4url('networks', network_id, command) |
|
49 |
success = kwargs.pop('success', (200, 203)) |
|
50 |
return self.get(path, success=success, **kwargs) |
|
51 |
|
|
52 |
def networks_delete(self, network_id='', command='', **kwargs): |
|
53 |
"""DEL ETE base_url/networks[/network_id][/command] request |
|
54 |
@param network_id or '' |
|
55 |
@param command can be 'detail', or '' |
|
56 |
""" |
|
57 |
path = path4url('networks', network_id, command) |
|
58 |
success = kwargs.pop('success', 204) |
|
59 |
return self.delete(path, success=success, **kwargs) |
|
60 |
|
|
61 |
def networks_post(self, |
|
62 |
network_id='', |
|
63 |
command='', |
|
64 |
json_data=None, |
|
65 |
**kwargs): |
|
66 |
"""POST base_url/servers[/server_id]/[command] request |
|
67 |
@param server_id or '' |
|
68 |
@param command: can be 'action' or '' |
|
69 |
@param json_data: a json valid dict that will be send as data |
|
70 |
""" |
|
71 |
data = json_data |
|
72 |
if json_data is not None: |
|
73 |
data = json.dumps(json_data) |
|
74 |
self.set_header('Content-Type', 'application/json') |
|
75 |
self.set_header('Content-Length', len(data)) |
|
76 |
|
|
77 |
path = path4url('networks', network_id, command) |
|
78 |
success = kwargs.pop('success', 202) |
|
79 |
return self.post(path, data=data, success=success, **kwargs) |
|
80 |
|
|
81 |
def networks_put(self, |
|
82 |
network_id='', |
|
83 |
command='', |
|
84 |
json_data=None, |
|
85 |
**kwargs): |
|
86 |
"""PUT base_url/servers[/server_id]/[command] request |
|
87 |
@param server_id or '' |
|
88 |
@param command: can be 'action' or '' |
|
89 |
@param json_data: a json valid dict that will be send as data |
|
90 |
""" |
|
91 |
data = json_data |
|
92 |
if json_data is not None: |
|
93 |
data = json.dumps(json_data) |
|
94 |
self.set_header('Content-Type', 'application/json') |
|
95 |
self.set_header('Content-Length', len(data)) |
|
96 |
|
|
97 |
path = path4url('networks', network_id, command) |
|
98 |
success = kwargs.pop('success', 204) |
|
99 |
return self.put(path, data=data, success=success, **kwargs) |
|
100 |
|
|
101 | 42 |
def start_server(self, server_id): |
102 | 43 |
"""Submit a startup request for a server specified by id""" |
103 | 44 |
req = {'start': {}} |
Also available in: Unified diff