Merge lp:~tpatil/nova/bug709510 into lp:~hudson-openstack/nova/trunk

Proposed by Tushar Patil
Status: Merged
Approved by: Vish Ishaya
Approved revision: 643
Merged at revision: 643
Proposed branch: lp:~tpatil/nova/bug709510
Merge into: lp:~hudson-openstack/nova/trunk
Diff against target: 65 lines (+12/-11)
2 files modified
nova/api/ec2/__init__.py (+10/-9)
nova/api/openstack/__init__.py (+2/-2)
To merge this branch: bzr merge lp:~tpatil/nova/bug709510
Reviewer Review Type Date Requested Status
Vish Ishaya (community) Approve
Thierry Carrez (community) gfe Approve
Devin Carlen (community) Approve
Review via email: mp+48078@code.launchpad.net

Commit message

Fix for LP Bug #709510

Description of the change

coerce the exceptions to unicode.

This will work in python 2.x but will fail in python 3.x because unicode function is not supported in 3.x. By default all string are unicode string. When python 3.x will be supported bby nova at that time we will need to port and replace from unicode() to str() again.

To post a comment you must log in.
Revision history for this message
Devin Carlen (devcamcar) wrote :

Seems like this is getting changed back and forth from ex.args[0] to ex. Do we have any kind of consensus here?

review: Needs Information
Revision history for this message
Tushar Patil (tpatil) wrote :

When LP Bug #699654 was fixed at that time itself it should have fixed/reviewed in the right manner. But that didn't happen.

Thanks to Vishy for pointing out the correct way of fixing this problem.

Revision history for this message
Devin Carlen (devcamcar) wrote :

Good and thanks for reference. Just wanted to make sure we're on the same page.

lgtm

review: Approve
Revision history for this message
Thierry Carrez (ttx) wrote :

Looks good to me, if this can get reviewed/merged today.

review: Approve (gfe)
Revision history for this message
Vish Ishaya (vishvananda) wrote :

lgtm

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'nova/api/ec2/__init__.py'
--- nova/api/ec2/__init__.py 2011-01-27 22:10:42 +0000
+++ nova/api/ec2/__init__.py 2011-01-31 22:55:55 +0000
@@ -171,7 +171,7 @@
171 req.path)171 req.path)
172 # Be explicit for what exceptions are 403, the rest bubble as 500172 # Be explicit for what exceptions are 403, the rest bubble as 500
173 except (exception.NotFound, exception.NotAuthorized) as ex:173 except (exception.NotFound, exception.NotAuthorized) as ex:
174 LOG.audit(_("Authentication Failure: %s"), ex.args[0])174 LOG.audit(_("Authentication Failure: %s"), unicode(ex))
175 raise webob.exc.HTTPForbidden()175 raise webob.exc.HTTPForbidden()
176176
177 # Authenticated!177 # Authenticated!
@@ -316,30 +316,31 @@
316 try:316 try:
317 result = api_request.invoke(context)317 result = api_request.invoke(context)
318 except exception.InstanceNotFound as ex:318 except exception.InstanceNotFound as ex:
319 LOG.info(_('InstanceNotFound raised: %s'), ex.args[0],319 LOG.info(_('InstanceNotFound raised: %s'), unicode(ex),
320 context=context)320 context=context)
321 ec2_id = cloud.id_to_ec2_id(ex.instance_id)321 ec2_id = cloud.id_to_ec2_id(ex.instance_id)
322 message = _('Instance %s not found') % ec2_id322 message = _('Instance %s not found') % ec2_id
323 return self._error(req, context, type(ex).__name__, message)323 return self._error(req, context, type(ex).__name__, message)
324 except exception.VolumeNotFound as ex:324 except exception.VolumeNotFound as ex:
325 LOG.info(_('VolumeNotFound raised: %s'), ex.args[0],325 LOG.info(_('VolumeNotFound raised: %s'), unicode(ex),
326 context=context)326 context=context)
327 ec2_id = cloud.id_to_ec2_id(ex.volume_id, 'vol-%08x')327 ec2_id = cloud.id_to_ec2_id(ex.volume_id, 'vol-%08x')
328 message = _('Volume %s not found') % ec2_id328 message = _('Volume %s not found') % ec2_id
329 return self._error(req, context, type(ex).__name__, message)329 return self._error(req, context, type(ex).__name__, message)
330 except exception.NotFound as ex:330 except exception.NotFound as ex:
331 LOG.info(_('NotFound raised: %s'), ex.args[0], context=context)331 LOG.info(_('NotFound raised: %s'), unicode(ex), context=context)
332 return self._error(req, context, type(ex).__name__, ex.args[0])332 return self._error(req, context, type(ex).__name__, unicode(ex))
333 except exception.ApiError as ex:333 except exception.ApiError as ex:
334 LOG.exception(_('ApiError raised: %s'), ex.args[0],334 LOG.exception(_('ApiError raised: %s'), unicode(ex),
335 context=context)335 context=context)
336 if ex.code:336 if ex.code:
337 return self._error(req, context, ex.code, ex.args[0])337 return self._error(req, context, ex.code, unicode(ex))
338 else:338 else:
339 return self._error(req, context, type(ex).__name__, ex.args[0])339 return self._error(req, context, type(ex).__name__,
340 unicode(ex))
340 except Exception as ex:341 except Exception as ex:
341 extra = {'environment': req.environ}342 extra = {'environment': req.environ}
342 LOG.exception(_('Unexpected error raised: %s'), ex.args[0],343 LOG.exception(_('Unexpected error raised: %s'), unicode(ex),
343 extra=extra, context=context)344 extra=extra, context=context)
344 return self._error(req,345 return self._error(req,
345 context,346 context,
346347
=== modified file 'nova/api/openstack/__init__.py'
--- nova/api/openstack/__init__.py 2011-01-22 21:20:09 +0000
+++ nova/api/openstack/__init__.py 2011-01-31 22:55:55 +0000
@@ -51,8 +51,8 @@
51 try:51 try:
52 return req.get_response(self.application)52 return req.get_response(self.application)
53 except Exception as ex:53 except Exception as ex:
54 LOG.exception(_("Caught error: %s"), str(ex))54 LOG.exception(_("Caught error: %s"), unicode(ex))
55 exc = webob.exc.HTTPInternalServerError(explanation=str(ex))55 exc = webob.exc.HTTPInternalServerError(explanation=unicode(ex))
56 return faults.Fault(exc)56 return faults.Fault(exc)
5757
5858