Revision f1e45161 kamaki/clients/cyclades/__init__.py
b/kamaki/clients/cyclades/__init__.py | ||
---|---|---|
37 | 37 |
from kamaki.clients import ClientError, Waiter |
38 | 38 |
import json |
39 | 39 |
|
40 |
|
|
40 | 41 |
class CycladesClient(CycladesRestClient, Waiter): |
41 | 42 |
"""Synnefo Cyclades Compute API client""" |
42 | 43 |
|
... | ... | |
199 | 200 |
r = self.networks_post(json_data=req, success=201) |
200 | 201 |
return r.json['network'] |
201 | 202 |
|
202 |
def networks_action_post( |
|
203 |
self, network_id='', json_data=None, success=202, **kwargs): |
|
203 |
def reassign_network(self, network_id, project, **kwargs): |
|
204 | 204 |
"""POST base_url/networks/<network_id>/action |
205 | 205 |
|
206 | 206 |
:returns: request response |
207 | 207 |
""" |
208 |
if json_data: |
|
209 |
json_data = json.dumps(json_data) |
|
210 |
self.set_header('Content-Type', 'application/json') |
|
211 |
self.set_header('Content-Length', len(json_data)) |
|
212 | 208 |
path = path4url('networks', network_id, 'action') |
213 |
return self.post(path, data=json_data, success=success, **kwargs) |
|
214 |
|
|
215 |
def reassign_network(self, network_id, project): |
|
216 | 209 |
req = {'reassign': {'project': project}} |
217 |
r = self.networks_action_post(network_id, json_data=req, success=200)
|
|
210 |
r = self.post(path, json=req, success=200, **kwargs)
|
|
218 | 211 |
return r.headers |
219 | 212 |
|
220 | 213 |
def list_ports(self, detail=None): |
... | ... | |
257 | 250 |
floatingip['floating_network_id'] = floating_network_id |
258 | 251 |
if floating_ip_address: |
259 | 252 |
floatingip['floating_ip_address'] = floating_ip_address |
260 |
if project_id: |
|
253 |
if project_id is not None:
|
|
261 | 254 |
floatingip['project'] = project_id |
262 | 255 |
r = self.floatingips_post( |
263 | 256 |
json_data=dict(floatingip=floatingip), success=200) |
Also available in: Unified diff