From 1b7f77f22d847803a24b66a9f6c08dc4a564bddb Mon Sep 17 00:00:00 2001 From: "Mauro S. M. Rodrigues" Date: Wed, 22 May 2013 02:01:22 -0400 Subject: Fix postgresql failures related to Data type Postgresql is kind of sensitive about different kind of data in a query, so it was failing in cases like lookin for an ip using a filter which wasn't a valid ip or ids values greater than the id type on the table. This patch fix this behavior to fixed ips and floating ips. Fixes bug 1182754 Change-Id: I83d532c28c9aec690e8e1ffad8b58e71d619d728 --- nova/api/openstack/compute/contrib/fixed_ips.py | 7 +++++-- nova/api/openstack/compute/contrib/floating_ips.py | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'nova/api') diff --git a/nova/api/openstack/compute/contrib/fixed_ips.py b/nova/api/openstack/compute/contrib/fixed_ips.py index 8c7e4f7d3..b474b685d 100644 --- a/nova/api/openstack/compute/contrib/fixed_ips.py +++ b/nova/api/openstack/compute/contrib/fixed_ips.py @@ -31,7 +31,8 @@ class FixedIPController(object): try: fixed_ip = db.fixed_ip_get_by_address_detailed(context, id) - except exception.FixedIpNotFoundForAddress as ex: + except (exception.FixedIpNotFoundForAddress, + exception.FixedIpInvalid) as ex: raise webob.exc.HTTPNotFound(explanation=ex.format_message()) fixed_ip_info = {"fixed_ip": {}} @@ -54,6 +55,7 @@ class FixedIPController(object): def action(self, req, id, body): context = req.environ['nova.context'] authorize(context) + if 'reserve' in body: return self._set_reserved(context, id, True) elif 'unreserve' in body: @@ -67,7 +69,8 @@ class FixedIPController(object): fixed_ip = db.fixed_ip_get_by_address(context, address) db.fixed_ip_update(context, fixed_ip['address'], {'reserved': reserved}) - except exception.FixedIpNotFoundForAddress: + except (exception.FixedIpNotFoundForAddress, + exception.FixedIpInvalid) as ex: msg = _("Fixed IP %s not found") % address raise webob.exc.HTTPNotFound(explanation=msg) diff --git a/nova/api/openstack/compute/contrib/floating_ips.py b/nova/api/openstack/compute/contrib/floating_ips.py index a3d03e8de..284a211cd 100644 --- a/nova/api/openstack/compute/contrib/floating_ips.py +++ b/nova/api/openstack/compute/contrib/floating_ips.py @@ -125,7 +125,7 @@ class FloatingIPController(object): try: floating_ip = self.network_api.get_floating_ip(context, id) - except exception.NotFound: + except (exception.NotFound, exception.InvalidID): msg = _("Floating ip not found for id %s") % id raise webob.exc.HTTPNotFound(explanation=msg) @@ -173,7 +173,7 @@ class FloatingIPController(object): # get the floating ip object try: floating_ip = self.network_api.get_floating_ip(context, id) - except exception.NotFound: + except (exception.NotFound, exception.InvalidID): msg = _("Floating ip not found for id %s") % id raise webob.exc.HTTPNotFound(explanation=msg) address = floating_ip['address'] -- cgit