diff options
| author | Alex Meade <alex.meade@rackspace.com> | 2012-03-21 19:13:16 +0000 |
|---|---|---|
| committer | Alex Meade <alex.meade@rackspace.com> | 2012-04-06 14:55:50 -0400 |
| commit | a0150a4d9e751ec222221558dfe89a66b0c118ab (patch) | |
| tree | e0eedb7c735b80e4c2e6d416acc66237874ad1e2 /nova/api | |
| parent | b573276e00f486120b35d84b892df2c0fa617acc (diff) | |
Add the serialization of exceptions for RPC calls.
This change uses json to serialize an exception so that it can be sent
through RPC calls to be reconstructed on the other side. The traceback is added
to the exception message. If recreating the exception fails for whatever reason
then a RemoteError is created containing all of the exception information.
Adds flag 'allowed_rpc_exception_modules' to prevent dangerous modules from
being accessed and allowing arbitrary code to be run.
Fixes bug 920705
Fixes bug 940500
Change-Id: Ife3b64b19fe8abbc730184d4ee7d9fcabfd29db3
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/ec2/cloud.py | 12 | ||||
| -rw-r--r-- | nova/api/openstack/compute/contrib/floating_ips.py | 17 |
2 files changed, 7 insertions, 22 deletions
diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py index 2ff5b32c6..9346d107b 100644 --- a/nova/api/ec2/cloud.py +++ b/nova/api/ec2/cloud.py @@ -41,7 +41,6 @@ from nova import flags from nova.image import s3 from nova import log as logging from nova import network -from nova.rpc import common as rpc_common from nova import utils from nova import volume @@ -1253,15 +1252,8 @@ class CloudController(object): def allocate_address(self, context, **kwargs): LOG.audit(_("Allocate address"), context=context) - try: - public_ip = self.network_api.allocate_floating_ip(context) - return {'publicIp': public_ip} - except rpc_common.RemoteError as ex: - # NOTE(tr3buchet) - why does this block exist? - if ex.exc_type == 'NoMoreFloatingIps': - raise exception.NoMoreFloatingIps() - else: - raise + public_ip = self.network_api.allocate_floating_ip(context) + return {'publicIp': public_ip} def release_address(self, context, public_ip, **kwargs): LOG.audit(_("Release address %s"), public_ip, context=context) diff --git a/nova/api/openstack/compute/contrib/floating_ips.py b/nova/api/openstack/compute/contrib/floating_ips.py index 6b9e9e97c..4a5cec8d2 100644 --- a/nova/api/openstack/compute/contrib/floating_ips.py +++ b/nova/api/openstack/compute/contrib/floating_ips.py @@ -152,16 +152,12 @@ class FloatingIPController(object): try: address = self.network_api.allocate_floating_ip(context, pool) ip = self.network_api.get_floating_ip_by_address(context, address) - except rpc_common.RemoteError as ex: - # NOTE(tr3buchet) - why does this block exist? - if ex.exc_type == 'NoMoreFloatingIps': - if pool: - msg = _("No more floating ips in pool %s.") % pool - else: - msg = _("No more floating ips available.") - raise webob.exc.HTTPBadRequest(explanation=msg) + except exception.NoMoreFloatingIps: + if pool: + msg = _("No more floating ips in pool %s.") % pool else: - raise + msg = _("No more floating ips available.") + raise webob.exc.HTTPBadRequest(explanation=msg) return _translate_floating_ip_view(ip) @@ -212,9 +208,6 @@ class FloatingIPActionController(wsgi.Controller): except exception.FixedIpNotFoundForInstance: msg = _("No fixed ips associated to instance") raise webob.exc.HTTPBadRequest(explanation=msg) - except rpc_common.RemoteError: - msg = _("Associate floating ip failed") - raise webob.exc.HTTPInternalServerError(explanation=msg) return webob.Response(status_int=202) |
