From 9a303f2cc231f5d43257ebced5b1167c08d32648 Mon Sep 17 00:00:00 2001 From: Sulochan Acharya Date: Mon, 17 Sep 2012 11:42:07 -0500 Subject: 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 --- nova/api/openstack/compute/contrib/floating_ips.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'nova/api') 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) -- cgit