diff --git a/ceilometer/alarm/notifier/log.py b/ceilometer/alarm/notifier/log.py index 529a9ea13..0f1a2fb10 100644 --- a/ceilometer/alarm/notifier/log.py +++ b/ceilometer/alarm/notifier/log.py @@ -18,6 +18,7 @@ """Log alarm notifier.""" from ceilometer.alarm import notifier +from ceilometer.openstack.common.gettextutils import _ # noqa from ceilometer.openstack.common import log LOG = log.getLogger(__name__) @@ -28,5 +29,9 @@ class LogAlarmNotifier(notifier.AlarmNotifier): @staticmethod def notify(action, alarm_id, previous, current, reason): - LOG.info("Notifying alarm %s from %s to %s with action %s because %s", - alarm_id, previous, current, action, reason) + LOG.info(_( + "Notifying alarm %(alarm_id)s from %(previous)s " + "to %(current)s with action %(action)s because " + "%(reason)s") % ({'alarm_id': alarm_id, 'previous': previous, + 'current': current, 'action': action, + 'reason': reason})) diff --git a/ceilometer/alarm/notifier/rest.py b/ceilometer/alarm/notifier/rest.py index 2bafabbea..b9e35e009 100644 --- a/ceilometer/alarm/notifier/rest.py +++ b/ceilometer/alarm/notifier/rest.py @@ -24,6 +24,7 @@ import urlparse from oslo.config import cfg from ceilometer.alarm import notifier +from ceilometer.openstack.common.gettextutils import _ # noqa from ceilometer.openstack.common import jsonutils from ceilometer.openstack.common import log @@ -54,8 +55,12 @@ class RestAlarmNotifier(notifier.AlarmNotifier): @staticmethod def notify(action, alarm_id, previous, current, reason): - LOG.info("Notifying alarm %s from %s to %s with action %s because %s", - alarm_id, previous, current, action, reason) + LOG.info(_( + "Notifying alarm %(alarm_id)s from %(previous)s " + "to %(current)s with action %(action)s because " + "%(reason)s") % ({'alarm_id': alarm_id, 'previous': previous, + 'current': current, 'action': action, + 'reason': reason})) body = {'alarm_id': alarm_id, 'previous': previous, 'current': current, 'reason': reason} kwargs = {'data': jsonutils.dumps(body)} diff --git a/ceilometer/alarm/partition/coordination.py b/ceilometer/alarm/partition/coordination.py index e222ad07d..77d406589 100644 --- a/ceilometer/alarm/partition/coordination.py +++ b/ceilometer/alarm/partition/coordination.py @@ -240,8 +240,8 @@ class PartitionCoordinator(object): # nothing to distribute, but check anyway if overtaken still_ahead = self.this < self.oldest self.last_alarms = set(alarms) - LOG.info('%(this)s not overtaken as master? %(still_ahead)s' % - dict(this=self.this, still_ahead=still_ahead)) + LOG.info(_('%(this)s not overtaken as master? %(still_ahead)s') % + ({'this': self.this, 'still_ahead': still_ahead})) return still_ahead def check_mastership(self, eval_interval, api_client): diff --git a/ceilometer/alarm/service.py b/ceilometer/alarm/service.py index 64197a479..dea227812 100644 --- a/ceilometer/alarm/service.py +++ b/ceilometer/alarm/service.py @@ -160,7 +160,7 @@ class PartitionedAlarmService(AlarmService, rpc_service.Service): self.partition_coordinator = coordination.PartitionCoordinator() def initialize_service_hook(self, service): - LOG.debug('initialize_service_hooks') + LOG.debug(_('initialize_service_hooks')) self.conn.create_worker( cfg.CONF.alarm.partition_rpc_topic, rpc_dispatcher.RpcDispatcher([self]), @@ -218,7 +218,7 @@ class AlarmNotifierService(rpc_service.Service): self.tg.add_timer(604800, lambda: None) def initialize_service_hook(self, service): - LOG.debug('initialize_service_hooks') + LOG.debug(_('initialize_service_hooks')) self.conn.create_worker( cfg.CONF.alarm.notifier_rpc_topic, rpc_dispatcher.RpcDispatcher([self]), @@ -245,8 +245,8 @@ class AlarmNotifierService(rpc_service.Service): return try: - LOG.debug("Notifying alarm %s with action %s", - alarm_id, action) + LOG.debug(_("Notifying alarm %(id)s with action %(act)s") % ( + {'id': alarm_id, 'act': action})) notifier.notify(action, alarm_id, previous, current, reason) except Exception: LOG.exception(_("Unable to notify alarm %s"), alarm_id) diff --git a/ceilometer/api/app.py b/ceilometer/api/app.py index 3ecf4a333..473e714df 100644 --- a/ceilometer/api/app.py +++ b/ceilometer/api/app.py @@ -117,14 +117,16 @@ def start(): host, port = cfg.CONF.api.host, cfg.CONF.api.port srv = simple_server.make_server(host, port, root) - LOG.info('Starting server in PID %s' % os.getpid()) - LOG.info("Configuration:") + LOG.info(_('Starting server in PID %s') % os.getpid()) + LOG.info(_("Configuration:")) cfg.CONF.log_opt_values(LOG, logging.INFO) if host == '0.0.0.0': - LOG.info('serving on 0.0.0.0:%s, view at http://127.0.0.1:%s' % - (port, port)) + LOG.info(_( + 'serving on 0.0.0.0:%(sport)s, view at http://127.0.0.1:%(vport)s') + % ({'sport': port, 'vport': port})) else: - LOG.info("serving on http://%s:%s" % (host, port)) + LOG.info(_("serving on http://%(host)s:%(port)s") % ( + {'host': host, 'port': port})) srv.serve_forever() diff --git a/ceilometer/api/controllers/v2.py b/ceilometer/api/controllers/v2.py index a67ed539e..39ddd5d7c 100644 --- a/ceilometer/api/controllers/v2.py +++ b/ceilometer/api/controllers/v2.py @@ -654,12 +654,12 @@ class Statistics(_Base): self.duration_start and self.duration_start < start_timestamp): self.duration_start = start_timestamp - LOG.debug('clamping min timestamp to range') + LOG.debug(_('clamping min timestamp to range')) if (end_timestamp and self.duration_end and self.duration_end > end_timestamp): self.duration_end = end_timestamp - LOG.debug('clamping max timestamp to range') + LOG.debug(_('clamping max timestamp to range')) # If we got valid timestamps back, compute a duration in seconds. # @@ -800,7 +800,8 @@ class MeterController(rest.RestController): computed = pecan.request.storage_conn.get_meter_statistics(f, period, g) - LOG.debug('computed value coming from %r', pecan.request.storage_conn) + LOG.debug(_('computed value coming from %r'), + pecan.request.storage_conn) # Find the original timestamp in the query to use for clamping # the duration returned in the statistics. start = end = None @@ -1347,7 +1348,7 @@ class AlarmController(rest.RestController): try: alarm_in = storage.models.Alarm(**updated_alarm) except Exception: - LOG.exception("Error while putting alarm: %s" % updated_alarm) + LOG.exception(_("Error while putting alarm: %s") % updated_alarm) raise ClientSideError(_("Alarm incorrect")) alarm = self.conn.update_alarm(alarm_in) @@ -1486,7 +1487,7 @@ class AlarmsController(rest.RestController): try: alarm_in = storage.models.Alarm(**change) except Exception: - LOG.exception("Error while posting alarm: %s" % change) + LOG.exception(_("Error while posting alarm: %s") % change) raise ClientSideError(_("Alarm incorrect")) alarm = conn.create_alarm(alarm_in) diff --git a/ceilometer/api/middleware.py b/ceilometer/api/middleware.py index 2d1f9ac61..0adffbc2c 100644 --- a/ceilometer/api/middleware.py +++ b/ceilometer/api/middleware.py @@ -29,6 +29,7 @@ import webob from ceilometer.api import hooks from ceilometer.openstack.common import gettextutils +from ceilometer.openstack.common.gettextutils import _ # noqa from ceilometer.openstack.common import log LOG = log.getLogger(__name__) @@ -108,7 +109,7 @@ class ParsableErrorMiddleware(object): body = ['' + etree.tostring(fault) + ''] except etree.XMLSyntaxError as err: - LOG.error('Error parsing HTTP response: %s' % err) + LOG.error(_('Error parsing HTTP response: %s') % err) body = ['%s' % state['status_code'] + ''] state['headers'].append(('Content-Type', 'application/xml')) diff --git a/ceilometer/api/v1/blueprint.py b/ceilometer/api/v1/blueprint.py index 19af81d8b..84ad16fcf 100644 --- a/ceilometer/api/v1/blueprint.py +++ b/ceilometer/api/v1/blueprint.py @@ -89,6 +89,7 @@ import datetime import flask +from ceilometer.openstack.common.gettextutils import _ # noqa from ceilometer.openstack.common import log from ceilometer.openstack.common import timeutils @@ -565,14 +566,20 @@ def compute_duration_by_resource(resource, meter): # "Clamp" the timestamps we return to the original time # range, excluding the offset. - LOG.debug('start_timestamp %s, end_timestamp %s, min_ts %s, max_ts %s', - start_timestamp, end_timestamp, min_ts, max_ts) + LOG.debug(_('start_timestamp %(start_timestamp)s, ' + 'end_timestamp %(end_timestamp)s, ' + 'min_ts %(min_ts)s, ' + 'max_ts %(max_ts)s') % ( + {'start_timestamp': start_timestamp, + 'end_timestamp': end_timestamp, + 'min_ts': min_ts, + 'max_ts': max_ts})) if start_timestamp and min_ts and min_ts < start_timestamp: min_ts = start_timestamp - LOG.debug('clamping min timestamp to range') + LOG.debug(_('clamping min timestamp to range')) if end_timestamp and max_ts and max_ts > end_timestamp: max_ts = end_timestamp - LOG.debug('clamping max timestamp to range') + LOG.debug(_('clamping max timestamp to range')) # If we got valid timestamps back, compute a duration in minutes. # diff --git a/ceilometer/central/manager.py b/ceilometer/central/manager.py index c82065267..c9a06ed85 100644 --- a/ceilometer/central/manager.py +++ b/ceilometer/central/manager.py @@ -21,6 +21,7 @@ from oslo.config import cfg from stevedore import extension from ceilometer import agent +from ceilometer.openstack.common.gettextutils import _ # noqa from ceilometer.openstack.common import log from ceilometer.openstack.common.rpc import service as rpc_service from ceilometer.openstack.common import service as os_service @@ -40,15 +41,16 @@ class PollingTask(agent.PollingTask): cache = {} for pollster in self.pollsters: try: - LOG.info("Polling pollster %s", pollster.name) + LOG.info(_("Polling pollster %s"), pollster.name) samples = list(pollster.obj.get_samples( self.manager, cache, )) publisher(samples) except Exception as err: - LOG.warning('Continue after error from %s: %s', - pollster.name, err) + LOG.warning(_( + 'Continue after error from %(name)s: %(error)s') + % ({'name': pollster.name, 'error': err})) LOG.exception(err) diff --git a/ceilometer/collector.py b/ceilometer/collector.py index 0ac00f26d..f8463e446 100644 --- a/ceilometer/collector.py +++ b/ceilometer/collector.py @@ -79,7 +79,7 @@ class CollectorService(service.DispatchedService, rpc_service.Service): sample['counter_volume'] = sample['volume'] sample['counter_unit'] = sample['unit'] sample['counter_type'] = sample['type'] - LOG.debug("UDP: Storing %s", str(sample)) + LOG.debug(_("UDP: Storing %s"), str(sample)) self.dispatcher_manager.map_method('record_metering_data', sample) except Exception: diff --git a/ceilometer/compute/manager.py b/ceilometer/compute/manager.py index cfbc5aa27..4a355d428 100644 --- a/ceilometer/compute/manager.py +++ b/ceilometer/compute/manager.py @@ -22,6 +22,7 @@ from stevedore import extension from ceilometer import agent from ceilometer.compute.virt import inspector as virt_inspector from ceilometer import nova_client +from ceilometer.openstack.common.gettextutils import _ # noqa from ceilometer.openstack.common import log from ceilometer.openstack.common.rpc import service as rpc_service from ceilometer.openstack.common import service as os_service @@ -39,7 +40,7 @@ class PollingTask(agent.PollingTask): cache = {} for pollster in self.pollsters: try: - LOG.info("Polling pollster %s", pollster.name) + LOG.info(_("Polling pollster %s"), pollster.name) samples = list(pollster.obj.get_samples( self.manager, cache, @@ -47,15 +48,16 @@ class PollingTask(agent.PollingTask): )) publisher(samples) except Exception as err: - LOG.warning('Continue after error from %s: %s', - pollster.name, err) + LOG.warning(_( + 'Continue after error from %(name)s: %(error)s') + % ({'name': pollster.name, 'error': err})) LOG.exception(err) def poll_and_publish(self): try: instances = self.manager.nv.instance_get_all_by_host(cfg.CONF.host) except Exception as err: - LOG.exception('Unable to retrieve instances: %s', err) + LOG.exception(_('Unable to retrieve instances: %s') % err) else: self.poll_and_publish_instances(instances) diff --git a/ceilometer/compute/pollsters/cpu.py b/ceilometer/compute/pollsters/cpu.py index 414b5d0c1..25cc4e139 100644 --- a/ceilometer/compute/pollsters/cpu.py +++ b/ceilometer/compute/pollsters/cpu.py @@ -21,6 +21,7 @@ from ceilometer.compute import plugin from ceilometer.compute.pollsters import util from ceilometer.compute.virt import inspector as virt_inspector +from ceilometer.openstack.common.gettextutils import _ # noqa from ceilometer.openstack.common import log from ceilometer import sample @@ -30,12 +31,12 @@ LOG = log.getLogger(__name__) class CPUPollster(plugin.ComputePollster): def get_samples(self, manager, cache, instance): - LOG.info('checking instance %s', instance.id) + LOG.info(_('checking instance %s'), instance.id) instance_name = util.instance_name(instance) try: cpu_info = manager.inspector.inspect_cpus(instance_name) - LOG.info("CPUTIME USAGE: %s %d", - instance.__dict__, cpu_info.time) + LOG.info(_("CPUTIME USAGE: %(instance)s %(time)d") % ( + {'instance': instance.__dict__, 'time': cpu_info.time})) cpu_num = {'cpu_number': cpu_info.number} yield util.make_sample_from_instance( instance, @@ -47,8 +48,8 @@ class CPUPollster(plugin.ComputePollster): ) except virt_inspector.InstanceNotFoundException as err: # Instance was deleted while getting samples. Ignore it. - LOG.debug('Exception while getting samples %s', err) + LOG.debug(_('Exception while getting samples %s'), err) except Exception as err: - LOG.error('could not get CPU time for %s: %s', - instance.id, err) + LOG.error(_('could not get CPU time for %(id)s: %(e)s') % ( + {'id': instance.id, 'e': err})) LOG.exception(err) diff --git a/ceilometer/compute/pollsters/disk.py b/ceilometer/compute/pollsters/disk.py index 1b17fa065..acbdcb4c2 100644 --- a/ceilometer/compute/pollsters/disk.py +++ b/ceilometer/compute/pollsters/disk.py @@ -24,6 +24,7 @@ import collections from ceilometer.compute import plugin from ceilometer.compute.pollsters import util from ceilometer.compute.virt import inspector as virt_inspector +from ceilometer.openstack.common.gettextutils import _ # noqa from ceilometer.openstack.common import log from ceilometer import sample @@ -89,10 +90,10 @@ class _Base(plugin.ComputePollster): yield self._get_sample(instance, c_data) except virt_inspector.InstanceNotFoundException as err: # Instance was deleted while getting samples. Ignore it. - LOG.debug('Exception while getting samples %s', err) + LOG.debug(_('Exception while getting samples %s'), err) except Exception as err: - LOG.warning('Ignoring instance %s: %s', - instance_name, err) + LOG.warning(_('Ignoring instance %(name)s: %(error)s') % ( + {'name': instance_name, 'error': err})) LOG.exception(err) diff --git a/ceilometer/compute/pollsters/net.py b/ceilometer/compute/pollsters/net.py index bc5ab93e6..052c2b4a1 100644 --- a/ceilometer/compute/pollsters/net.py +++ b/ceilometer/compute/pollsters/net.py @@ -23,6 +23,7 @@ import copy from ceilometer.compute import plugin from ceilometer.compute.pollsters import util from ceilometer.compute.virt import inspector as virt_inspector +from ceilometer.openstack.common.gettextutils import _ # noqa from ceilometer.openstack.common import log from ceilometer.openstack.common import timeutils from ceilometer import sample @@ -73,7 +74,7 @@ class _Base(plugin.ComputePollster): def get_samples(self, manager, cache, instance): instance_name = util.instance_name(instance) - LOG.info('checking instance %s', instance.id) + LOG.info(_('checking instance %s'), instance.id) try: vnics = self._get_vnics_for_instance( cache, @@ -86,10 +87,10 @@ class _Base(plugin.ComputePollster): yield self._get_sample(instance, vnic, info) except virt_inspector.InstanceNotFoundException as err: # Instance was deleted while getting samples. Ignore it. - LOG.debug('Exception while getting samples %s', err) + LOG.debug(_('Exception while getting samples %s'), err) except Exception as err: - LOG.warning('Ignoring instance %s: %s', - instance_name, err) + LOG.warning(_('Ignoring instance %(name)s: %(error)s') % ( + {'name': instance_name, 'error': err})) LOG.exception(err) diff --git a/ceilometer/compute/virt/inspector.py b/ceilometer/compute/virt/inspector.py index 2071819d6..2374ce3c9 100644 --- a/ceilometer/compute/virt/inspector.py +++ b/ceilometer/compute/virt/inspector.py @@ -23,6 +23,7 @@ import collections from oslo.config import cfg from stevedore import driver +from ceilometer.openstack.common.gettextutils import _ # noqa from ceilometer.openstack.common import log @@ -151,5 +152,5 @@ def get_hypervisor_inspector(): invoke_on_load=True) return mgr.driver except ImportError as e: - LOG.error("Unable to load the hypervisor inspector: %s" % (e)) + LOG.error(_("Unable to load the hypervisor inspector: %s") % (e)) return Inspector() diff --git a/ceilometer/compute/virt/libvirt/inspector.py b/ceilometer/compute/virt/libvirt/inspector.py index 69734d86b..bda48ae96 100644 --- a/ceilometer/compute/virt/libvirt/inspector.py +++ b/ceilometer/compute/virt/libvirt/inspector.py @@ -21,6 +21,7 @@ from lxml import etree from oslo.config import cfg from ceilometer.compute.virt import inspector as virt_inspector +from ceilometer.openstack.common.gettextutils import _ # noqa from ceilometer.openstack.common import log as logging libvirt = None @@ -60,7 +61,7 @@ class LibvirtInspector(virt_inspector.Inspector): if libvirt is None: libvirt = __import__('libvirt') - LOG.debug('Connecting to libvirt: %s', self.uri) + LOG.debug(_('Connecting to libvirt: %s'), self.uri) self.connection = libvirt.openReadOnly(self.uri) return self.connection @@ -73,7 +74,7 @@ class LibvirtInspector(virt_inspector.Inspector): if (e.get_error_code() == libvirt.VIR_ERR_SYSTEM_ERROR and e.get_error_domain() in (libvirt.VIR_FROM_REMOTE, libvirt.VIR_FROM_RPC)): - LOG.debug('Connection to libvirt broke') + LOG.debug(_('Connection to libvirt broke')) return False raise diff --git a/ceilometer/dispatcher/database.py b/ceilometer/dispatcher/database.py index fa00b7798..c73144eda 100644 --- a/ceilometer/dispatcher/database.py +++ b/ceilometer/dispatcher/database.py @@ -17,6 +17,7 @@ # under the License. from ceilometer import dispatcher +from ceilometer.openstack.common.gettextutils import _ # noqa from ceilometer.openstack.common import log from ceilometer.openstack.common import timeutils from ceilometer.publisher import rpc as publisher_rpc @@ -46,11 +47,13 @@ class DatabaseDispatcher(dispatcher.Base): data = [data] for meter in data: - LOG.debug('metering data %s for %s @ %s: %s', - meter['counter_name'], - meter['resource_id'], - meter.get('timestamp', 'NO TIMESTAMP'), - meter['counter_volume']) + LOG.debug(_( + 'metering data %(counter_name)s ' + 'for %(resource_id)s @ %(timestamp)s: %(counter_volume)s') + % ({'counter_name': meter['counter_name'], + 'resource_id': meter['resource_id'], + 'timestamp': meter.get('timestamp', 'NO TIMESTAMP'), + 'counter_volume': meter['counter_volume']})) if publisher_rpc.verify_signature( meter, self.conf.publisher_rpc.metering_secret): @@ -63,10 +66,11 @@ class DatabaseDispatcher(dispatcher.Base): meter['timestamp'] = timeutils.normalize_time(ts) self.storage_conn.record_metering_data(meter) except Exception as err: - LOG.exception('Failed to record metering data: %s', err) + LOG.exception(_('Failed to record metering data: %s'), + err) else: - LOG.warning( - 'message signature invalid, discarding message: %r', + LOG.warning(_( + 'message signature invalid, discarding message: %r'), meter) def record_events(self, events): diff --git a/ceilometer/network/floatingip.py b/ceilometer/network/floatingip.py index 04b1f093b..250673674 100644 --- a/ceilometer/network/floatingip.py +++ b/ceilometer/network/floatingip.py @@ -21,6 +21,7 @@ from ceilometer.central import plugin from ceilometer import nova_client +from ceilometer.openstack.common.gettextutils import _ # noqa from ceilometer.openstack.common import log from ceilometer.openstack.common import timeutils from ceilometer import sample @@ -41,7 +42,7 @@ class FloatingIPPollster(plugin.CentralPollster): def get_samples(self, manager, cache): for ip in self._iter_floating_ips(cache): - self.LOG.info("FLOATING IP USAGE: %s" % ip.ip) + self.LOG.info(_("FLOATING IP USAGE: %s") % ip.ip) # FIXME (flwang) Now Nova API /os-floating-ips can't provide those # attributes were used by Ceilometer, such as project id, host. # In this fix, those attributes usage will be removed temporarily. diff --git a/ceilometer/network/notifications.py b/ceilometer/network/notifications.py index 3a5c507fd..4dd917ca4 100644 --- a/ceilometer/network/notifications.py +++ b/ceilometer/network/notifications.py @@ -22,6 +22,7 @@ from oslo.config import cfg +from ceilometer.openstack.common.gettextutils import _ # noqa from ceilometer.openstack.common import log from ceilometer import plugin from ceilometer import sample @@ -75,7 +76,7 @@ class NetworkNotificationBase(plugin.NotificationBase): ] def process_notification(self, message): - LOG.info('network notification %r', message) + LOG.info(_('network notification %r') % message) message['payload'] = message['payload'][self.resource_name] counter_name = getattr(self, 'counter_name', self.resource_name) unit_value = getattr(self, 'unit', self.resource_name) diff --git a/ceilometer/notification.py b/ceilometer/notification.py index 69034d061..5568325bd 100644 --- a/ceilometer/notification.py +++ b/ceilometer/notification.py @@ -20,6 +20,7 @@ from oslo.config import cfg from stevedore import extension from ceilometer.openstack.common import context +from ceilometer.openstack.common.gettextutils import _ # noqa from ceilometer.openstack.common import log from ceilometer.openstack.common.rpc import service as rpc_service from ceilometer.openstack.common import service as os_service @@ -79,7 +80,7 @@ class NotificationService(service.DispatchedService, rpc_service.Service): ) if not list(self.notification_manager): - LOG.warning('Failed to load any notification handlers for %s', + LOG.warning(_('Failed to load any notification handlers for %s'), self.NOTIFICATION_NAMESPACE) self.notification_manager.map(self._setup_subscription) @@ -97,9 +98,11 @@ class NotificationService(service.DispatchedService, rpc_service.Service): """ handler = ext.obj ack_on_error = cfg.CONF.notification.ack_on_event_error - LOG.debug('Event types from %s: %s (ack_on_error=%s)', - ext.name, ', '.join(handler.event_types), - ack_on_error) + LOG.debug(_('Event types from %(name)s: %(type)s' + ' (ack_on_error=%(error)s)') % + {'name': ext.name, + 'type': ', '.join(handler.event_types), + 'error': ack_on_error}) for exchange_topic in handler.get_exchange_topics(cfg.CONF): for topic in exchange_topic.topics: @@ -111,8 +114,10 @@ class NotificationService(service.DispatchedService, rpc_service.Service): exchange_name=exchange_topic.exchange, ack_on_error=ack_on_error) except Exception: - LOG.exception('Could not join consumer pool %s/%s' % - (topic, exchange_topic.exchange)) + LOG.exception(_('Could not join consumer pool' + ' %(topic)s/%(exchange)s') % + {'topic': topic, + 'exchange': exchange_topic.exchange}) def process_notification(self, notification): """RPC endpoint for notification messages @@ -121,7 +126,7 @@ class NotificationService(service.DispatchedService, rpc_service.Service): bus, this method receives it. See _setup_subscription(). """ - LOG.debug('notification %r', notification.get('event_type')) + LOG.debug(_('notification %r'), notification.get('event_type')) self.notification_manager.map(self._process_notification_for_ext, notification=notification) @@ -151,7 +156,7 @@ class NotificationService(service.DispatchedService, rpc_service.Service): message_id = body.get('message_id') event_type = body['event_type'] when = self._extract_when(body) - LOG.debug('Saving event "%s"', event_type) + LOG.debug(_('Saving event "%s"'), event_type) publisher = body.get('publisher_id') request_id = body.get('_context_request_id') diff --git a/ceilometer/notifier.py b/ceilometer/notifier.py index cf4bdc32c..fa510fc67 100644 --- a/ceilometer/notifier.py +++ b/ceilometer/notifier.py @@ -21,6 +21,7 @@ from ceilometer.openstack.common import log as logging from ceilometer import pipeline from ceilometer import transformer +from ceilometer.openstack.common.gettextutils import _ # noqa from stevedore import extension @@ -36,14 +37,14 @@ def _load_notification_manager(): namespace = 'ceilometer.notification' - LOG.debug('loading notification handlers from %s', namespace) + LOG.debug(_('loading notification handlers from %s'), namespace) _notification_manager = extension.ExtensionManager( namespace=namespace, invoke_on_load=True) if not list(_notification_manager): - LOG.warning('Failed to load any notification handlers for %s', + LOG.warning(_('Failed to load any notification handlers for %s'), namespace) diff --git a/ceilometer/pipeline.py b/ceilometer/pipeline.py index 8234f5333..5a02507bb 100644 --- a/ceilometer/pipeline.py +++ b/ceilometer/pipeline.py @@ -24,6 +24,7 @@ import os from oslo.config import cfg import yaml +from ceilometer.openstack.common.gettextutils import _ # noqa from ceilometer.openstack.common import log from ceilometer import publisher @@ -125,7 +126,7 @@ class Pipeline(object): try: self.publishers.append(publisher.get_publisher(p)) except Exception: - LOG.exception("Unable to load publisher %s", p) + LOG.exception(_("Unable to load publisher %s"), p) self.transformers = self._setup_transformers(cfg, transformer_manager) @@ -168,11 +169,11 @@ class Pipeline(object): "No transformer named %s loaded" % transformer['name'], cfg) transformers.append(ext.plugin(**parameter)) - LOG.info("Pipeline %s: Setup transformer instance %s " - "with parameter %s", - self, - transformer['name'], - parameter) + LOG.info(_( + "Pipeline %(pipeline)s: Setup transformer instance %(name)s " + "with parameter %(param)s") % ({'pipeline': self, + 'name': transformer['name'], + 'param': parameter})) return transformers @@ -181,14 +182,18 @@ class Pipeline(object): for transformer in self.transformers[start:]: sample = transformer.handle_sample(ctxt, sample) if not sample: - LOG.debug("Pipeline %s: Sample dropped by transformer %s", - self, transformer) + LOG.debug(_( + "Pipeline %(pipeline)s: Sample dropped by " + "transformer %(trans)s") % ({'pipeline': self, + 'trans': transformer})) return return sample except Exception as err: - LOG.warning("Pipeline %s: Exit after error from transformer" - "%s for %s", - self, transformer, sample) + LOG.warning(_("Pipeline %(pipeline)s: " + "Exit after error from transformer " + "%(trans)s for %(smp)s") % ({'pipeline': self, + 'trans': transformer, + 'smp': sample})) LOG.exception(err) def _publish_samples(self, start, ctxt, samples): @@ -204,21 +209,26 @@ class Pipeline(object): transformed_samples = [] for sample in samples: - LOG.debug("Pipeline %s: Transform sample %s from %s transformer", - self, sample, start) + LOG.debug(_( + "Pipeline %(pipeline)s: Transform sample " + "%(smp)s from %(trans)s transformer") % ({'pipeline': self, + 'smp': sample, + 'trans': start})) sample = self._transform_sample(start, ctxt, sample) if sample: transformed_samples.append(sample) if transformed_samples: - LOG.audit("Pipeline %s: Publishing samples", self) + LOG.audit(_("Pipeline %s: Publishing samples"), self) for p in self.publishers: try: p.publish_samples(ctxt, transformed_samples) except Exception: - LOG.exception("Pipeline %s: Continue after error " - "from publisher %s", self, p) - LOG.audit("Pipeline %s: Published samples", self) + LOG.exception(_( + "Pipeline %(pipeline)s: Continue after error " + "from publisher %(pub)s") % ({'pipeline': self, + 'pub': p})) + LOG.audit(_("Pipeline %s: Published samples") % self) def publish_sample(self, ctxt, sample): self.publish_samples(ctxt, [sample]) @@ -267,16 +277,16 @@ class Pipeline(object): def flush(self, ctxt): """Flush data after all samples have been injected to pipeline.""" - LOG.audit("Flush pipeline %s", self) + LOG.audit(_("Flush pipeline %s"), self) for (i, transformer) in enumerate(self.transformers): try: self._publish_samples(i + 1, ctxt, list(transformer.flush(ctxt))) except Exception as err: - LOG.warning( - "Pipeline %s: Error flushing " - "transformer %s", - self, transformer) + LOG.warning(_( + "Pipeline %(pipeline)s: Error flushing " + "transformer %(trans)s") % ({'pipeline': self, + 'trans': transformer})) LOG.exception(err) def get_interval(self): @@ -351,13 +361,13 @@ def setup_pipeline(transformer_manager): if not os.path.exists(cfg_file): cfg_file = cfg.CONF.find_file(cfg_file) - LOG.debug("Pipeline config file: %s", cfg_file) + LOG.debug(_("Pipeline config file: %s"), cfg_file) with open(cfg_file) as fap: data = fap.read() pipeline_cfg = yaml.safe_load(data) - LOG.info("Pipeline config: %s", pipeline_cfg) + LOG.info(_("Pipeline config: %s"), pipeline_cfg) return PipelineManager(pipeline_cfg, transformer_manager) diff --git a/ceilometer/publisher/file.py b/ceilometer/publisher/file.py index 08e1589be..54274006b 100644 --- a/ceilometer/publisher/file.py +++ b/ceilometer/publisher/file.py @@ -20,6 +20,7 @@ import logging import logging.handlers import urlparse +from ceilometer.openstack.common.gettextutils import _ # noqa from ceilometer.openstack.common import log from ceilometer import publisher @@ -58,7 +59,7 @@ class FilePublisher(publisher.PublisherBase): self.publisher_logger = None path = parsed_url.path if not path or path.lower() == 'file': - LOG.error('The path for the file publisher is required') + LOG.error(_('The path for the file publisher is required')) return rfh = None @@ -72,8 +73,8 @@ class FilePublisher(publisher.PublisherBase): max_bytes = int(params.get('max_bytes')[0]) backup_count = int(params.get('backup_count')[0]) except ValueError: - LOG.error('max_bytes and backup_count should be ' - 'numbers.') + LOG.error(_('max_bytes and backup_count should be ' + 'numbers.')) return # create rotating file handler rfh = logging.handlers.RotatingFileHandler( diff --git a/ceilometer/publisher/rpc.py b/ceilometer/publisher/rpc.py index f3ab83fdb..04570be46 100644 --- a/ceilometer/publisher/rpc.py +++ b/ceilometer/publisher/rpc.py @@ -26,6 +26,7 @@ import urlparse from oslo.config import cfg +from ceilometer.openstack.common.gettextutils import _ # noqa from ceilometer.openstack.common import log from ceilometer.openstack.common import rpc from ceilometer import publisher @@ -154,14 +155,14 @@ class RPCPublisher(publisher.PublisherBase): self.local_queue = [] if self.policy in ['queue', 'drop']: - LOG.info('Publishing policy set to %s, \ - override backend retry config to 1' % self.policy) + LOG.info(_('Publishing policy set to %s, \ + override backend retry config to 1') % self.policy) override_backend_retry_config(1) elif self.policy == 'default': - LOG.info('Publishing policy set to %s' % self.policy) + LOG.info(_('Publishing policy set to %s') % self.policy) else: - LOG.warn('Publishing policy is unknown (%s) force to default' + LOG.warn(_('Publishing policy is unknown (%s) force to default') % self.policy) self.policy = 'default' @@ -186,8 +187,8 @@ class RPCPublisher(publisher.PublisherBase): 'version': '1.0', 'args': {'data': meters}, } - LOG.audit('Publishing %d samples on %s', - len(msg['args']['data']), topic) + LOG.audit(_('Publishing %(m)d samples on %(t)s') % ( + {'m': len(msg['args']['data']), 't': topic})) self.local_queue.append((context, topic, msg)) if self.per_meter_topic: @@ -200,8 +201,8 @@ class RPCPublisher(publisher.PublisherBase): 'args': {'data': list(meter_list)}, } topic_name = topic + '.' + meter_name - LOG.audit('Publishing %d samples on %s', - len(msg['args']['data']), topic_name) + LOG.audit(_('Publishing %(m)d samples on %(n)s') % ( + {'m': len(msg['args']['data']), 'n': topic_name})) self.local_queue.append((context, topic_name, msg)) self.flush() @@ -225,8 +226,8 @@ class RPCPublisher(publisher.PublisherBase): if queue_length > self.max_queue_length > 0: count = queue_length - self.max_queue_length self.local_queue = self.local_queue[count:] - LOG.warn("Publisher max local_queue length is exceeded, " - "dropping %d oldest samples", count) + LOG.warn(_("Publisher max local_queue length is exceeded, " + "dropping %d oldest samples") % count) @staticmethod def _process_queue(queue, policy): diff --git a/ceilometer/service.py b/ceilometer/service.py index 26995690b..a94f381ed 100644 --- a/ceilometer/service.py +++ b/ceilometer/service.py @@ -26,6 +26,7 @@ from oslo.config import cfg from stevedore import named from ceilometer.openstack.common import gettextutils +from ceilometer.openstack.common.gettextutils import _ # noqa from ceilometer.openstack.common import log from ceilometer.openstack.common import rpc @@ -96,7 +97,7 @@ class DispatchedService(object): def __init__(self, *args, **kwargs): super(DispatchedService, self).__init__(*args, **kwargs) - LOG.debug('loading dispatchers from %s', + LOG.debug(_('loading dispatchers from %s'), self.DISPATCHER_NAMESPACE) self.dispatcher_manager = named.NamedExtensionManager( namespace=self.DISPATCHER_NAMESPACE, @@ -104,7 +105,7 @@ class DispatchedService(object): invoke_on_load=True, invoke_args=[cfg.CONF]) if not list(self.dispatcher_manager): - LOG.warning('Failed to load any dispatchers for %s', + LOG.warning(_('Failed to load any dispatchers for %s'), self.DISPATCHER_NAMESPACE) diff --git a/ceilometer/storage/__init__.py b/ceilometer/storage/__init__.py index 341f4b1d0..a0c39f3c4 100644 --- a/ceilometer/storage/__init__.py +++ b/ceilometer/storage/__init__.py @@ -23,6 +23,7 @@ import urlparse from oslo.config import cfg from stevedore import driver +from ceilometer.openstack.common.gettextutils import _ # noqa from ceilometer.openstack.common import log from ceilometer import service from ceilometer import utils @@ -67,8 +68,9 @@ def get_engine(conf): conf.set_override('connection', conf.database_connection, group='database') engine_name = urlparse.urlparse(conf.database.connection).scheme - LOG.debug('looking for %r driver in %r', - engine_name, STORAGE_ENGINE_NAMESPACE) + LOG.debug(_('looking for %(name)r driver in %(namespace)r') % ( + {'name': engine_name, + 'namespace': STORAGE_ENGINE_NAMESPACE})) mgr = driver.DriverManager(STORAGE_ENGINE_NAMESPACE, engine_name, invoke_on_load=True) @@ -140,7 +142,7 @@ def dbsync(): def expirer(): service.prepare_service() - LOG.debug("Clearing expired metering data") + LOG.debug(_("Clearing expired metering data")) storage_conn = get_connection(cfg.CONF) storage_conn.clear_expired_metering_data( cfg.CONF.database.time_to_live) diff --git a/ceilometer/storage/impl_hbase.py b/ceilometer/storage/impl_hbase.py index 080550d07..5a250cdae 100644 --- a/ceilometer/storage/impl_hbase.py +++ b/ceilometer/storage/impl_hbase.py @@ -96,8 +96,8 @@ class Connection(base.Connection): else: # This is a in-memory usage for unit tests if Connection._memory_instance is None: - LOG.debug('Creating a new in-memory HBase ' - 'Connection object') + LOG.debug(_('Creating a new in-memory HBase ' + 'Connection object')) Connection._memory_instance = MConnection() self.conn = Connection._memory_instance else: @@ -111,7 +111,7 @@ class Connection(base.Connection): self.conn.create_table(self.METER_TABLE, {'f': dict()}) def clear(self): - LOG.debug('Dropping HBase schema...') + LOG.debug(_('Dropping HBase schema...')) for table in [self.PROJECT_TABLE, self.USER_TABLE, self.RESOURCE_TABLE, @@ -119,11 +119,11 @@ class Connection(base.Connection): try: self.conn.disable_table(table) except Exception: - LOG.debug('Cannot disable table but ignoring error') + LOG.debug(_('Cannot disable table but ignoring error')) try: self.conn.delete_table(table) except Exception: - LOG.debug('Cannot delete table but ignoring error') + LOG.debug(_('Cannot delete table but ignoring error')) @staticmethod def _get_connection(conf): @@ -134,7 +134,8 @@ class Connection(base.Connection): The tests use a subclass to override this and return an in-memory connection. """ - LOG.debug('connecting to HBase on %s:%s', conf['host'], conf['port']) + LOG.debug(_('connecting to HBase on %(host)s:%(port)s') % ( + {'host': conf['host'], 'port': conf['port']})) return happybase.Connection(host=conf['host'], port=conf['port'], table_prefix=conf['table_prefix']) @@ -269,7 +270,7 @@ class Connection(base.Connection): :param source: Optional source filter. """ user_table = self.conn.table(self.USER_TABLE) - LOG.debug("source: %s" % source) + LOG.debug(_("source: %s") % source) scan_args = {} if source: scan_args['columns'] = ['f:s_%s' % source] @@ -281,7 +282,7 @@ class Connection(base.Connection): :param source: Optional source filter. """ project_table = self.conn.table(self.PROJECT_TABLE) - LOG.debug("source: %s" % source) + LOG.debug(_("source: %s") % source) scan_args = {} if source: scan_args['columns'] = ['f:s_%s' % source] @@ -338,7 +339,7 @@ class Connection(base.Connection): end_op=end_timestamp_op, require_meter=False, query_only=False) - LOG.debug("Query Meter table: %s" % q) + LOG.debug(_("Query Meter table: %s") % q) meters = meter_table.scan(filter=q, row_start=start_row, row_stop=stop_row) @@ -395,7 +396,7 @@ class Connection(base.Connection): resource_table = self.conn.table(self.RESOURCE_TABLE) q = make_query(user=user, project=project, resource=resource, source=source, require_meter=False, query_only=True) - LOG.debug("Query Resource table: %s" % q) + LOG.debug(_("Query Resource table: %s") % q) # handle metaquery if len(metaquery) > 0: @@ -451,7 +452,7 @@ class Connection(base.Connection): q, start, stop = make_query_from_filter(sample_filter, require_meter=False) - LOG.debug("Query Meter Table: %s" % q) + LOG.debug(_("Query Meter Table: %s") % q) gen = meter_table.scan(filter=q, row_start=start, row_stop=stop) @@ -760,7 +761,7 @@ class MConnection(object): self.tables = {} def open(self): - LOG.debug("Opening in-memory HBase connection") + LOG.debug(_("Opening in-memory HBase connection")) def create_table(self, n, families={}): if n in self.tables: diff --git a/ceilometer/storage/impl_log.py b/ceilometer/storage/impl_log.py index 56bf2cc63..8b0f5a669 100644 --- a/ceilometer/storage/impl_log.py +++ b/ceilometer/storage/impl_log.py @@ -53,10 +53,11 @@ class Connection(base.Connection): :param data: a dictionary such as returned by ceilometer.meter.meter_message_from_counter """ - LOG.info('metering data %s for %s: %s', - data['counter_name'], - data['resource_id'], - data['counter_volume']) + LOG.info(_('metering data %(counter_name)s for %(resource_id)s: ' + '%(counter_volume)s') + % ({'counter_name': data['counter_name'], + 'resource_id': data['resource_id'], + 'counter_volume': data['counter_volume']})) def clear_expired_metering_data(self, ttl): """Clear expired data from the backend storage system according to the @@ -65,7 +66,7 @@ class Connection(base.Connection): :param ttl: Number of seconds to keep records for. """ - LOG.info("Dropping data with TTL %d", ttl) + LOG.info(_("Dropping data with TTL %d"), ttl) def get_users(self, source=None): """Return an iterable of user id strings. diff --git a/ceilometer/storage/impl_sqlalchemy.py b/ceilometer/storage/impl_sqlalchemy.py index 131a52361..2c8ee180b 100644 --- a/ceilometer/storage/impl_sqlalchemy.py +++ b/ceilometer/storage/impl_sqlalchemy.py @@ -916,7 +916,7 @@ class Connection(base.Connection): problem_events.append((api_models.Event.DUPLICATE, event_model)) except Exception as e: - LOG.exception('Failed to record event: %s', e) + LOG.exception(_('Failed to record event: %s') % e) problem_events.append((api_models.Event.UNKNOWN_PROBLEM, event_model)) events.append(event) diff --git a/ceilometer/transformer/conversions.py b/ceilometer/transformer/conversions.py index 769aa96f4..5ced6d157 100644 --- a/ceilometer/transformer/conversions.py +++ b/ceilometer/transformer/conversions.py @@ -98,10 +98,10 @@ class ScalingTransformer(transformer.TransformerBase): def handle_sample(self, context, s): """Handle a sample, converting if necessary.""" - LOG.debug('handling sample %s', (s,)) + LOG.debug(_('handling sample %s'), (s,)) if (self.source.get('unit', s.unit) == s.unit): s = self._convert(s) - LOG.debug(_('converted to: %s') % (s,)) + LOG.debug(_('converted to: %s'), (s,)) return s @@ -120,7 +120,7 @@ class RateOfChangeTransformer(ScalingTransformer): def handle_sample(self, context, s): """Handle a sample, converting if necessary.""" - LOG.debug('handling sample %s', (s,)) + LOG.debug(_('handling sample %s'), (s,)) key = s.name + s.resource_id prev = self.cache.get(key) timestamp = timeutils.parse_isotime(s.timestamp) @@ -141,9 +141,9 @@ class RateOfChangeTransformer(ScalingTransformer): if time_delta else 0.0) s = self._convert(s, rate_of_change) - LOG.debug(_('converted to: %s') % (s,)) + LOG.debug(_('converted to: %s'), (s,)) else: - LOG.warn(_('dropping sample with no predecessor: %s') % + LOG.warn(_('dropping sample with no predecessor: %s'), (s,)) s = None return s