Handle log message interpolation by the logger part 5
The following directories were checked in this commit: - conductor/ - configuration/ 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: Ib46b6a5c947e250ec549ed9be1b8a7862f528d52 Related-Bug: #1642552
This commit is contained in:
parent
3d3181f56f
commit
7191530abb
@ -69,8 +69,8 @@ class API(object):
|
||||
secure_serializer=sz.ConductorGuestSerializer)
|
||||
|
||||
def heartbeat(self, instance_id, payload, sent=None):
|
||||
LOG.debug("Making async call to cast heartbeat for instance: %s"
|
||||
% instance_id)
|
||||
LOG.debug("Making async call to cast heartbeat for instance: %s",
|
||||
instance_id)
|
||||
version = self.API_BASE_VERSION
|
||||
|
||||
cctxt = self.client.prepare(version=version)
|
||||
@ -81,8 +81,8 @@ class API(object):
|
||||
|
||||
def update_backup(self, instance_id, backup_id, sent=None,
|
||||
**backup_fields):
|
||||
LOG.debug("Making async call to cast update_backup for instance: %s"
|
||||
% instance_id)
|
||||
LOG.debug("Making async call to cast update_backup for instance: %s",
|
||||
instance_id)
|
||||
version = self.API_BASE_VERSION
|
||||
|
||||
cctxt = self.client.prepare(version=version)
|
||||
@ -93,8 +93,8 @@ class API(object):
|
||||
**backup_fields)
|
||||
|
||||
def report_root(self, instance_id, user):
|
||||
LOG.debug("Making async call to cast report_root for instance: %s"
|
||||
% instance_id)
|
||||
LOG.debug("Making async call to cast report_root for instance: %s",
|
||||
instance_id)
|
||||
version = self.API_BASE_VERSION
|
||||
cctxt = self.client.prepare(version=version)
|
||||
cctxt.cast(self.context, "report_root",
|
||||
|
@ -47,11 +47,10 @@ class Manager(periodic_task.PeriodicTasks):
|
||||
|
||||
if sent is None:
|
||||
LOG.error(_("[Instance %s] sent field not present. Cannot "
|
||||
"compare.") % instance_id)
|
||||
"compare."), instance_id)
|
||||
return False
|
||||
|
||||
LOG.debug("Instance %(instance)s sent %(method)s at %(sent)s "
|
||||
% fields)
|
||||
LOG.debug("Instance %(instance)s sent %(method)s at %(sent)s ", fields)
|
||||
|
||||
seen = None
|
||||
try:
|
||||
@ -63,7 +62,7 @@ class Manager(periodic_task.PeriodicTasks):
|
||||
|
||||
if seen is None:
|
||||
LOG.debug("[Instance %s] Did not find any previous message. "
|
||||
"Creating." % instance_id)
|
||||
"Creating.", instance_id)
|
||||
seen = LastSeen.create(instance_id=instance_id,
|
||||
method_name=method_name,
|
||||
sent=sent)
|
||||
@ -73,17 +72,17 @@ class Manager(periodic_task.PeriodicTasks):
|
||||
last_sent = float(seen.sent)
|
||||
if last_sent < sent:
|
||||
LOG.debug("[Instance %s] Rec'd message is younger than last "
|
||||
"seen. Updating." % instance_id)
|
||||
"seen. Updating.", instance_id)
|
||||
seen.sent = sent
|
||||
seen.save()
|
||||
return False
|
||||
|
||||
LOG.info(_("[Instance %s] Rec'd message is older than last seen. "
|
||||
"Discarding.") % instance_id)
|
||||
"Discarding."), instance_id)
|
||||
return True
|
||||
|
||||
def heartbeat(self, context, instance_id, payload, sent=None):
|
||||
LOG.debug("Instance ID: %(instance)s, Payload: %(payload)s" %
|
||||
LOG.debug("Instance ID: %(instance)s, Payload: %(payload)s",
|
||||
{"instance": str(instance_id),
|
||||
"payload": str(payload)})
|
||||
status = inst_models.InstanceServiceStatus.find_by(
|
||||
@ -97,7 +96,7 @@ class Manager(periodic_task.PeriodicTasks):
|
||||
|
||||
def update_backup(self, context, instance_id, backup_id,
|
||||
sent=None, **backup_fields):
|
||||
LOG.debug("Instance ID: %(instance)s, Backup ID: %(backup)s" %
|
||||
LOG.debug("Instance ID: %(instance)s, Backup ID: %(backup)s",
|
||||
{"instance": str(instance_id),
|
||||
"backup": str(backup_id)})
|
||||
backup = bkup_models.DBBackup.find_by(id=backup_id)
|
||||
@ -114,7 +113,7 @@ class Manager(periodic_task.PeriodicTasks):
|
||||
'instance': str(instance_id),
|
||||
}
|
||||
LOG.error(_("[Instance: %(instance)s] Backup IDs mismatch! "
|
||||
"Expected %(expected)s, found %(found)s") % fields)
|
||||
"Expected %(expected)s, found %(found)s"), fields)
|
||||
return
|
||||
if instance_id != backup.instance_id:
|
||||
fields = {
|
||||
@ -124,7 +123,7 @@ class Manager(periodic_task.PeriodicTasks):
|
||||
}
|
||||
LOG.error(_("[Instance: %(instance)s] Backup instance IDs "
|
||||
"mismatch! Expected %(expected)s, found "
|
||||
"%(found)s") % fields)
|
||||
"%(found)s"), fields)
|
||||
return
|
||||
|
||||
for k, v in backup_fields.items():
|
||||
@ -133,7 +132,7 @@ class Manager(periodic_task.PeriodicTasks):
|
||||
'key': k,
|
||||
'value': v,
|
||||
}
|
||||
LOG.debug("Backup %(key)s: %(value)s" % fields)
|
||||
LOG.debug("Backup %(key)s: %(value)s", fields)
|
||||
setattr(backup, k, v)
|
||||
backup.save()
|
||||
|
||||
@ -149,6 +148,6 @@ class Manager(periodic_task.PeriodicTasks):
|
||||
message, exception):
|
||||
notification = SerializableNotification.deserialize(
|
||||
context, serialized_notification)
|
||||
LOG.error(_("Guest exception on request %(req)s:\n%(exc)s")
|
||||
% {'req': notification.request_id, 'exc': exception})
|
||||
LOG.error(_("Guest exception on request %(req)s:\n%(exc)s"),
|
||||
{'req': notification.request_id, 'exc': exception})
|
||||
notification.notify_exc_info(message, exception)
|
||||
|
@ -51,8 +51,8 @@ class Configurations(object):
|
||||
db_info = DBConfiguration.find_all(tenant_id=context.tenant,
|
||||
deleted=False)
|
||||
if db_info.count() == 0:
|
||||
LOG.debug("No configurations found for tenant %s"
|
||||
% context.tenant)
|
||||
LOG.debug("No configurations found for tenant %s",
|
||||
context.tenant)
|
||||
|
||||
limit = utils.pagination_limit(context.limit,
|
||||
Configurations.DEFAULT_LIMIT)
|
||||
@ -90,8 +90,8 @@ class Configuration(object):
|
||||
|
||||
@staticmethod
|
||||
def create_items(cfg_id, values):
|
||||
LOG.debug("Saving configuration values for %s - "
|
||||
"values: %s" % (cfg_id, values))
|
||||
LOG.debug("Saving configuration values for %(id)s - "
|
||||
"values: %(values)s", {'id': cfg_id, 'values': values})
|
||||
config_items = []
|
||||
for key, val in values.items():
|
||||
config_item = DBConfigurationParameter.create(
|
||||
@ -113,7 +113,7 @@ class Configuration(object):
|
||||
def remove_all_items(context, id, deleted_at):
|
||||
items = DBConfigurationParameter.find_all(configuration_id=id,
|
||||
deleted=False).all()
|
||||
LOG.debug("Removing all configuration values for %s" % id)
|
||||
LOG.debug("Removing all configuration values for %s", id)
|
||||
for item in items:
|
||||
item.deleted = True
|
||||
item.deleted_at = deleted_at
|
||||
@ -187,15 +187,15 @@ class Configuration(object):
|
||||
self.configuration_id)
|
||||
config_items = Configuration.load_items(self.context,
|
||||
id=self.configuration_id)
|
||||
LOG.debug("config_items: %s" % config_items)
|
||||
LOG.debug("config_items: %s", config_items)
|
||||
detail_list = DatastoreConfigurationParameters.load_parameters(
|
||||
datastore_v.id, show_deleted=True)
|
||||
|
||||
for i in config_items:
|
||||
LOG.debug("config item: %s" % i)
|
||||
LOG.debug("config item: %s", i)
|
||||
details = Configuration.find_parameter_details(
|
||||
i.configuration_key, detail_list)
|
||||
LOG.debug("parameter details: %s" % details)
|
||||
LOG.debug("parameter details: %s", details)
|
||||
if not details:
|
||||
raise exception.NotFound(uuid=i.configuration_key)
|
||||
if bool(details.restart_required):
|
||||
|
@ -59,8 +59,8 @@ class ConfigurationsController(wsgi.Controller):
|
||||
return wsgi.Result(paged.data(), 200)
|
||||
|
||||
def show(self, req, tenant_id, id):
|
||||
LOG.debug("Showing configuration group %(id)s on tenant %(tenant)s"
|
||||
% {"tenant": tenant_id, "id": id})
|
||||
LOG.debug("Showing configuration group %(id)s on tenant %(tenant)s",
|
||||
{"tenant": tenant_id, "id": id})
|
||||
context = req.environ[wsgi.CONTEXT_KEY]
|
||||
configuration = models.Configuration.load(context, id)
|
||||
self.authorize_config_action(context, 'show', configuration)
|
||||
@ -96,8 +96,8 @@ class ConfigurationsController(wsgi.Controller):
|
||||
return wsgi.Result(paged.data(), 200)
|
||||
|
||||
def create(self, req, body, tenant_id):
|
||||
LOG.debug("req : '%s'\n\n" % req)
|
||||
LOG.debug("body : '%s'\n\n" % req)
|
||||
LOG.debug("req : '%s'\n\n", req)
|
||||
LOG.debug("body : '%s'\n\n", req)
|
||||
|
||||
context = req.environ[wsgi.CONTEXT_KEY]
|
||||
policy.authorize_on_tenant(context, 'configuration:create')
|
||||
@ -109,7 +109,7 @@ class ConfigurationsController(wsgi.Controller):
|
||||
|
||||
msg = _("Creating configuration group on tenant "
|
||||
"%(tenant_id)s with name: %(cfg_name)s")
|
||||
LOG.info(msg % {"tenant_id": tenant_id, "cfg_name": name})
|
||||
LOG.info(msg, {"tenant_id": tenant_id, "cfg_name": name})
|
||||
|
||||
datastore_args = body['configuration'].get('datastore', {})
|
||||
datastore, datastore_version = (
|
||||
@ -146,7 +146,7 @@ class ConfigurationsController(wsgi.Controller):
|
||||
def delete(self, req, tenant_id, id):
|
||||
msg = _("Deleting configuration group %(cfg_id)s on tenant: "
|
||||
"%(tenant_id)s")
|
||||
LOG.info(msg % {"tenant_id": tenant_id, "cfg_id": id})
|
||||
LOG.info(msg, {"tenant_id": tenant_id, "cfg_id": id})
|
||||
|
||||
context = req.environ[wsgi.CONTEXT_KEY]
|
||||
group = models.Configuration.load(context, id)
|
||||
@ -166,7 +166,7 @@ class ConfigurationsController(wsgi.Controller):
|
||||
def update(self, req, body, tenant_id, id):
|
||||
msg = _("Updating configuration group %(cfg_id)s for tenant "
|
||||
"id %(tenant_id)s")
|
||||
LOG.info(msg % {"tenant_id": tenant_id, "cfg_id": id})
|
||||
LOG.info(msg, {"tenant_id": tenant_id, "cfg_id": id})
|
||||
|
||||
context = req.environ[wsgi.CONTEXT_KEY]
|
||||
group = models.Configuration.load(context, id)
|
||||
@ -219,8 +219,8 @@ class ConfigurationsController(wsgi.Controller):
|
||||
def _refresh_on_all_instances(self, context, configuration_id):
|
||||
"""Refresh a configuration group on all single instances.
|
||||
"""
|
||||
LOG.debug("Re-applying configuration group '%s' to all instances."
|
||||
% configuration_id)
|
||||
LOG.debug("Re-applying configuration group '%s' to all instances.",
|
||||
configuration_id)
|
||||
single_instances = instances_models.DBInstance.find_all(
|
||||
tenant_id=context.tenant,
|
||||
configuration_id=configuration_id,
|
||||
@ -229,24 +229,23 @@ class ConfigurationsController(wsgi.Controller):
|
||||
|
||||
config = models.Configuration(context, configuration_id)
|
||||
for dbinstance in single_instances:
|
||||
LOG.debug("Re-applying configuration to instance: %s"
|
||||
% dbinstance.id)
|
||||
LOG.debug("Re-applying configuration to instance: %s",
|
||||
dbinstance.id)
|
||||
instance = instances_models.Instance.load(context, dbinstance.id)
|
||||
instance.update_configuration(config)
|
||||
|
||||
def _refresh_on_all_clusters(self, context, configuration_id):
|
||||
"""Refresh a configuration group on all clusters.
|
||||
"""
|
||||
LOG.debug("Re-applying configuration group '%s' to all clusters."
|
||||
% configuration_id)
|
||||
LOG.debug("Re-applying configuration group '%s' to all clusters.",
|
||||
configuration_id)
|
||||
clusters = cluster_models.DBCluster.find_all(
|
||||
tenant_id=context.tenant,
|
||||
configuration_id=configuration_id,
|
||||
deleted=False).all()
|
||||
|
||||
for dbcluster in clusters:
|
||||
LOG.debug("Re-applying configuration to cluster: %s"
|
||||
% dbcluster.id)
|
||||
LOG.debug("Re-applying configuration to cluster: %s", dbcluster.id)
|
||||
cluster = cluster_models.Cluster.load(context, dbcluster.id)
|
||||
cluster.configuration_attach(configuration_id)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user