summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorKirill Shileev <kshileev@griddynamics.com>2011-06-24 20:59:32 +0400
committerKirill Shileev <kshileev@griddynamics.com>2011-06-24 20:59:32 +0400
commitc5745c0cb61bb6ab375a1e52d5e203a7a0a76366 (patch)
treefd52a881a12e9e29b81d9fd976393c9ab4bb8b80 /nova/api
parentc2216547d0c55e32a4f8203129f4604f4ba004c7 (diff)
associate diassociate untested, first attept to test
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/openstack/contrib/floating_ips.py27
1 files changed, 22 insertions, 5 deletions
diff --git a/nova/api/openstack/contrib/floating_ips.py b/nova/api/openstack/contrib/floating_ips.py
index dc048869c..23864c352 100644
--- a/nova/api/openstack/contrib/floating_ips.py
+++ b/nova/api/openstack/contrib/floating_ips.py
@@ -43,7 +43,7 @@ def _translate_floating_ips_view(floating_ips):
class FloatingIPController(object):
- """The Volumes API controller for the OpenStack API."""
+ """The Floating IPs API controller for the OpenStack API."""
_serialization_metadata = {
'application/xml': {
@@ -98,15 +98,32 @@ class FloatingIPController(object):
return {'released': ip}
- def associate(self, req, id, body):
+ def associate(self, req, id_ip, body):
+ """ /floating_ips/ip or id/associate fixed ip in body """
context = req.environ['nova.context']
+ floating_ip = self._get_ip_by_id(context, id_ip)
- return {'associate': None}
+ fixed_ip = body['associate_address']['fixed_ip']
- def disassociate(self, req, id, body):
+ try:
+ self.network_api.associate_floating_ip(context, floating_ip, fixed_ip)
+ except rpc.RemoteError:
+ raise
+
+ return {'associated': [floating_ip, fixed_ip]}
+
+ def disassociate(self, req, id_ip, body):
+ """ POST /floating_ips/{ip | ip_id}/disassociate """
context = req.environ['nova.context']
- return {'disassociate': None}
+ floating_ip = self._get_ip_by_id(context, id_ip)
+
+ try:
+ self.network_api.disassociate_floating_ip(context, floating_ip)
+ except rpc.RemoteError:
+ raise
+
+ return {'disassociated': floating_ip}
def _get_ip_by_id(self, context, value):
"""Checks that value is id and then returns its address.