add log exception hints in some modules

Add hints for log exception messages

Change-Id: I51b30d58bcb4b9fa8e51b29af1cfff33c0b432aa
This commit is contained in:
shuangtai 2014-08-05 14:10:57 +08:00
parent 58b8a68f3c
commit 5a607c814b
7 changed files with 25 additions and 26 deletions

View File

@ -31,7 +31,7 @@ from oslo.config import cfg
from nova.api.ec2 import ec2utils
import nova.cert.rpcapi
from nova import exception
from nova.i18n import _
from nova.i18n import _, _LE
from nova.image import glance
from nova.openstack.common import log as logging
from nova.openstack.common import processutils
@ -328,8 +328,8 @@ class S3ImageService(object):
shutil.copyfileobj(part, combined)
except Exception:
LOG.exception(_("Failed to download %(image_location)s "
"to %(image_path)s"), log_vars)
LOG.exception(_LE("Failed to download %(image_location)s "
"to %(image_path)s"), log_vars)
_update_image_state(context, image_uuid, 'failed_download')
return
@ -345,8 +345,8 @@ class S3ImageService(object):
self._decrypt_image(context, enc_filename, encrypted_key,
encrypted_iv, dec_filename)
except Exception:
LOG.exception(_("Failed to decrypt %(image_location)s "
"to %(image_path)s"), log_vars)
LOG.exception(_LE("Failed to decrypt %(image_location)s "
"to %(image_path)s"), log_vars)
_update_image_state(context, image_uuid, 'failed_decrypt')
return
@ -356,8 +356,8 @@ class S3ImageService(object):
unz_filename = self._untarzip_image(image_path,
dec_filename)
except Exception:
LOG.exception(_("Failed to untar %(image_location)s "
"to %(image_path)s"), log_vars)
LOG.exception(_LE("Failed to untar %(image_location)s "
"to %(image_path)s"), log_vars)
_update_image_state(context, image_uuid, 'failed_untar')
return
@ -366,8 +366,8 @@ class S3ImageService(object):
with open(unz_filename) as image_file:
_update_image_data(context, image_uuid, image_file)
except Exception:
LOG.exception(_("Failed to upload %(image_location)s "
"to %(image_path)s"), log_vars)
LOG.exception(_LE("Failed to upload %(image_location)s "
"to %(image_path)s"), log_vars)
_update_image_state(context, image_uuid, 'failed_upload')
return

View File

@ -24,7 +24,7 @@ import six
from nova import context
from nova import exception
from nova.i18n import _
from nova.i18n import _, _LE
from nova import objects
from nova.objects import fields
from nova.openstack.common import log as logging
@ -83,8 +83,7 @@ def make_class_properties(cls):
return setattr(self, attrname, field_value)
except Exception:
attr = "%s.%s" % (self.obj_name(), name)
LOG.exception(_('Error setting %(attr)s') %
{'attr': attr})
LOG.exception(_LE('Error setting %(attr)s'), {'attr': attr})
raise
setattr(cls, name, property(getter, setter))

View File

@ -17,7 +17,7 @@ from nova.cells import rpcapi as cells_rpcapi
from nova.compute import flavors
from nova import db
from nova import exception
from nova.i18n import _
from nova.i18n import _LE
from nova import notifications
from nova import objects
from nova.objects import base
@ -428,7 +428,7 @@ class Instance(base.NovaPersistentObject, base.NovaObject):
try:
getattr(self, '_save_%s' % field)(context)
except AttributeError:
LOG.exception(_('No save handler for %s') % field,
LOG.exception(_LE('No save handler for %s'), field,
instance=self)
elif field in changes:
updates[field] = self[field]

View File

@ -16,7 +16,7 @@ from nova.cells import opts as cells_opts
from nova.cells import rpcapi as cells_rpcapi
from nova import db
from nova import exception
from nova.i18n import _
from nova.i18n import _LE
from nova.objects import base
from nova.objects import fields
from nova.openstack.common import log as logging
@ -79,8 +79,8 @@ class InstanceInfoCache(base.NovaPersistentObject, base.NovaObject):
try:
cells_api.instance_info_cache_update_at_top(ctxt, info_cache)
except Exception:
LOG.exception(_("Failed to notify cells of instance info "
"cache update"))
LOG.exception(_LE("Failed to notify cells of instance info "
"cache update"))
@base.remotable
def save(self, context, update_cells=True):

View File

@ -18,7 +18,7 @@ import six
from nova import conductor
from nova import context
from nova.i18n import _
from nova.i18n import _, _LE
from nova.openstack.common import log as logging
from nova.openstack.common import timeutils
from nova.servicegroup import api
@ -107,4 +107,4 @@ class DbDriver(api.ServiceGroupDriver):
except Exception: # pylint: disable=W0702
if not getattr(service, 'model_disconnected', False):
service.model_disconnected = True
LOG.exception(_('model server went away'))
LOG.exception(_LE('model server went away'))

View File

@ -21,7 +21,7 @@ from oslo.config import cfg
from nova import conductor
from nova import context
from nova.i18n import _
from nova.i18n import _, _LE
from nova.openstack.common import log as logging
from nova.openstack.common import memorycache
from nova.openstack.common import timeutils
@ -102,4 +102,4 @@ class MemcachedDriver(api.ServiceGroupDriver):
except Exception: # pylint: disable=W0702
if not getattr(service, 'model_disconnected', False):
service.model_disconnected = True
LOG.exception(_('model server went away'))
LOG.exception(_LE('model server went away'))

View File

@ -20,7 +20,7 @@ import eventlet
from oslo.config import cfg
from nova import exception
from nova.i18n import _
from nova.i18n import _, _LE
from nova.openstack.common import importutils
from nova.openstack.common import log as logging
from nova.openstack.common import loopingcall
@ -87,10 +87,10 @@ class ZooKeeperDriver(api.ServiceGroupDriver):
try:
member = membership.Membership(self._session, path, member_id)
except RuntimeError:
LOG.exception(_("Unable to join. It is possible that either "
"another node exists with the same name, or "
"this node just restarted. We will try "
"again in a short while to make sure."))
LOG.exception(_LE("Unable to join. It is possible that either"
" another node exists with the same name, or"
" this node just restarted. We will try "
"again in a short while to make sure."))
eventlet.sleep(CONF.zookeeper.sg_retry_interval)
member = membership.Membership(self._session, path, member_id)
self._memberships[(group, member_id)] = member