From 296403319182a62c737363872f9e57d56bc2669d Mon Sep 17 00:00:00 2001 From: daisy-ycguo Date: Mon, 19 Nov 2012 14:07:16 +0800 Subject: Wrap log messages with _() bug 1075082 There are a few log messages without _(), but a lot messages with _(). Wrap these log messages with _() in order to make the code consistent. Change-Id: Ibaff2c352df925f7e00d5a62d111ef73f60c944b --- nova/api/ec2/__init__.py | 2 +- nova/compute/resource_tracker.py | 2 +- nova/db/sqlalchemy/session.py | 2 +- nova/network/api.py | 2 +- nova/network/ldapdns.py | 13 ++++++++----- nova/network/linux_net.py | 2 +- nova/notifications.py | 2 +- nova/openstack/common/rpc/amqp.py | 2 +- nova/virt/fake.py | 5 +++-- nova/virt/xenapi/host.py | 4 ++-- 10 files changed, 20 insertions(+), 16 deletions(-) (limited to 'nova') diff --git a/nova/api/ec2/__init__.py b/nova/api/ec2/__init__.py index 28b946a8b..22771b589 100644 --- a/nova/api/ec2/__init__.py +++ b/nova/api/ec2/__init__.py @@ -256,7 +256,7 @@ class EC2KeystoneAuth(wsgi.Middleware): roles = [role['name'] for role in result['access']['user']['roles']] except (AttributeError, KeyError), e: - LOG.exception("Keystone failure: %s" % e) + LOG.exception(_("Keystone failure: %s") % e) msg = _("Failure communicating with keystone") return ec2_error(req, request_id, "Unauthorized", msg) diff --git a/nova/compute/resource_tracker.py b/nova/compute/resource_tracker.py index e1f8f8653..17d0869ad 100644 --- a/nova/compute/resource_tracker.py +++ b/nova/compute/resource_tracker.py @@ -370,7 +370,7 @@ class ResourceTracker(object): represent an incoming or outbound migration. """ uuid = migration['instance_uuid'] - LOG.audit("Updating from migration %s" % uuid) + LOG.audit(_("Updating from migration %s") % uuid) incoming = (migration['dest_compute'] == self.host) outbound = (migration['source_compute'] == self.host) diff --git a/nova/db/sqlalchemy/session.py b/nova/db/sqlalchemy/session.py index 6ff2b4e3b..cad690401 100644 --- a/nova/db/sqlalchemy/session.py +++ b/nova/db/sqlalchemy/session.py @@ -251,7 +251,7 @@ def ping_listener(dbapi_conn, connection_rec, connection_proxy): dbapi_conn.cursor().execute('select 1') except dbapi_conn.OperationalError, ex: if ex.args[0] in (2006, 2013, 2014, 2045, 2055): - LOG.warn('Got mysql server has gone away: %s', ex) + LOG.warn(_('Got mysql server has gone away: %s'), ex) raise DisconnectionError("Database server went away") else: raise diff --git a/nova/network/api.py b/nova/network/api.py index 2c0ddb05f..bd12e73c0 100644 --- a/nova/network/api.py +++ b/nova/network/api.py @@ -74,7 +74,7 @@ def update_instance_cache_with_nw_info(api, context, instance, cache = {'network_info': nw_info.json()} api.db.instance_info_cache_update(context, instance['uuid'], cache) except Exception as e: - LOG.exception('Failed storing info cache', instance=instance) + LOG.exception(_('Failed storing info cache'), instance=instance) LOG.debug(_('args: %s') % (args or {})) LOG.debug(_('kwargs: %s') % (kwargs or {})) diff --git a/nova/network/ldapdns.py b/nova/network/ldapdns.py index 0cc07aa92..affa976f0 100644 --- a/nova/network/ldapdns.py +++ b/nova/network/ldapdns.py @@ -94,8 +94,9 @@ class DNSEntry(object): if not entry: return None if len(entry) > 1: - LOG.warn("Found multiple matches for domain %s.\n%s" % - (domain, entry)) + LOG.warn(_("Found multiple matches for domain " + "%(domain)s.\n%(entry)s") % + (domain, entry)) return entry[0] @classmethod @@ -120,8 +121,10 @@ class DNSEntry(object): if name.endswith(z): dequalified = name[0:name.rfind(z)] else: - LOG.warn("Unable to dequalify. %s is not in %s.\n" % - (name, self.qualified_domain)) + LOG.warn(_("Unable to dequalify. %(name)s is not in " + "%(domain)s.\n") % + {'name': name, + 'domain': self.qualified_domain}) dequalified = None return dequalified @@ -356,5 +359,5 @@ class LdapDNS(object): dEntry.delete() def delete_dns_file(self): - LOG.warn("This shouldn't be getting called except during testing.") + LOG.warn(_("This shouldn't be getting called except during testing.")) pass diff --git a/nova/network/linux_net.py b/nova/network/linux_net.py index 4bd65e49b..c04a009be 100644 --- a/nova/network/linux_net.py +++ b/nova/network/linux_net.py @@ -1033,7 +1033,7 @@ def _create_veth_pair(dev1_name, dev2_name): utils.execute('ip', 'link', 'delete', dev1_name, run_as_root=True, check_exit_code=[0, 2, 254]) except exception.ProcessExecutionError: - LOG.exception("Error clearing stale veth %s" % dev) + LOG.exception(_("Error clearing stale veth %s") % dev) utils.execute('ip', 'link', 'add', dev1_name, 'type', 'veth', 'peer', 'name', dev2_name, run_as_root=True) diff --git a/nova/notifications.py b/nova/notifications.py index b1338c582..9f92e3dd4 100644 --- a/nova/notifications.py +++ b/nova/notifications.py @@ -226,7 +226,7 @@ def bandwidth_usage(instance_ref, audit_start, nw_info = network.API().get_instance_nw_info(admin_context, instance_ref) except Exception: - LOG.exception('Failed to get nw_info', instance=instance_ref) + LOG.exception(_('Failed to get nw_info'), instance=instance_ref) if ignore_missing_network_data: return raise diff --git a/nova/openstack/common/rpc/amqp.py b/nova/openstack/common/rpc/amqp.py index a88408437..3324e3758 100644 --- a/nova/openstack/common/rpc/amqp.py +++ b/nova/openstack/common/rpc/amqp.py @@ -283,7 +283,7 @@ class ProxyCallback(object): # This final None tells multicall that it is done. ctxt.reply(ending=True, connection_pool=self.connection_pool) except Exception as e: - LOG.exception('Exception during message handling') + LOG.exception(_('Exception during message handling')) ctxt.reply(None, sys.exc_info(), connection_pool=self.connection_pool) diff --git a/nova/virt/fake.py b/nova/virt/fake.py index 49f7b548b..eb3d584d6 100644 --- a/nova/virt/fake.py +++ b/nova/virt/fake.py @@ -195,8 +195,9 @@ class FakeDriver(driver.ComputeDriver): if key in self.instances: del self.instances[key] else: - LOG.warning("Key '%s' not in instances '%s'" % - (key, self.instances), instance=instance) + LOG.warning(_("Key '%(key)s' not in instances '%(inst)s'") % + {'key': key, + 'inst': self.instances}, instance=instance) def attach_volume(self, connection_info, instance_name, mountpoint): """Attach the disk to the instance at mountpoint using info""" diff --git a/nova/virt/xenapi/host.py b/nova/virt/xenapi/host.py index 30d085fe2..8057f0542 100644 --- a/nova/virt/xenapi/host.py +++ b/nova/virt/xenapi/host.py @@ -104,8 +104,8 @@ class Host(object): break except self._session.XenAPI.Failure: - LOG.exception('Unable to migrate VM %(vm_ref)s' - 'from %(host)s' % locals()) + LOG.exception(_('Unable to migrate VM %(vm_ref)s' + 'from %(host)s') % locals()) (old_ref, new_ref) = self._virtapi.instance_update( ctxt, instance['uuid'], -- cgit