summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorIlya Alekseyev <ialekseev@griddynamics.com>2011-06-25 02:12:24 +0400
committerIlya Alekseyev <ialekseev@griddynamics.com>2011-06-25 02:12:24 +0400
commit310f731b2422a11a2afab45b2f14a78a78733f6b (patch)
tree335859b33d471488e46b0f9309dfe3f7e0484f1e /nova/api
parentcbd0622ffbd021d404270be8b35b3e4839dd0ea0 (diff)
parentee82eb5916cd87ee984d00a07759d7c7648c6976 (diff)
some tests and refactoring
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/openstack/contrib/floating_ips.py29
1 files changed, 16 insertions, 13 deletions
diff --git a/nova/api/openstack/contrib/floating_ips.py b/nova/api/openstack/contrib/floating_ips.py
index 924b504a8..c6bc85c61 100644
--- a/nova/api/openstack/contrib/floating_ips.py
+++ b/nova/api/openstack/contrib/floating_ips.py
@@ -82,39 +82,45 @@ class FloatingIPController(object):
context = req.environ['nova.context']
try:
- ip = self.network_api.allocate_floating_ip(context)
+ address = self.network_api.allocate_floating_ip(context)
+ ip = self.network_api.get_floating_ip_by_ip(context, address)
except rpc.RemoteError as ex:
if ex.exc_type == 'NoMoreAddresses':
raise exception.NoMoreFloatingIps()
else:
raise
- return {'allocated': ip}
+ return {'allocated': {
+ "id" : ip['id'],
+ "floating_ip": ip['address']}}
def delete(self, req, id):
context = req.environ['nova.context']
-
- ip = self._get_ip_by_id(context, id)
+
+ ip = self.network_api.get(context, id)
self.network_api.release_floating_ip(context, address=ip)
- return {'released': ip}
+ return {'released': {
+ "id": ip['id'],
+ "floating_ip": ip['address']}}
def associate(self, req, id_ip, body):
- """ /floating_ips/ip or id/associate fixed ip in body """
+ """ /floating_ips/{id}/associate fixed ip in body """
context = req.environ['nova.context']
floating_ip = self._get_ip_by_id(context, id_ip)
fixed_ip = body['associate_address']['fixed_ip']
try:
- self.network_api.associate_floating_ip(context, floating_ip, fixed_ip)
+ 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 """
+ """ POST /floating_ips/{id}/disassociate """
context = req.environ['nova.context']
floating_ip = self._get_ip_by_id(context, id_ip)
@@ -127,11 +133,8 @@ class FloatingIPController(object):
return {'disassociated': floating_ip}
def _get_ip_by_id(self, context, value):
- """Checks that value is id and then returns its address.
- If value is ip then return value."""
- if value.isdigit():
- return self.network_api.get(context, value)['address']
- return value
+ """Checks that value is id and then returns its address."""
+ return self.network_api.get(context, value)['address']
class Floating_ips(extensions.ExtensionDescriptor):