summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorSulochan Acharya <sulochan@gmail.com>2012-09-17 11:42:07 -0500
committerSulochan Acharya <sulochan@gmail.com>2012-09-20 04:47:10 -0500
commit9a303f2cc231f5d43257ebced5b1167c08d32648 (patch)
treea2dac926358190a8208c6bfdf0686cd819d7d11b /nova/api
parent9536b3fa9861e4b9c93b5cf0a91451a92c5df92c (diff)
Catch NotFound exception in FloatingIP add/remove
Catch the FloatingIPNotFoundForAddress exception for add/remove operations in floating ip extension for non existing floating ips. Fixes bug 977536 Change-Id: Ied450aa56ef7a52a015c6d78a099d445ab6258b6
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/openstack/compute/contrib/floating_ips.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/nova/api/openstack/compute/contrib/floating_ips.py b/nova/api/openstack/compute/contrib/floating_ips.py
index f3692e02e..038e2cea5 100644
--- a/nova/api/openstack/compute/contrib/floating_ips.py
+++ b/nova/api/openstack/compute/contrib/floating_ips.py
@@ -254,6 +254,9 @@ class FloatingIPActionController(wsgi.Controller):
except exception.NoFloatingIpInterface:
msg = _('l3driver call to add floating ip failed')
raise webob.exc.HTTPBadRequest(explanation=msg)
+ except exception.FloatingIpNotFoundForAddress:
+ msg = _('floating ip not found')
+ raise webob.exc.HTTPNotFound(explanation=msg)
except Exception:
msg = _('Error. Unable to associate floating ip')
LOG.exception(msg)
@@ -277,8 +280,13 @@ class FloatingIPActionController(wsgi.Controller):
raise webob.exc.HTTPBadRequest(explanation=msg)
# get the floating ip object
- floating_ip = self.network_api.get_floating_ip_by_address(context,
- address)
+ try:
+ floating_ip = self.network_api.get_floating_ip_by_address(context,
+ address)
+ except exception.FloatingIpNotFoundForAddress:
+ msg = _("floating ip not found")
+ raise webob.exc.HTTPNotFound(explanation=msg)
+
# get the associated instance object (if any)
instance = get_instance_by_floating_ip_addr(self, context, address)