Handle log message interpolation by the logger part 10

The following directories were fixed in this commit:
  - module/
  - quota/
  - taskmanager/

According to OpenStack Guideline[1], logged string message should be
interpolated by the logger.

[1]: http://docs.openstack.org/developer/oslo.i18n/guidelines.html#adding-variables-to-log-messages

Change-Id: Iabfb6e8caeae3afe057b77315f26f9fdcaffda54
Related-Bug: #1642552
This commit is contained in:
Gábor Antal 2017-02-15 16:22:43 +01:00
parent 3f159fe844
commit 219d8f9dc4
6 changed files with 239 additions and 233 deletions

View File

@ -68,7 +68,7 @@ class Modules(object):
db_info = db_info.filter(or_(DBModule.tenant_id == context.tenant,
DBModule.tenant_id.is_(None)))
if db_info.count() == 0:
LOG.debug("No modules found for tenant %s" % context.tenant)
LOG.debug("No modules found for tenant %s", context.tenant)
modules = db_info.all()
return modules
@ -87,7 +87,7 @@ class Modules(object):
db_info = Modules.add_datastore_filter(db_info, datastore_id)
db_info = Modules.add_ds_version_filter(db_info, datastore_version_id)
if db_info.count() == 0:
LOG.debug("No auto-apply modules found for tenant %s" %
LOG.debug("No auto-apply modules found for tenant %s",
context.tenant)
modules = db_info.all()
return modules
@ -161,7 +161,7 @@ class Module(object):
datastore_version, auto_apply, visible, live_update,
priority_apply, apply_order, full_access):
if module_type.lower() not in Modules.VALID_MODULE_TYPES:
LOG.error(_("Valid module types: %s") % Modules.VALID_MODULE_TYPES)
LOG.error(_("Valid module types: %s"), Modules.VALID_MODULE_TYPES)
raise exception.ModuleTypeNotFound(module_type=module_type)
Module.validate_action(
context, 'create', tenant_id, auto_apply, visible, priority_apply,
@ -400,13 +400,16 @@ class InstanceModule(object):
InstanceModule.update(context, instance_module)
else:
if old_im.md5 == md5 and instance_module:
LOG.debug("Found dupe IM record %s; marking as deleted "
"(instance %s, module %s)." %
(old_im.id, instance_id, module_id))
LOG.debug("Found dupe IM record %(old_im)s; marking as "
"deleted (instance %(instance_id)s, "
"module %(module_id)s).",
{'old_im': old_im.id, 'instance_id': instance_id,
'module_id': module_id})
else:
LOG.debug("Deleting IM record %s (instance %s, "
"module %s)." %
(old_im.id, instance_id, module_id))
LOG.debug("Deleting IM record %(old_im)s (instance "
"%(instance_id)s, module %(module_id)s).",
{'old_im': old_im.id, 'instance_id': instance_id,
'module_id': module_id})
InstanceModule.delete(context, old_im)
# If we don't have an instance module, it means we need to create

View File

@ -64,7 +64,7 @@ class ModuleController(wsgi.Controller):
return wsgi.Result(view.data(), 200)
def show(self, req, tenant_id, id):
LOG.info(_("Showing module %s.") % id)
LOG.info(_("Showing module %s."), id)
context = req.environ[wsgi.CONTEXT_KEY]
module = models.Module.load(context, id)
@ -78,7 +78,7 @@ class ModuleController(wsgi.Controller):
def create(self, req, body, tenant_id):
name = body['module']['name']
LOG.info(_("Creating module '%s'") % name)
LOG.info(_("Creating module '%s'"), name)
context = req.environ[wsgi.CONTEXT_KEY]
policy.authorize_on_tenant(context, 'module:create')
@ -106,7 +106,7 @@ class ModuleController(wsgi.Controller):
return wsgi.Result(view_data.data(), 200)
def delete(self, req, tenant_id, id):
LOG.info(_("Deleting module %s.") % id)
LOG.info(_("Deleting module %s."), id)
context = req.environ[wsgi.CONTEXT_KEY]
module = models.Module.load(context, id)
@ -115,7 +115,7 @@ class ModuleController(wsgi.Controller):
return wsgi.Result(None, 200)
def update(self, req, body, tenant_id, id):
LOG.info(_("Updating module %s.") % id)
LOG.info(_("Updating module %s."), id)
context = req.environ[wsgi.CONTEXT_KEY]
module = models.Module.load(context, id)
@ -173,7 +173,7 @@ class ModuleController(wsgi.Controller):
return wsgi.Result(view_data.data(), 200)
def instances(self, req, tenant_id, id):
LOG.info(_("Getting instances for module %s.") % id)
LOG.info(_("Getting instances for module %s."), id)
context = req.environ[wsgi.CONTEXT_KEY]
@ -206,7 +206,7 @@ class ModuleController(wsgi.Controller):
return wsgi.Result(result_list, 200)
def reapply(self, req, body, tenant_id, id):
LOG.info(_("Reapplying module %s to all instances.") % id)
LOG.info(_("Reapplying module %s to all instances."), id)
context = req.environ[wsgi.CONTEXT_KEY]
md5 = None

View File

@ -309,7 +309,7 @@ class QuotaEngine(object):
reservations = self._driver.reserve(tenant_id, self._resources, deltas)
LOG.debug("Created reservations %(reservations)s" %
LOG.debug("Created reservations %(reservations)s",
{'reservations': reservations})
return reservations
@ -325,7 +325,7 @@ class QuotaEngine(object):
self._driver.commit(reservations)
except Exception:
LOG.exception(_("Failed to commit reservations "
"%(reservations)s") % {'reservations': reservations})
"%(reservations)s"), {'reservations': reservations})
def rollback(self, reservations):
"""Roll back reservations.
@ -338,7 +338,7 @@ class QuotaEngine(object):
self._driver.rollback(reservations)
except Exception:
LOG.exception(_("Failed to roll back reservations "
"%(reservations)s") % {'reservations': reservations})
"%(reservations)s"), {'reservations': reservations})
@property
def resources(self):

View File

@ -73,7 +73,7 @@ class API(object):
self.client = self.get_client(target, version_cap)
def _cast(self, method_name, version, **kwargs):
LOG.debug("Casting %s" % method_name)
LOG.debug("Casting %s", method_name)
with NotificationCastWrapper(self.context, 'taskmanager'):
cctxt = self.client.prepare(version=version)
cctxt.cast(self.context, method_name, **kwargs)
@ -107,8 +107,8 @@ class API(object):
LOG.error(e.message)
def resize_volume(self, new_size, instance_id):
LOG.debug("Making async call to resize volume for instance: %s"
% instance_id)
LOG.debug("Making async call to resize volume for instance: %s",
instance_id)
version = self.API_BASE_VERSION
self._cast("resize_volume", version=version,
@ -116,7 +116,7 @@ class API(object):
instance_id=instance_id)
def resize_flavor(self, instance_id, old_flavor, new_flavor):
LOG.debug("Making async call to resize flavor for instance: %s" %
LOG.debug("Making async call to resize flavor for instance: %s",
instance_id)
version = self.API_BASE_VERSION
@ -126,54 +126,54 @@ class API(object):
new_flavor=self._transform_obj(new_flavor))
def reboot(self, instance_id):
LOG.debug("Making async call to reboot instance: %s" % instance_id)
LOG.debug("Making async call to reboot instance: %s", instance_id)
version = self.API_BASE_VERSION
self._cast("reboot", version=version, instance_id=instance_id)
def restart(self, instance_id):
LOG.debug("Making async call to restart instance: %s" % instance_id)
LOG.debug("Making async call to restart instance: %s", instance_id)
version = self.API_BASE_VERSION
self._cast("restart", version=version, instance_id=instance_id)
def detach_replica(self, instance_id):
LOG.debug("Making async call to detach replica: %s" % instance_id)
LOG.debug("Making async call to detach replica: %s", instance_id)
version = self.API_BASE_VERSION
self._cast("detach_replica", version=version,
instance_id=instance_id)
def promote_to_replica_source(self, instance_id):
LOG.debug("Making async call to promote replica to source: %s" %
LOG.debug("Making async call to promote replica to source: %s",
instance_id)
version = self.API_BASE_VERSION
self._cast("promote_to_replica_source", version=version,
instance_id=instance_id)
def eject_replica_source(self, instance_id):
LOG.debug("Making async call to eject replica source: %s" %
LOG.debug("Making async call to eject replica source: %s",
instance_id)
version = self.API_BASE_VERSION
self._cast("eject_replica_source", version=version,
instance_id=instance_id)
def migrate(self, instance_id, host):
LOG.debug("Making async call to migrate instance: %s" % instance_id)
LOG.debug("Making async call to migrate instance: %s", instance_id)
version = self.API_BASE_VERSION
self._cast("migrate", version=version,
instance_id=instance_id, host=host)
def delete_instance(self, instance_id):
LOG.debug("Making async call to delete instance: %s" % instance_id)
LOG.debug("Making async call to delete instance: %s", instance_id)
version = self.API_BASE_VERSION
self._cast("delete_instance", version=version,
instance_id=instance_id)
def create_backup(self, backup_info, instance_id):
LOG.debug("Making async call to create a backup for instance: %s" %
LOG.debug("Making async call to create a backup for instance: %s",
instance_id)
version = self.API_BASE_VERSION
@ -182,7 +182,7 @@ class API(object):
instance_id=instance_id)
def delete_backup(self, backup_id):
LOG.debug("Making async call to delete backup: %s" % backup_id)
LOG.debug("Making async call to delete backup: %s", backup_id)
version = self.API_BASE_VERSION
self._cast("delete_backup", version=version, backup_id=backup_id)
@ -195,7 +195,7 @@ class API(object):
cluster_config=None, volume_type=None,
modules=None, locality=None):
LOG.debug("Making async call to create instance %s " % instance_id)
LOG.debug("Making async call to create instance %s ", instance_id)
version = self.API_BASE_VERSION
self._cast("create_instance", version=version,
instance_id=instance_id, name=name,
@ -217,13 +217,13 @@ class API(object):
modules=modules, locality=locality)
def create_cluster(self, cluster_id):
LOG.debug("Making async call to create cluster %s " % cluster_id)
LOG.debug("Making async call to create cluster %s ", cluster_id)
version = self.API_BASE_VERSION
self._cast("create_cluster", version=version, cluster_id=cluster_id)
def grow_cluster(self, cluster_id, new_instance_ids):
LOG.debug("Making async call to grow cluster %s " % cluster_id)
LOG.debug("Making async call to grow cluster %s ", cluster_id)
version = self.API_BASE_VERSION
cctxt = self.client.prepare(version=version)
@ -231,7 +231,7 @@ class API(object):
cluster_id=cluster_id, new_instance_ids=new_instance_ids)
def shrink_cluster(self, cluster_id, instance_ids):
LOG.debug("Making async call to shrink cluster %s " % cluster_id)
LOG.debug("Making async call to shrink cluster %s ", cluster_id)
version = self.API_BASE_VERSION
cctxt = self.client.prepare(version=version)
@ -239,14 +239,14 @@ class API(object):
cluster_id=cluster_id, instance_ids=instance_ids)
def delete_cluster(self, cluster_id):
LOG.debug("Making async call to delete cluster %s " % cluster_id)
LOG.debug("Making async call to delete cluster %s ", cluster_id)
version = self.API_BASE_VERSION
self._cast("delete_cluster", version=version, cluster_id=cluster_id)
def upgrade(self, instance_id, datastore_version_id):
LOG.debug("Making async call to upgrade guest to datastore "
"version %s " % datastore_version_id)
"version %s ", datastore_version_id)
version = self.API_BASE_VERSION
cctxt = self.client.prepare(version=version)
@ -254,7 +254,7 @@ class API(object):
datastore_version_id=datastore_version_id)
def restart_cluster(self, cluster_id):
LOG.debug("Making async call to restart cluster %s " % cluster_id)
LOG.debug("Making async call to restart cluster %s ", cluster_id)
version = self.API_BASE_VERSION
cctxt = self.client.prepare(version=version)
@ -262,7 +262,7 @@ class API(object):
def upgrade_cluster(self, cluster_id, datastore_version_id):
LOG.debug("Making async call to upgrade guest to datastore "
"version %s " % datastore_version_id)
"version %s ", datastore_version_id)
version = self.API_BASE_VERSION
cctxt = self.client.prepare(version=version)
@ -271,7 +271,7 @@ class API(object):
def reapply_module(self, module_id, md5, include_clustered,
batch_size, batch_delay, force):
LOG.debug("Making async call to reapply module %s" % module_id)
LOG.debug("Making async call to reapply module %s", module_id)
version = self.API_BASE_VERSION
cctxt = self.client.prepare(version=version)

View File

@ -297,14 +297,14 @@ class Manager(periodic_task.PeriodicTasks):
master_instance_tasks = BuiltInstanceTasks.load(context, slave_of_id)
server_group = master_instance_tasks.server_group
scheduler_hints = srv_grp.ServerGroup.convert_to_hint(server_group)
LOG.debug("Using scheduler hints for locality: %s" % scheduler_hints)
LOG.debug("Using scheduler hints for locality: %s", scheduler_hints)
try:
for replica_index in range(0, len(ids)):
try:
replica_number += 1
LOG.debug("Creating replica %d of %d."
% (replica_number, len(ids)))
LOG.debug("Creating replica %(num)d of %(count)d.",
{'num': replica_number, 'count': len(ids)})
instance_tasks = FreshInstanceTasks.load(
context, ids[replica_index])
snapshot = instance_tasks.get_replication_master_snapshot(
@ -322,8 +322,8 @@ class Manager(periodic_task.PeriodicTasks):
except Exception:
# if it's the first replica, then we shouldn't continue
LOG.exception(_(
"Could not create replica %(num)d of %(count)d.")
% {'num': replica_number, 'count': len(ids)})
"Could not create replica %(num)d of %(count)d."),
{'num': replica_number, 'count': len(ids)})
if replica_number == 1:
raise

File diff suppressed because it is too large Load Diff