diff options
| author | Ilya Alekseyev <ialekseev@griddynamics.com> | 2011-06-23 04:28:42 +0400 |
|---|---|---|
| committer | Ilya Alekseyev <ialekseev@griddynamics.com> | 2011-06-23 04:28:42 +0400 |
| commit | b7684e0d36010050ce8254bbbf4573a6a624fa69 (patch) | |
| tree | f4d91fa8c65e0152d6d4de578b8cf7c041e4292d | |
| parent | 971efd1b5568c324c91e826fc347c49ceea3790c (diff) | |
| download | nova-b7684e0d36010050ce8254bbbf4573a6a624fa69.tar.gz nova-b7684e0d36010050ce8254bbbf4573a6a624fa69.tar.xz nova-b7684e0d36010050ce8254bbbf4573a6a624fa69.zip | |
allocate and release implementation
| -rw-r--r-- | nova/api/openstack/contrib/floating_ips.py | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/nova/api/openstack/contrib/floating_ips.py b/nova/api/openstack/contrib/floating_ips.py index f7a939ddd..9bad6806c 100644 --- a/nova/api/openstack/contrib/floating_ips.py +++ b/nova/api/openstack/contrib/floating_ips.py @@ -18,6 +18,7 @@ from webob import exc from nova import exception from nova import network +from nova import rpc from nova.api.openstack import faults from nova.api.openstack import extensions @@ -69,12 +70,27 @@ class FloatingIPController(object): def create(self, req, body): context = req.environ['nova.context'] - return {'allocate': None} + try: + ip = self.network_api.allocate_floating_ip(context) + except rpc.RemoteError as ex: + if ex.exc_type == 'NoMoreAddresses': + raise exception.NoMoreFloatingIps() + else: + raise + + return {'allocated': ip} def delete(self,req, id): context = req.environ['nova.context'] - return {'release': None } + if id.isdigit(): + ip = self.network_api.get(id) + else: + ip = id + + self.network_api.release_floating_ip(context, address=ip) + + return {'released': ip } def associate(self, req, id, body): context = req.environ['nova.context'] |
