From 0c25fbbac86f46ed168d0f61a8e587b2a73aac54 Mon Sep 17 00:00:00 2001 From: Gary Kotton Date: Tue, 29 Apr 2014 03:31:03 -0700 Subject: [PATCH] Don't translate debug level logs in nova.cert, console and consoleauth Our translation policy (https://wiki.openstack.org/wiki/LoggingStandards#Log_Translation) calls for not translating debug level logs. This is to help prioritize log translation. Furthermore translation has a performance overhead, even if the log isn't used (since nova doesn't support lazy translation yet). Change-Id: I9a0c718fc71e456baf87d1d28827654a015c62a6 --- nova/console/manager.py | 9 ++++----- nova/console/vmrc_manager.py | 11 +++++------ nova/console/xvp.py | 12 ++++++------ nova/hacking/checks.py | 3 +++ 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/nova/console/manager.py b/nova/console/manager.py index 303cc1d0f36c..2e66320a948f 100644 --- a/nova/console/manager.py +++ b/nova/console/manager.py @@ -23,7 +23,6 @@ from oslo import messaging from nova.compute import rpcapi as compute_rpcapi from nova import exception from nova import manager -from nova.openstack.common.gettextutils import _ from nova.openstack.common import importutils from nova.openstack.common import log as logging from nova import utils @@ -77,7 +76,7 @@ class ConsoleProxyManager(manager.Manager): pool['id'], instance['uuid']) except exception.NotFound: - LOG.debug(_('Adding console'), instance=instance) + LOG.debug('Adding console', instance=instance) password = utils.generate_password(8) port = self.driver.get_port(context) console_data = {'instance_name': name, @@ -95,9 +94,9 @@ class ConsoleProxyManager(manager.Manager): try: console = self.db.console_get(context, console_id) except exception.NotFound: - LOG.debug(_('Tried to remove non-existent console ' - '%(console_id)s.') % - {'console_id': console_id}) + LOG.debug('Tried to remove non-existent console ' + '%(console_id)s.', + {'console_id': console_id}) return self.db.console_delete(context, console_id) self.driver.teardown_console(context, console) diff --git a/nova/console/vmrc_manager.py b/nova/console/vmrc_manager.py index 5eab5c349c92..cce669113404 100644 --- a/nova/console/vmrc_manager.py +++ b/nova/console/vmrc_manager.py @@ -20,7 +20,6 @@ from oslo.config import cfg from nova.compute import rpcapi as compute_rpcapi from nova import exception from nova import manager -from nova.openstack.common.gettextutils import _ from nova.openstack.common import importutils from nova.openstack.common import log as logging from nova.virt.vmwareapi import driver as vmwareapi_conn @@ -59,7 +58,7 @@ class ConsoleVMRCManager(manager.Manager): def _generate_console(self, context, pool, name, instance_id, instance): """Sets up console for the instance.""" - LOG.debug(_('Adding console')) + LOG.debug('Adding console') password = self.driver.generate_password( self._get_vim_session(pool), @@ -109,11 +108,11 @@ class ConsoleVMRCManager(manager.Manager): try: console = self.db.console_get(context, console_id) except exception.NotFound: - LOG.debug(_('Tried to remove non-existent console ' - '%(console_id)s.') % {'console_id': console_id}) + LOG.debug('Tried to remove non-existent console ' + '%(console_id)s.', {'console_id': console_id}) return - LOG.debug(_('Removing console ' - '%(console_id)s.') % {'console_id': console_id}) + LOG.debug('Removing console ' + '%(console_id)s.', {'console_id': console_id}) self.db.console_delete(context, console_id) self.driver.teardown_console(context, console) diff --git a/nova/console/xvp.py b/nova/console/xvp.py index 7fd250301343..f55645b2d6ac 100644 --- a/nova/console/xvp.py +++ b/nova/console/xvp.py @@ -96,7 +96,7 @@ class XVPConsoleProxy(object): return self._xvp_encrypt(password) def _rebuild_xvp_conf(self, context): - LOG.debug(_('Rebuilding xvp conf')) + LOG.debug('Rebuilding xvp conf') pools = [pool for pool in db.console_pool_get_all_by_host_type(context, self.host, self.console_type) @@ -116,7 +116,7 @@ class XVPConsoleProxy(object): def _write_conf(self, config): try: - LOG.debug(_('Re-wrote %s') % CONF.console_xvp_conf) + LOG.debug('Re-wrote %s', CONF.console_xvp_conf) with open(CONF.console_xvp_conf, 'w') as cfile: cfile.write(config) except IOError: @@ -124,7 +124,7 @@ class XVPConsoleProxy(object): LOG.exception(_("Failed to write configuration file")) def _xvp_stop(self): - LOG.debug(_('Stopping xvp')) + LOG.debug('Stopping xvp') pid = self._xvp_pid() if not pid: return @@ -137,7 +137,7 @@ class XVPConsoleProxy(object): def _xvp_start(self): if self._xvp_check_running(): return - LOG.debug(_('Starting xvp')) + LOG.debug('Starting xvp') try: utils.execute('xvp', '-p', CONF.console_xvp_pid, @@ -147,9 +147,9 @@ class XVPConsoleProxy(object): LOG.error(_('Error starting xvp: %s') % err) def _xvp_restart(self): - LOG.debug(_('Restarting xvp')) + LOG.debug('Restarting xvp') if not self._xvp_check_running(): - LOG.debug(_('xvp not running...')) + LOG.debug('xvp not running...') self._xvp_start() else: pid = self._xvp_pid() diff --git a/nova/hacking/checks.py b/nova/hacking/checks.py index 677a6bd06dc0..66cf598b5241 100644 --- a/nova/hacking/checks.py +++ b/nova/hacking/checks.py @@ -216,6 +216,9 @@ def no_translate_debug_logs(logical_line, filename): "nova/objects", "nova/cmd", "nova/db", + "nova/cert", + "nova/console", + "nova/consoleauth", ] if max([name in filename for name in dirs]): if logical_line.startswith("LOG.debug(_("):