Please test with the below patch. If see any problem in this patch please let me know. Thanks.
=== 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-29 00:03:03 +0000 @@ -171,7 +171,7 @@ req.path) # Be explicit for what exceptions are 403, the rest bubble as 500 except (exception.NotFound, exception.NotAuthorized) as ex: - LOG.audit(_("Authentication Failure: %s"), ex.args[0]) + LOG.audit(_("Authentication Failure: %s"), utils.utf8(ex)) raise webob.exc.HTTPForbidden()
# Authenticated! @@ -316,30 +316,31 @@ try: result = api_request.invoke(context) except exception.InstanceNotFound as ex: - LOG.info(_('InstanceNotFound raised: %s'), ex.args[0], + LOG.info(_('InstanceNotFound raised: %s'), utils.utf8(ex), context=context) ec2_id = cloud.id_to_ec2_id(ex.instance_id) message = _('Instance %s not found') % ec2_id return self._error(req, context, type(ex).__name__, message) except exception.VolumeNotFound as ex: - LOG.info(_('VolumeNotFound raised: %s'), ex.args[0], + LOG.info(_('VolumeNotFound raised: %s'), utils.utf8(ex), context=context) ec2_id = cloud.id_to_ec2_id(ex.volume_id, 'vol-%08x') message = _('Volume %s not found') % ec2_id return self._error(req, context, type(ex).__name__, message) except exception.NotFound as ex: - LOG.info(_('NotFound raised: %s'), ex.args[0], context=context) - return self._error(req, context, type(ex).__name__, ex.args[0]) + LOG.info(_('NotFound raised: %s'), utils.utf8(ex), context=context) + return self._error(req, context, type(ex).__name__, utils.utf8(ex)) except exception.ApiError as ex: - LOG.exception(_('ApiError raised: %s'), ex.args[0], + LOG.exception(_('ApiError raised: %s'), utils.utf8(ex), context=context) if ex.code: - return self._error(req, context, ex.code, ex.args[0]) + return self._error(req, context, ex.code, utils.utf8(ex)) else: - return self._error(req, context, type(ex).__name__, ex.args[0]) + return self._error(req, context, type(ex).__name_, + utils.utf8(ex)) except Exception as ex: extra = {'environment': req.environ} - LOG.exception(_('Unexpected error raised: %s'), ex.args[0], + LOG.exception(_('Unexpected error raised: %s'), utils.utf8(ex), extra=extra, context=context) return self._error(req, context,
=== modified file 'nova/utils.py' --- nova/utils.py 2011-01-27 19:52:10 +0000 +++ nova/utils.py 2011-01-28 23:45:43 +0000 @@ -405,6 +405,12 @@ """ if isinstance(value, unicode): return value.encode("utf-8") + if isinstance(value, Exception): + if value.args: + return value.args[0].encode("utf-8") + else: + return "" + assert isinstance(value, str) return value
Please test with the below patch. If see any problem in this patch please let me know. Thanks.
=== modified file 'nova/api/ ec2/__init_ _.py' ec2/__init_ _.py 2011-01-27 22:10:42 +0000 ec2/__init_ _.py 2011-01-29 00:03:03 +0000
req.path) NotFound, exception. NotAuthorized) as ex: _("Authenticati on Failure: %s"), ex.args[0]) _("Authenticati on Failure: %s"), utils.utf8(ex)) HTTPForbidden( )
--- nova/api/
+++ nova/api/
@@ -171,7 +171,7 @@
# Be explicit for what exceptions are 403, the rest bubble as 500
except (exception.
- LOG.audit(
+ LOG.audit(
raise webob.exc.
# Authenticated! invoke( context) InstanceNotFoun d as ex: _('InstanceNotF ound raised: %s'), ex.args[0], _('InstanceNotF ound raised: %s'), utils.utf8(ex),
context= context) to_ec2_ id(ex.instance_ id)
message = _('Instance %s not found') % ec2_id VolumeNotFound as ex: _('VolumeNotFou nd raised: %s'), ex.args[0], _('VolumeNotFou nd raised: %s'), utils.utf8(ex),
context= context) to_ec2_ id(ex.volume_ id, 'vol-%08x')
message = _('Volume %s not found') % ec2_id _('NotFound raised: %s'), ex.args[0], context=context) _('NotFound raised: %s'), utils.utf8(ex), context=context) _('ApiError raised: %s'), ex.args[0], _('ApiError raised: %s'), utils.utf8(ex),
context= context) _('Unexpected error raised: %s'), ex.args[0], _('Unexpected error raised: %s'), utils.utf8(ex),
extra= extra, context=context)
context,
@@ -316,30 +316,31 @@
try:
result = api_request.
except exception.
- LOG.info(
+ LOG.info(
ec2_id = cloud.id_
return self._error(req, context, type(ex).__name__, message)
except exception.
- LOG.info(
+ LOG.info(
ec2_id = cloud.id_
return self._error(req, context, type(ex).__name__, message)
except exception.NotFound as ex:
- LOG.info(
- return self._error(req, context, type(ex).__name__, ex.args[0])
+ LOG.info(
+ return self._error(req, context, type(ex).__name__, utils.utf8(ex))
except exception.ApiError as ex:
- LOG.exception(
+ LOG.exception(
if ex.code:
- return self._error(req, context, ex.code, ex.args[0])
+ return self._error(req, context, ex.code, utils.utf8(ex))
else:
- return self._error(req, context, type(ex).__name__, ex.args[0])
+ return self._error(req, context, type(ex).__name_,
+ utils.utf8(ex))
except Exception as ex:
extra = {'environment': req.environ}
- LOG.exception(
+ LOG.exception(
return self._error(req,
=== modified file 'nova/utils.py' "utf-8" ) 0].encode( "utf-8" )
--- nova/utils.py 2011-01-27 19:52:10 +0000
+++ nova/utils.py 2011-01-28 23:45:43 +0000
@@ -405,6 +405,12 @@
"""
if isinstance(value, unicode):
return value.encode(
+ if isinstance(value, Exception):
+ if value.args:
+ return value.args[
+ else:
+ return ""
+
assert isinstance(value, str)
return value