Remove log translations
Log messages are no longer being translated. This removes all use of the _LE, _LI, and _LW translation markers to simplify logging and to avoid confusion with new contributions. See: http://lists.openstack.org/pipermail/openstack-i18n/2016-November/002574.html http://lists.openstack.org/pipermail/openstack-dev/2017-March/113365.html Change-Id: Icba5a60fff276b85e0c5df8b638d525f073faa2e
This commit is contained in:
parent
e5dfc05067
commit
d194bf597b
|
@ -24,7 +24,7 @@ import sys
|
|||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
|
||||
from kingbird.common.i18n import _, _LI
|
||||
from kingbird.common.i18n import _
|
||||
|
||||
|
||||
# from kingbird import policy
|
||||
|
@ -76,8 +76,8 @@ def setup_logging():
|
|||
"""Sets up the logging options for a log with supplied name."""
|
||||
product_name = "kingbird"
|
||||
logging.setup(cfg.CONF, product_name)
|
||||
LOG.info(_LI("Logging enabled!"))
|
||||
LOG.info(_LI("%(prog)s version %(version)s"),
|
||||
LOG.info("Logging enabled!")
|
||||
LOG.info("%(prog)s version %(version)s",
|
||||
{'prog': sys.argv[0],
|
||||
'version': version.version_info.release_string()})
|
||||
LOG.debug("command line: %s", " ".join(sys.argv))
|
||||
|
|
|
@ -31,7 +31,6 @@ from kingbird.api import api_config
|
|||
from kingbird.api import app
|
||||
|
||||
from kingbird.common import config
|
||||
from kingbird.common.i18n import _LI, _LW
|
||||
from kingbird.common import messaging
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
@ -50,10 +49,10 @@ def main():
|
|||
workers = CONF.api_workers
|
||||
|
||||
if workers < 1:
|
||||
LOG.warning(_LW("Wrong worker number, worker = %(workers)s"), workers)
|
||||
LOG.warning("Wrong worker number, worker = %(workers)s", workers)
|
||||
workers = 1
|
||||
|
||||
LOG.info(_LI("Server on http://%(host)s:%(port)s with %(workers)s"),
|
||||
LOG.info("Server on http://%(host)s:%(port)s with %(workers)s",
|
||||
{'host': host, 'port': port, 'workers': workers})
|
||||
messaging.setup()
|
||||
systemd.notify_once()
|
||||
|
@ -61,7 +60,7 @@ def main():
|
|||
|
||||
app.serve(service, CONF, workers)
|
||||
|
||||
LOG.info(_LI("Configuration:"))
|
||||
LOG.info("Configuration:")
|
||||
CONF.log_opt_values(LOG, std_logging.INFO)
|
||||
|
||||
app.wait()
|
||||
|
|
|
@ -18,13 +18,3 @@ _translators = oslo_i18n.TranslatorFactory(domain='kingbird')
|
|||
|
||||
# The primary translation function using the well-known name "_"
|
||||
_ = _translators.primary
|
||||
|
||||
# Translators for log levels.
|
||||
#
|
||||
# The abbreviated names are meant to reflect the usual use of a short
|
||||
# name like '_'. The "L" is for "log" and the other letter comes from
|
||||
# the level.
|
||||
_LI = _translators.log_info
|
||||
_LW = _translators.log_warning
|
||||
_LE = _translators.log_error
|
||||
_LC = _translators.log_critical
|
||||
|
|
|
@ -17,7 +17,6 @@ from oslo_log import log
|
|||
|
||||
from kingbird.common import consts
|
||||
from kingbird.common import exceptions
|
||||
from kingbird.common.i18n import _LI, _LE
|
||||
from kingbird.drivers import base
|
||||
|
||||
from novaclient import client
|
||||
|
@ -107,11 +106,11 @@ class NovaClient(base.DriverBase):
|
|||
"""
|
||||
try:
|
||||
keypair = self.nova_client.keypairs.get(res_id, user_id)
|
||||
LOG.info(_LI("Source Keypair: %s"), keypair.name)
|
||||
LOG.info("Source Keypair: %s", keypair.name)
|
||||
return keypair
|
||||
|
||||
except Exception as exception:
|
||||
LOG.error(_LE('Exception Occurred: %s'), exception.message)
|
||||
LOG.error('Exception Occurred: %s', exception.message)
|
||||
pass
|
||||
|
||||
def create_keypairs(self, force, keypair, user_id):
|
||||
|
@ -123,11 +122,11 @@ class NovaClient(base.DriverBase):
|
|||
if force:
|
||||
try:
|
||||
self.nova_client.keypairs.delete(keypair, user_id)
|
||||
LOG.info(_LI("Deleted Keypair: %s"), keypair.name)
|
||||
LOG.info("Deleted Keypair: %s", keypair.name)
|
||||
except Exception as exception:
|
||||
LOG.error(_LE('Exception Occurred: %s'), exception.message)
|
||||
LOG.error('Exception Occurred: %s', exception.message)
|
||||
pass
|
||||
LOG.info(_LI("Created Keypair: %s"), keypair.name)
|
||||
LOG.info("Created Keypair: %s", keypair.name)
|
||||
return self.nova_client.keypairs. \
|
||||
create(keypair.name,
|
||||
user_id=user_id,
|
||||
|
|
|
@ -23,7 +23,7 @@ from oslo_utils import timeutils
|
|||
from kingbird.common import consts
|
||||
from kingbird.common import endpoint_cache
|
||||
from kingbird.common import exceptions
|
||||
from kingbird.common.i18n import _, _LE, _LI
|
||||
from kingbird.common.i18n import _
|
||||
|
||||
from kingbird.drivers.openstack.cinder_v2 import CinderClient
|
||||
from kingbird.drivers.openstack.keystone_v3 import KeystoneClient
|
||||
|
@ -52,7 +52,7 @@ class OpenStackDriver(object):
|
|||
self.disabled_quotas = self._get_disabled_quotas(region_name)
|
||||
if region_name in OpenStackDriver.os_clients_dict and \
|
||||
self._is_token_valid():
|
||||
LOG.info(_LI('Using cached OS client objects'))
|
||||
LOG.info('Using cached OS client objects')
|
||||
self.nova_client = OpenStackDriver.os_clients_dict[
|
||||
region_name]['nova']
|
||||
self.cinder_client = OpenStackDriver.os_clients_dict[
|
||||
|
@ -84,13 +84,13 @@ class OpenStackDriver(object):
|
|||
try:
|
||||
return self.keystone_client.get_enabled_projects()
|
||||
except Exception as exception:
|
||||
LOG.error(_LE('Error Occurred: %s'), exception.message)
|
||||
LOG.error('Error Occurred: %s', exception.message)
|
||||
|
||||
def get_enabled_users(self):
|
||||
try:
|
||||
return self.keystone_client.get_enabled_users()
|
||||
except Exception as exception:
|
||||
LOG.error(_LE('Error Occurred : %s'), exception.message)
|
||||
LOG.error('Error Occurred : %s', exception.message)
|
||||
|
||||
def get_resource_usages(self, project_id):
|
||||
try:
|
||||
|
@ -104,7 +104,7 @@ class OpenStackDriver(object):
|
|||
# Delete the cached objects for that region
|
||||
del OpenStackDriver.os_clients_dict[self.region_name]
|
||||
except Exception as exception:
|
||||
LOG.error(_LE('Error Occurred: %s'), exception.message)
|
||||
LOG.error('Error Occurred: %s', exception.message)
|
||||
|
||||
def write_quota_limits(self, project_id, limits_to_write):
|
||||
try:
|
||||
|
@ -119,7 +119,7 @@ class OpenStackDriver(object):
|
|||
# Delete the cached objects for that region
|
||||
del OpenStackDriver.os_clients_dict[self.region_name]
|
||||
except Exception as exception:
|
||||
LOG.error(_LE('Error Occurred: %s'), exception.message)
|
||||
LOG.error('Error Occurred: %s', exception.message)
|
||||
|
||||
def delete_quota_limits(self, project_id):
|
||||
try:
|
||||
|
@ -131,7 +131,7 @@ class OpenStackDriver(object):
|
|||
# Delete the cached objects for that region
|
||||
del OpenStackDriver.os_clients_dict[self.region_name]
|
||||
except Exception as exception:
|
||||
LOG.error(_LE('Error Occurred: %s'), exception.message)
|
||||
LOG.error('Error Occurred: %s', exception.message)
|
||||
|
||||
def _get_disabled_quotas(self, region):
|
||||
disabled_quotas = []
|
||||
|
@ -157,7 +157,7 @@ class OpenStackDriver(object):
|
|||
region_lists = endpoint_cache.EndpointCache().get_all_regions()
|
||||
return region_lists
|
||||
except Exception as exception:
|
||||
LOG.error(_LE('Error Occurred: %s'), exception.message)
|
||||
LOG.error('Error Occurred: %s', exception.message)
|
||||
raise
|
||||
|
||||
def _get_filtered_regions(self, project_id):
|
||||
|
@ -168,7 +168,7 @@ class OpenStackDriver(object):
|
|||
try:
|
||||
token = keystone.tokens.validate(keystone.session.get_token())
|
||||
except Exception as exception:
|
||||
LOG.info(_LE('Exception Occurred: %s'), exception.message)
|
||||
LOG.info('Exception Occurred: %s', exception.message)
|
||||
# Reset the cached dictionary
|
||||
OpenStackDriver.os_clients_dict = collections.defaultdict(dict)
|
||||
return False
|
||||
|
@ -176,7 +176,7 @@ class OpenStackDriver(object):
|
|||
expiry_time = timeutils.normalize_time(timeutils.parse_isotime(
|
||||
token['expires_at']))
|
||||
if timeutils.is_soon(expiry_time, STALE_TOKEN_DURATION):
|
||||
LOG.info(_LE('The cached keystone token will expire soon'))
|
||||
LOG.info('The cached keystone token will expire soon')
|
||||
# Reset the cached dictionary
|
||||
OpenStackDriver.os_clients_dict = collections.defaultdict(dict)
|
||||
return False
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
|
||||
from kingbird.common.i18n import _, _LE, _LI
|
||||
from kingbird.common.i18n import _
|
||||
from kingbird.db import api as db_api
|
||||
from kingbird.engine import scheduler
|
||||
|
||||
|
@ -43,7 +43,7 @@ def sync_lock_acquire(context, engine_id, task_type, forced=False):
|
|||
"""
|
||||
|
||||
# Step 1: try lock the projects- if it returns True then success
|
||||
LOG.info(_LI('Trying to acquire lock with %(engId)s for Task: %(task)s'),
|
||||
LOG.info('Trying to acquire lock with %(engId)s for Task: %(task)s',
|
||||
{'engId': engine_id,
|
||||
'task': task_type
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ def sync_lock_acquire(context, engine_id, task_type, forced=False):
|
|||
|
||||
while retries > 0:
|
||||
scheduler.sleep(retry_interval)
|
||||
LOG.info(_LI('Retry acquire lock with %(engId)s for Task: %(task)s'),
|
||||
LOG.info('Retry acquire lock with %(engId)s for Task: %(task)s',
|
||||
{'engId': engine_id,
|
||||
'task': task_type
|
||||
}
|
||||
|
@ -78,8 +78,8 @@ def sync_lock_acquire(context, engine_id, task_type, forced=False):
|
|||
|
||||
# Will reach here only when not able to acquire locks with retry
|
||||
|
||||
LOG.error(_LE('Not able to acquire lock for %(task)s with retry'
|
||||
' with engineId %(engId)s'),
|
||||
LOG.error('Not able to acquire lock for %(task)s with retry'
|
||||
' with engineId %(engId)s',
|
||||
{'engId': engine_id,
|
||||
'task': task_type
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ def sync_lock_acquire(context, engine_id, task_type, forced=False):
|
|||
def sync_lock_release(context, engine_id, task_type):
|
||||
"""Release the lock for the projects"""
|
||||
|
||||
LOG.info(_LI('Releasing acquired lock with %(engId)s for Task: %(task)s'),
|
||||
LOG.info('Releasing acquired lock with %(engId)s for Task: %(task)s',
|
||||
{'engId': engine_id,
|
||||
'task': task_type
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ from kingbird.common import consts
|
|||
from kingbird.common import context
|
||||
from kingbird.common import endpoint_cache
|
||||
from kingbird.common import exceptions
|
||||
from kingbird.common.i18n import _, _LE, _LI
|
||||
from kingbird.common.i18n import _
|
||||
from kingbird.common import manager
|
||||
from kingbird.common import utils
|
||||
from kingbird.db import api as db_api
|
||||
|
@ -62,18 +62,18 @@ class QuotaManager(manager.Manager):
|
|||
self.endpoints = endpoint_cache.EndpointCache()
|
||||
|
||||
def periodic_balance_all(self, engine_id):
|
||||
LOG.info(_LI("periodically balance quota for all keystone tenants"))
|
||||
LOG.info("periodically balance quota for all keystone tenants")
|
||||
lock = kingbird_lock.sync_lock_acquire(self.context, engine_id,
|
||||
TASK_TYPE)
|
||||
if not lock:
|
||||
LOG.error(_LE("Not able to acquire lock for %(task_type)s, may"
|
||||
" be Previous sync job has not finished yet, "
|
||||
"Aborting this run at: %(time)s "),
|
||||
LOG.error("Not able to acquire lock for %(task_type)s, may"
|
||||
" be Previous sync job has not finished yet, "
|
||||
"Aborting this run at: %(time)s ",
|
||||
{'task_type': TASK_TYPE,
|
||||
'time': time.strftime("%c")}
|
||||
)
|
||||
return
|
||||
LOG.info(_LI("Successfully acquired lock"))
|
||||
LOG.info("Successfully acquired lock")
|
||||
projects_thread_list = []
|
||||
# Iterate through project list and call sync project for each project
|
||||
# using threads
|
||||
|
@ -82,7 +82,7 @@ class QuotaManager(manager.Manager):
|
|||
# for one batch at a time.
|
||||
for current_batch_projects in utils.get_batch_projects(
|
||||
cfg.CONF.batch.batch_size, project_list):
|
||||
LOG.info(_LI("Syncing quota for current batch with projects: %s"),
|
||||
LOG.info("Syncing quota for current batch with projects: %s",
|
||||
current_batch_projects)
|
||||
for current_project in current_batch_projects:
|
||||
if current_project:
|
||||
|
@ -100,7 +100,7 @@ class QuotaManager(manager.Manager):
|
|||
def read_quota_usage(self, project_id, region, usage_queue):
|
||||
# Writes usage dict to the Queue in the following format
|
||||
# {'region_name': (<nova_usages>, <neutron_usages>, <cinder_usages>)}
|
||||
LOG.info(_LI("Reading quota usage for %(project_id)s in %(region)s"),
|
||||
LOG.info("Reading quota usage for %(project_id)s in %(region)s",
|
||||
{'project_id': project_id,
|
||||
'region': region}
|
||||
)
|
||||
|
@ -173,7 +173,7 @@ class QuotaManager(manager.Manager):
|
|||
# Global remaining limit = Kingbird global limit - Summation of usages
|
||||
# in all the regions
|
||||
# New quota limit = Global remaining limit + usage in that region
|
||||
LOG.info(_LI("Quota sync Called for Project: %s"),
|
||||
LOG.info("Quota sync Called for Project: %s",
|
||||
project_id)
|
||||
regions_thread_list = []
|
||||
# Retrieve regions for the project
|
||||
|
@ -182,8 +182,8 @@ class QuotaManager(manager.Manager):
|
|||
regions_usage_dict = self.get_tenant_quota_usage_per_region(project_id)
|
||||
if not regions_usage_dict:
|
||||
# Skip syncing for the project if not able to read regions usage
|
||||
LOG.error(_LE("Error reading regions usage for the Project: '%s'. "
|
||||
"Aborting, continue with next project."), project_id)
|
||||
LOG.error("Error reading regions usage for the Project: '%s'. "
|
||||
"Aborting, continue with next project.", project_id)
|
||||
return
|
||||
total_project_usages = dict(self.get_summation(regions_usage_dict))
|
||||
kingbird_global_limit = self._get_kingbird_project_limit(project_id)
|
||||
|
@ -235,7 +235,7 @@ class QuotaManager(manager.Manager):
|
|||
|
||||
def get_total_usage_for_tenant(self, project_id):
|
||||
# Returns total quota usage for a tenant
|
||||
LOG.info(_LI("Get total usage called for project: %s"),
|
||||
LOG.info("Get total usage called for project: %s",
|
||||
project_id)
|
||||
try:
|
||||
total_usage = dict(self.get_summation(
|
||||
|
|
|
@ -21,7 +21,7 @@ import oslo_messaging
|
|||
from kingbird.common import consts
|
||||
from kingbird.common import context
|
||||
from kingbird.common import exceptions
|
||||
from kingbird.common.i18n import _, _LE, _LI
|
||||
from kingbird.common.i18n import _
|
||||
from kingbird.common import messaging as rpc_messaging
|
||||
from kingbird.engine.quota_manager import QuotaManager
|
||||
from kingbird.engine import scheduler
|
||||
|
@ -116,7 +116,7 @@ class EngineService(service.Service):
|
|||
service_obj.Service.create(ctx, self.engine_id, self.host,
|
||||
'kingbird-engine', self.topic)
|
||||
except Exception as ex:
|
||||
LOG.error(_LE('Service %(service_id)s update failed: %(error)s'),
|
||||
LOG.error('Service %(service_id)s update failed: %(error)s',
|
||||
{'service_id': self.engine_id, 'error': ex})
|
||||
|
||||
def service_registry_cleanup(self):
|
||||
|
@ -129,12 +129,12 @@ class EngineService(service.Service):
|
|||
if timeutils.is_older_than(svc['updated_at'], time_window):
|
||||
# < time_line:
|
||||
# hasn't been updated, assuming it's died.
|
||||
LOG.info(_LI('Service %s was aborted'), svc['id'])
|
||||
LOG.info('Service %s was aborted', svc['id'])
|
||||
service_obj.Service.delete(ctx, svc['id'])
|
||||
|
||||
def periodic_balance_all(self, engine_id):
|
||||
# Automated Quota Sync for all the keystone projects
|
||||
LOG.info(_LI("Periodic quota sync job started at: %s"),
|
||||
LOG.info("Periodic quota sync job started at: %s",
|
||||
time.strftime("%c"))
|
||||
self.qm.periodic_balance_all(engine_id)
|
||||
|
||||
|
@ -142,14 +142,14 @@ class EngineService(service.Service):
|
|||
def get_total_usage_for_tenant(self, context, project_id):
|
||||
# Returns a dictionary containing nova, neutron &
|
||||
# cinder usages for the project
|
||||
LOG.info(_LI("Get total tenant usage called for: %s"),
|
||||
LOG.info("Get total tenant usage called for: %s",
|
||||
project_id)
|
||||
return self.qm.get_total_usage_for_tenant(project_id)
|
||||
|
||||
@request_context
|
||||
def quota_sync_for_project(self, context, project_id):
|
||||
# On Demand Quota Sync for a project, will be triggered by KB-API
|
||||
LOG.info(_LI("On Demand Quota Sync Called for: %s"),
|
||||
LOG.info("On Demand Quota Sync Called for: %s",
|
||||
project_id)
|
||||
self.qm.quota_sync_for_project(project_id)
|
||||
|
||||
|
@ -164,9 +164,9 @@ class EngineService(service.Service):
|
|||
try:
|
||||
self._rpc_server.stop()
|
||||
self._rpc_server.wait()
|
||||
LOG.info(_LI('Engine service stopped successfully'))
|
||||
LOG.info('Engine service stopped successfully')
|
||||
except Exception as ex:
|
||||
LOG.error(_LE('Failed to stop engine service: %s'),
|
||||
LOG.error('Failed to stop engine service: %s',
|
||||
six.text_type(ex))
|
||||
|
||||
def stop(self):
|
||||
|
@ -174,5 +174,5 @@ class EngineService(service.Service):
|
|||
|
||||
self.TG.stop()
|
||||
# Terminate the engine process
|
||||
LOG.info(_LI("All threads were gone, terminating engine"))
|
||||
LOG.info("All threads were gone, terminating engine")
|
||||
super(EngineService, self).stop()
|
||||
|
|
|
@ -20,8 +20,6 @@ from oslo_log import log as logging
|
|||
from kingbird.common import consts
|
||||
from kingbird.common import context
|
||||
from kingbird.common import exceptions
|
||||
from kingbird.common.i18n import _LE
|
||||
from kingbird.common.i18n import _LI
|
||||
from kingbird.common import manager
|
||||
from kingbird.db.sqlalchemy import api as db_api
|
||||
from kingbird.drivers.openstack import sdk
|
||||
|
@ -53,7 +51,7 @@ class SyncManager(manager.Manager):
|
|||
os_client = sdk.OpenStackDriver(region)
|
||||
try:
|
||||
os_client.create_keypairs(force, source_keypair, user_id)
|
||||
LOG.info(_LI('keypair %(keypair)s created in %(region)s')
|
||||
LOG.info('keypair %(keypair)s created in %(region)s'
|
||||
% {'keypair': source_keypair.name, 'region': region})
|
||||
try:
|
||||
db_api.resource_sync_update(self.context, job_id, region,
|
||||
|
@ -62,7 +60,7 @@ class SyncManager(manager.Manager):
|
|||
except exceptions.JobNotFound():
|
||||
raise
|
||||
except Exception as exc:
|
||||
LOG.error(_LE('Exception Occurred: %(msg)s in %(region)s')
|
||||
LOG.error('Exception Occurred: %(msg)s in %(region)s'
|
||||
% {'msg': exc.message, 'region': region})
|
||||
try:
|
||||
db_api.resource_sync_update(self.context, job_id, region,
|
||||
|
@ -73,7 +71,7 @@ class SyncManager(manager.Manager):
|
|||
pass
|
||||
|
||||
def keypair_sync_for_user(self, user_id, job_id, payload):
|
||||
LOG.info(_LI("Keypair sync Called for user: %s"),
|
||||
LOG.info("Keypair sync Called for user: %s",
|
||||
user_id)
|
||||
keypairs_thread = list()
|
||||
target_regions = payload['target']
|
||||
|
|
Loading…
Reference in New Issue