Merge "Format log messages correctly"

This commit is contained in:
Jenkins 2015-12-06 05:33:53 +00:00 committed by Gerrit Code Review
commit f8e31deaa4
25 changed files with 202 additions and 259 deletions

View File

@ -41,10 +41,9 @@ class VersionNegotiationFilter(wsgi.Middleware):
def process_request(self, req):
"""Try to find a version first in the accept header, then the URL"""
msg = _("Determining version of request: %(method)s %(path)s"
" Accept: %(accept)s")
args = {'method': req.method, 'path': req.path, 'accept': req.accept}
LOG.debug(msg % args)
LOG.debug("Determining version of request: %(method)s %(path)s "
"Accept: %(accept)s", args)
# If the request is for /versions, just return the versions container
if req.path_info_peek() == "versions":

View File

@ -41,14 +41,13 @@ class BaseController(object):
try:
return registry.get_image_metadata(context, image_id)
except exception.NotFound:
msg = "Image with identifier %s not found" % image_id
LOG.debug(msg)
LOG.debug("Image with identifier %s not found", image_id)
msg = _("Image with identifier %s not found") % image_id
raise webob.exc.HTTPNotFound(
msg, request=request, content_type='text/plain')
except exception.Forbidden:
msg = "Forbidden image access"
LOG.debug(msg)
raise webob.exc.HTTPForbidden(msg,
LOG.debug("Forbidden image access")
raise webob.exc.HTTPForbidden(_("Forbidden image access"),
request=request,
content_type='text/plain')
@ -59,14 +58,12 @@ class BaseController(object):
"""
image = self.get_image_meta_or_404(request, image_id)
if image['status'] == 'deactivated':
msg = "Image %s is deactivated" % image_id
LOG.debug(msg)
LOG.debug("Image %s is deactivated", image_id)
msg = _("Image %s is deactivated") % image_id
raise webob.exc.HTTPForbidden(
msg, request=request, content_type='text/plain')
if image['status'] != 'active':
msg = "Image %s is not active" % image_id
LOG.debug(msg)
LOG.debug("Image %s is not active", image_id)
msg = _("Image %s is not active") % image_id
raise webob.exc.HTTPNotFound(
msg, request=request, content_type='text/plain')

View File

@ -195,7 +195,7 @@ class Controller(controller.BaseController):
try:
self.policy.enforce(req.context, action, target)
except exception.Forbidden:
LOG.debug("User not permitted to perform '%s' action" % action)
LOG.debug("User not permitted to perform '%s' action", action)
raise HTTPForbidden()
def _enforce_image_property_quota(self,
@ -577,8 +577,8 @@ class Controller(controller.BaseController):
try:
backend = store.get_store_from_location(location)
except (store.UnknownScheme, store.BadStoreUri):
LOG.debug("Invalid location %s", location)
msg = _("Invalid location %s") % location
LOG.debug(msg)
raise HTTPBadRequest(explanation=msg,
request=req,
content_type="text/plain")
@ -711,7 +711,7 @@ class Controller(controller.BaseController):
# Delete image data since it has been superseded by another
# upload and re-raise.
LOG.debug("duplicate operation - deleting image data for "
" %(id)s (location:%(location)s)" %
" %(id)s (location:%(location)s)",
{'id': image_id, 'location': image_meta['location']})
upload_utils.initiate_deletion(req, location_data, image_id)
except exception.Invalid as e:

View File

@ -202,9 +202,8 @@ class NamespaceController(object):
namespace_obj = namespace_repo.get(namespace.namespace)
namespace_obj.delete()
namespace_repo.remove(namespace_obj)
msg = ("Cleaned up namespace %(namespace)s "
% {'namespace': namespace.namespace})
LOG.debug(msg)
LOG.debug("Cleaned up namespace %(namespace)s ",
{'namespace': namespace.namespace})
except exception:
msg = (_LE("Failed to delete namespace %(namespace)s ") %
{'namespace': namespace.namespace})

View File

@ -68,7 +68,7 @@ class _CreateImage(task.Task):
self.image_repo, self.image_factory,
task_input.get('image_properties'), self.task_id)
LOG.debug("Task %(task_id)s created image %(image_id)s" %
LOG.debug("Task %(task_id)s created image %(image_id)s",
{'task_id': task.task_id, 'image_id': image.image_id})
return image.image_id

View File

@ -70,7 +70,7 @@ class _Introspect(utils.OptionalTask):
new_image.virtual_size = metadata.get('virtual-size', 0)
new_image.disk_format = metadata.get('format')
self.image_repo.save(new_image)
LOG.debug("%(task_id)s: Introspection successful: %(file)s" %
LOG.debug("%(task_id)s: Introspection successful: %(file)s",
{'task_id': self.task_id, 'file': file_path})
return new_image
@ -87,7 +87,7 @@ def get_flow(**kwargs):
task_type = kwargs.get('task_type')
image_repo = kwargs.get('image_repo')
LOG.debug("Flow: %(task_type)s with ID %(id)s on %(repo)s" %
LOG.debug("Flow: %(task_type)s with ID %(id)s on %(repo)s",
{'task_type': task_type, 'id': task_id, 'repo': image_repo})
return lf.Flow(task_type).add(

View File

@ -123,8 +123,8 @@ class TaskExecutor(glance.async.TaskExecutor):
def _run(self, task_id, task_type):
LOG.debug('Taskflow executor picked up the execution of task ID '
'%(task_id)s of task type '
'%(task_type)s' % {'task_id': task_id,
'task_type': task_type})
'%(task_type)s', {'task_id': task_id,
'task_type': task_type})
task = script_utils.get_task(self.task_repo, task_id)
if task is None:

View File

@ -140,22 +140,22 @@ class ImageService(object):
headers.setdefault('x-auth-token', self.auth_token)
LOG.debug('Request: %(method)s http://%(server)s:%(port)s'
'%(url)s with headers %(headers)s'
% {'method': method,
'server': self.conn.host,
'port': self.conn.port,
'url': url,
'headers': repr(headers)})
'%(url)s with headers %(headers)s',
{'method': method,
'server': self.conn.host,
'port': self.conn.port,
'url': url,
'headers': repr(headers)})
self.conn.request(method, url, body, headers)
response = self.conn.getresponse()
headers = self._header_list_to_dict(response.getheaders())
code = response.status
code_description = http_client.responses[code]
LOG.debug('Response: %(code)s %(status)s %(headers)s'
% {'code': code,
'status': code_description,
'headers': repr(headers)})
LOG.debug('Response: %(code)s %(status)s %(headers)s',
{'code': code,
'status': code_description,
'headers': repr(headers)})
if code == 400:
raise exc.HTTPBadRequest(
@ -338,7 +338,7 @@ def replication_size(options, args):
client = imageservice(http_client.HTTPConnection(server, port),
options.slavetoken)
for image in client.get_images():
LOG.debug('Considering image: %(image)s' % {'image': image})
LOG.debug('Considering image: %(image)s', {'image': image})
if image['status'] == 'active':
total_size += int(image['size'])
count += 1
@ -368,7 +368,7 @@ def replication_dump(options, args):
client = imageservice(http_client.HTTPConnection(server, port),
options.mastertoken)
for image in client.get_images():
LOG.debug('Considering: %s' % image['id'])
LOG.debug('Considering: %s', image['id'])
data_path = os.path.join(path, image['id'])
if not os.path.exists(data_path):
@ -387,7 +387,7 @@ def replication_dump(options, args):
# is the same as that which we got from the detailed images
# request earlier, so we can ignore it here. Note that we also
# only dump active images.
LOG.debug('Image %s is active' % image['id'])
LOG.debug('Image %s is active', image['id'])
image_response = client.get_image(image['id'])
with open(data_path + '.img', 'wb') as f:
while True:
@ -407,15 +407,15 @@ def _dict_diff(a, b):
"""
# Only things the master has which the slave lacks matter
if set(a.keys()) - set(b.keys()):
LOG.debug('metadata diff -- master has extra keys: %(keys)s'
% {'keys': ' '.join(set(a.keys()) - set(b.keys()))})
LOG.debug('metadata diff -- master has extra keys: %(keys)s',
{'keys': ' '.join(set(a.keys()) - set(b.keys()))})
return True
for key in a:
if str(a[key]) != str(b[key]):
LOG.debug('metadata diff -- value differs for key '
'%(key)s: master "%(master_value)s" vs '
'slave "%(slave_value)s"' %
'slave "%(slave_value)s"',
{'key': key,
'master_value': a[key],
'slave_value': b[key]})
@ -482,7 +482,7 @@ def replication_load(options, args):
else:
if not os.path.exists(os.path.join(path, image_uuid + '.img')):
LOG.debug('%s dump is missing image data, skipping' %
LOG.debug('%s dump is missing image data, skipping',
image_uuid)
continue
@ -525,7 +525,7 @@ def replication_livecopy(options, args):
updated = []
for image in master_client.get_images():
LOG.debug('Considering %(id)s' % {'id': image['id']})
LOG.debug('Considering %(id)s', {'id': image['id']})
for key in options.dontreplicate.split(' '):
if key in image:
LOG.debug('Stripping %(header)s from master metadata',
@ -618,8 +618,8 @@ def replication_compare(options, args):
'slave_value': headers.get(key, 'undefined')})
differences[image['id']] = 'diff'
else:
LOG.debug('%(image_id)s is identical'
% {'image_id': image['id']})
LOG.debug('%(image_id)s is identical',
{'image_id': image['id']})
elif image['status'] == 'active':
LOG.warn(_LW('Image %s entirely missing from the destination')

View File

@ -307,9 +307,8 @@ class BaseClient(object):
if self.DEFAULT_DOC_ROOT:
doc_root = self.DEFAULT_DOC_ROOT.lstrip('/')
self.doc_root += '/' + doc_root
msg = ("Appending doc_root %(doc_root)s to URL %(url)s" %
{'doc_root': doc_root, 'url': url})
LOG.debug(msg)
LOG.debug("Appending doc_root %(doc_root)s to URL %(url)s",
{'doc_root': doc_root, 'url': url})
# ensure connection kwargs are re-evaluated after the service catalog
# publicURL is parsed for potential SSL usage

View File

@ -132,10 +132,9 @@ def create_image(image_repo, image_factory, image_properties, task_id):
try:
properties[key] = image_properties.pop(key)
except KeyError:
msg = ("Task ID %(task_id)s: Ignoring property %(k)s for setting "
"base properties while creating "
"Image.") % {'task_id': task_id, 'k': key}
LOG.debug(msg)
LOG.debug("Task ID %(task_id)s: Ignoring property %(k)s for "
"setting base properties while creating "
"Image.", {'task_id': task_id, 'k': key})
# NOTE: get the rest of the properties and pass them as
# extra_properties for Image to be created with them.

View File

@ -645,7 +645,7 @@ class APIMapper(routes.Mapper):
class RejectMethodController(object):
def reject(self, req, allowed_methods, *args, **kwargs):
LOG.debug("The method %s is not allowed for this resource" %
LOG.debug("The method %s is not allowed for this resource",
req.environ['REQUEST_METHOD'])
raise webob.exc.HTTPMethodNotAllowed(
headers=[('Allow', allowed_methods)])

View File

@ -892,8 +892,7 @@ def task_update(context, task_id, values):
try:
task = DATA['tasks'][task_id]
except KeyError:
msg = "No task found with ID %s" % task_id
LOG.debug(msg)
LOG.debug("No task found with ID %s", task_id)
raise exception.TaskNotFound(task_id=task_id)
task.update(task_values)
@ -924,8 +923,7 @@ def _task_get(context, task_id, force_show_deleted=False):
raise exception.TaskNotFound(task_id=task_id)
if not _is_task_visible(context, task):
msg = "Forbidding request, task %s is not visible" % task_id
LOG.debug(msg)
LOG.debug("Forbidding request, task %s is not visible", task_id)
msg = _("Forbidding request, task %s is not visible") % task_id
raise exception.Forbidden(msg)
@ -943,8 +941,7 @@ def task_delete(context, task_id):
DATA['tasks'][task_id]['updated_at'] = timeutils.utcnow()
return copy.deepcopy(DATA['tasks'][task_id])
except KeyError:
msg = "No task found with ID %s" % task_id
LOG.debug(msg)
LOG.debug("No task found with ID %s", task_id)
raise exception.TaskNotFound(task_id=task_id)
@ -1064,8 +1061,7 @@ def _task_info_update(task_id, values):
try:
task_info = DATA['task_info'][task_id]
except KeyError:
msg = "No task info found with task id %s" % task_id
LOG.debug(msg)
LOG.debug("No task info found with task id %s", task_id)
raise exception.TaskNotFound(task_id=task_id)
task_info.update(values)
@ -1109,9 +1105,8 @@ def metadef_namespace_create(context, values):
for namespace in DATA['metadef_namespaces']:
if namespace['namespace'] == namespace_name:
msg = ("Can not create the metadata definition namespace. "
"Namespace=%s already exists.") % namespace_name
LOG.debug(msg)
LOG.debug("Can not create the metadata definition namespace. "
"Namespace=%s already exists.", namespace_name)
raise exception.MetadefDuplicateNamespace(
namespace_name=namespace_name)
@ -1140,11 +1135,9 @@ def metadef_namespace_update(context, namespace_id, values):
if namespace['namespace'] != values['namespace']:
for db_namespace in DATA['metadef_namespaces']:
if db_namespace['namespace'] == values['namespace']:
msg = ("Invalid update. It would result in a duplicate"
" metadata definition namespace with the same"
" name of %s"
% values['namespace'])
LOG.debug(msg)
LOG.debug("Invalid update. It would result in a duplicate "
"metadata definition namespace with the same "
"name of %s", values['namespace'])
emsg = (_("Invalid update. It would result in a duplicate"
" metadata definition namespace with the same"
" name of %s")
@ -1172,11 +1165,10 @@ def metadef_namespace_get_by_id(context, namespace_id):
raise exception.MetadefNamespaceNotFound(msg)
if not _is_namespace_visible(context, namespace):
msg = ("Forbidding request, metadata definition namespace=%s"
" is not visible.") % namespace.namespace
LOG.debug(msg)
emsg = _("Forbidding request, metadata definition namespace=%s"
" is not visible.") % namespace.namespace
LOG.debug("Forbidding request, metadata definition namespace=%s "
"is not visible.", namespace.namespace)
emsg = _("Forbidding request, metadata definition namespace=%s "
"is not visible.") % namespace.namespace
raise exception.MetadefForbidden(emsg)
return namespace
@ -1189,8 +1181,7 @@ def metadef_namespace_get(context, namespace_name):
namespace = next(namespace for namespace in DATA['metadef_namespaces']
if namespace['namespace'] == namespace_name)
except StopIteration:
msg = "No namespace found with name %s" % namespace_name
LOG.debug(msg)
LOG.debug("No namespace found with name %s", namespace_name)
raise exception.MetadefNamespaceNotFound(
namespace_name=namespace_name)
@ -1280,10 +1271,9 @@ def metadef_object_get(context, namespace_name, object_name):
object['name'] == object_name):
return object
else:
msg = ("The metadata definition object with name=%(name)s"
" was not found in namespace=%(namespace_name)s."
% {'name': object_name, 'namespace_name': namespace_name})
LOG.debug(msg)
LOG.debug("The metadata definition object with name=%(name)s"
" was not found in namespace=%(namespace_name)s.",
{'name': object_name, 'namespace_name': namespace_name})
raise exception.MetadefObjectNotFound(namespace_name=namespace_name,
object_name=object_name)
@ -1337,10 +1327,9 @@ def metadef_object_create(context, namespace_name, values):
for object in DATA['metadef_objects']:
if (object['name'] == object_name and
object['namespace_id'] == namespace['id']):
msg = ("A metadata definition object with name=%(name)s"
" in namespace=%(namespace_name)s already exists."
% {'name': object_name, 'namespace_name': namespace_name})
LOG.debug(msg)
LOG.debug("A metadata definition object with name=%(name)s "
"in namespace=%(namespace_name)s already exists.",
{'name': object_name, 'namespace_name': namespace_name})
raise exception.MetadefDuplicateObject(
object_name=object_name, namespace_name=namespace_name)
@ -1377,12 +1366,11 @@ def metadef_object_update(context, namespace_name, object_id, values):
for db_object in DATA['metadef_objects']:
if (db_object['name'] == values['name'] and
db_object['namespace_id'] == namespace['id']):
msg = ("Invalid update. It would result in a duplicate"
" metadata definition object with same name=%(name)s "
" in namespace=%(namespace_name)s."
% {'name': object['name'],
'namespace_name': namespace_name})
LOG.debug(msg)
LOG.debug("Invalid update. It would result in a duplicate "
"metadata definition object with same name=%(name)s "
"in namespace=%(namespace_name)s.",
{'name': object['name'],
'namespace_name': namespace_name})
emsg = (_("Invalid update. It would result in a duplicate"
" metadata definition object with the same"
" name=%(name)s "
@ -1462,12 +1450,11 @@ def metadef_property_create(context, namespace_name, values):
for property in DATA['metadef_properties']:
if (property['name'] == property_name and
property['namespace_id'] == namespace['id']):
msg = ("Can not create metadata definition property. A property"
" with name=%(name)s already exists in"
" namespace=%(namespace_name)s."
% {'name': property_name,
'namespace_name': namespace_name})
LOG.debug(msg)
LOG.debug("Can not create metadata definition property. A property"
" with name=%(name)s already exists in"
" namespace=%(namespace_name)s.",
{'name': property_name,
'namespace_name': namespace_name})
raise exception.MetadefDuplicateProperty(
property_name=property_name,
namespace_name=namespace_name)
@ -1505,13 +1492,12 @@ def metadef_property_update(context, namespace_name, property_id, values):
for db_property in DATA['metadef_properties']:
if (db_property['name'] == values['name'] and
db_property['namespace_id'] == namespace['id']):
msg = ("Invalid update. It would result in a duplicate"
" metadata definition property with the same"
" name=%(name)s"
" in namespace=%(namespace_name)s."
% {'name': property['name'],
'namespace_name': namespace_name})
LOG.debug(msg)
LOG.debug("Invalid update. It would result in a duplicate"
" metadata definition property with the same"
" name=%(name)s"
" in namespace=%(namespace_name)s.",
{'name': property['name'],
'namespace_name': namespace_name})
emsg = (_("Invalid update. It would result in a duplicate"
" metadata definition property with the same"
" name=%(name)s"
@ -1574,10 +1560,9 @@ def metadef_property_get(context, namespace_name, property_name):
property['name'] == property_name):
return property
else:
msg = ("No property found with name=%(name)s in"
" namespace=%(namespace_name)s "
% {'name': property_name, 'namespace_name': namespace_name})
LOG.debug(msg)
LOG.debug("No property found with name=%(name)s in"
" namespace=%(namespace_name)s ",
{'name': property_name, 'namespace_name': namespace_name})
raise exception.MetadefPropertyNotFound(namespace_name=namespace_name,
property_name=property_name)
@ -1641,8 +1626,7 @@ def metadef_resource_type_get(context, resource_type_name):
if resource_type['name'] ==
resource_type_name)
except StopIteration:
msg = "No resource type found with name %s" % resource_type_name
LOG.debug(msg)
LOG.debug("No resource type found with name %s", resource_type_name)
raise exception.MetadefResourceTypeNotFound(
resource_type_name=resource_type_name)
@ -1667,12 +1651,11 @@ def metadef_resource_type_association_create(context, namespace_name,
for association in DATA['metadef_namespace_resource_types']:
if (association['namespace_id'] == namespace['id'] and
association['resource_type'] == resource_type['id']):
msg = ("The metadata definition resource-type association of"
" resource_type=%(resource_type_name)s to"
" namespace=%(namespace_name)s, already exists."
% {'resource_type_name': resource_type_name,
'namespace_name': namespace_name})
LOG.debug(msg)
LOG.debug("The metadata definition resource-type association of"
" resource_type=%(resource_type_name)s to"
" namespace=%(namespace_name)s, already exists.",
{'resource_type_name': resource_type_name,
'namespace_name': namespace_name})
raise exception.MetadefDuplicateResourceTypeAssociation(
resource_type_name=resource_type_name,
namespace_name=namespace_name)
@ -1704,9 +1687,9 @@ def metadef_resource_type_association_get(context, namespace_name,
association['resource_type'] == resource_type['id']):
return association
else:
msg = ("No resource type association found associated with namespace "
"%s and resource type %s" % namespace_name, resource_type_name)
LOG.debug(msg)
LOG.debug("No resource type association found associated with "
"namespace %s and resource type %s", namespace_name,
resource_type_name)
raise exception.MetadefResourceTypeAssociationNotFound(
resource_type_name=resource_type_name,
namespace_name=namespace_name)
@ -1748,10 +1731,9 @@ def metadef_tag_get(context, namespace_name, name):
if tag['namespace_id'] == namespace['id'] and tag['name'] == name:
return tag
else:
msg = ("The metadata definition tag with name=%(name)s"
" was not found in namespace=%(namespace_name)s."
% {'name': name, 'namespace_name': namespace_name})
LOG.debug(msg)
LOG.debug("The metadata definition tag with name=%(name)s"
" was not found in namespace=%(namespace_name)s.",
{'name': name, 'namespace_name': namespace_name})
raise exception.MetadefTagNotFound(name=name,
namespace_name=namespace_name)
@ -1802,10 +1784,9 @@ def metadef_tag_create(context, namespace_name, values):
for tag in DATA['metadef_tags']:
if tag['name'] == tag_name and tag['namespace_id'] == namespace['id']:
msg = ("A metadata definition tag with name=%(name)s"
" in namespace=%(namespace_name)s already exists."
% {'name': tag_name, 'namespace_name': namespace_name})
LOG.debug(msg)
LOG.debug("A metadata definition tag with name=%(name)s"
" in namespace=%(namespace_name)s already exists.",
{'name': tag_name, 'namespace_name': namespace_name})
raise exception.MetadefDuplicateTag(
name=tag_name, namespace_name=namespace_name)
@ -1853,10 +1834,9 @@ def metadef_tag_create_tags(context, namespace_name, tag_list):
'The keys %s are not valid' % str(incorrect_keys))
if tag_name in tag_name_list:
msg = ("A metadata definition tag with name=%(name)s"
" in namespace=%(namespace_name)s already exists."
% {'name': tag_name, 'namespace_name': namespace_name})
LOG.debug(msg)
LOG.debug("A metadata definition tag with name=%(name)s"
" in namespace=%(namespace_name)s already exists.",
{'name': tag_name, 'namespace_name': namespace_name})
raise exception.MetadefDuplicateTag(
name=tag_name, namespace_name=namespace_name)
else:
@ -1886,12 +1866,11 @@ def metadef_tag_update(context, namespace_name, id, values):
for db_tag in DATA['metadef_tags']:
if (db_tag['name'] == values['name'] and
db_tag['namespace_id'] == namespace['id']):
msg = ("Invalid update. It would result in a duplicate"
" metadata definition tag with same name=%(name)s "
" in namespace=%(namespace_name)s."
% {'name': tag['name'],
'namespace_name': namespace_name})
LOG.debug(msg)
LOG.debug("Invalid update. It would result in a duplicate"
" metadata definition tag with same name=%(name)s "
" in namespace=%(namespace_name)s.",
{'name': tag['name'],
'namespace_name': namespace_name})
raise exception.MetadefDuplicateTag(
name=tag['name'], namespace_name=namespace_name)
@ -2130,9 +2109,8 @@ def _is_namespace_visible(context, namespace):
def _check_namespace_visibility(context, namespace, namespace_name):
if not _is_namespace_visible(context, namespace):
msg = ("Forbidding request, metadata definition namespace=%s"
" is not visible." % namespace_name)
LOG.debug(msg)
LOG.debug("Forbidding request, metadata definition namespace=%s "
"is not visible.", namespace_name)
emsg = _("Forbidding request, metadata definition namespace=%s"
" is not visible.") % namespace_name
raise exception.MetadefForbidden(emsg)

View File

@ -1258,9 +1258,8 @@ def _task_info_get(context, task_id, session=None):
try:
task_info_ref = query.one()
except sa_orm.exc.NoResultFound:
msg = ("TaskInfo was not found for task with id %(task_id)s" %
{'task_id': task_id})
LOG.debug(msg)
LOG.debug("TaskInfo was not found for task with id %(task_id)s",
{'task_id': task_id})
task_info_ref = None
return task_info_ref
@ -1423,8 +1422,7 @@ def _task_get(context, task_id, session=None, force_show_deleted=False):
try:
task_ref = query.one()
except sa_orm.exc.NoResultFound:
msg = "No task found with ID %s" % task_id
LOG.debug(msg)
LOG.debug("No task found with ID %s", task_id)
raise exception.TaskNotFound(task_id=task_id)
# Make sure the task is visible

View File

@ -425,7 +425,7 @@ def _do_paginate_query(query, sort_keys=None, sort_dirs=None,
def _do_artifacts_query(context, session, show_level=ga.Showlevel.NONE):
"""Build the query to get all artifacts based on the context"""
LOG.debug("context.is_admin=%(is_admin)s; context.owner=%(owner)s" %
LOG.debug("context.is_admin=%(is_admin)s; context.owner=%(owner)s",
{'is_admin': context.is_admin, 'owner': context.owner})
if show_level == ga.Showlevel.NONE:

View File

@ -56,7 +56,7 @@ def _is_namespace_visible(context, namespace, status=None):
def _select_namespaces_query(context, session):
"""Build the query to get all namespaces based on the context"""
LOG.debug("context.is_admin=%(is_admin)s; context.owner=%(owner)s" %
LOG.debug("context.is_admin=%(is_admin)s; context.owner=%(owner)s",
{'is_admin': context.is_admin, 'owner': context.owner})
# If admin, return everything.
@ -93,9 +93,8 @@ def _get(context, namespace_id, session):
# Make sure they are allowed to view it.
if not _is_namespace_visible(context, namespace_rec.to_dict()):
msg = ("Forbidding request, metadata definition namespace=%s"
" is not visible.") % namespace_rec.namespace
LOG.debug(msg)
LOG.debug("Forbidding request, metadata definition namespace=%s"
" is not visible.", namespace_rec.namespace)
emsg = _("Forbidding request, metadata definition namespace=%s"
" is not visible.") % namespace_rec.namespace
raise exc.MetadefForbidden(emsg)
@ -111,15 +110,13 @@ def _get_by_name(context, name, session):
namespace=name)
namespace_rec = query.one()
except sa_orm.exc.NoResultFound:
msg = "Metadata definition namespace=%s was not found." % name
LOG.debug(msg)
LOG.debug("Metadata definition namespace=%s was not found.", name)
raise exc.MetadefNamespaceNotFound(namespace_name=name)
# Make sure they are allowed to view it.
if not _is_namespace_visible(context, namespace_rec.to_dict()):
msg = ("Forbidding request, metadata definition namespace=%s"
" is not visible." % name)
LOG.debug(msg)
LOG.debug("Forbidding request, metadata definition namespace=%s"
" is not visible.", name)
emsg = _("Forbidding request, metadata definition namespace=%s"
" is not visible.") % name
raise exc.MetadefForbidden(emsg)
@ -229,9 +226,8 @@ def create(context, values, session):
try:
namespace.save(session=session)
except db_exc.DBDuplicateEntry:
msg = ("Can not create the metadata definition namespace."
" Namespace=%s already exists.") % namespace_name
LOG.debug(msg)
LOG.debug("Can not create the metadata definition namespace."
" Namespace=%s already exists.", namespace_name)
raise exc.MetadefDuplicateNamespace(
namespace_name=namespace_name)
@ -248,10 +244,9 @@ def update(context, namespace_id, values, session):
namespace_rec.update(values.copy())
namespace_rec.save(session=session)
except db_exc.DBDuplicateEntry:
msg = ("Invalid update. It would result in a duplicate"
" metadata definition namespace with the same name of %s"
% values['namespace'])
LOG.debug(msg)
LOG.debug("Invalid update. It would result in a duplicate"
" metadata definition namespace with the same name of %s",
values['namespace'])
emsg = (_("Invalid update. It would result in a duplicate"
" metadata definition namespace with the same name of %s")
% values['namespace'])
@ -269,9 +264,8 @@ def delete(context, name, session):
session.flush()
except db_exc.DBError as e:
if isinstance(e.inner_exception, sa_exc.IntegrityError):
msg = ("Metadata definition namespace=%s not deleted."
" Other records still refer to it." % name)
LOG.debug(msg)
LOG.debug("Metadata definition namespace=%s not deleted. "
"Other records still refer to it.", name)
raise exc.MetadefIntegrityError(
record_type='namespace', record_name=name)
else:
@ -298,9 +292,8 @@ def delete_cascade(context, name, session):
session.flush()
except db_exc.DBError as e:
if isinstance(e.inner_exception, sa_exc.IntegrityError):
msg = ("Metadata definition namespace=%s not deleted."
" Other records still refer to it." % name)
LOG.debug(msg)
LOG.debug("Metadata definition namespace=%s not deleted. "
"Other records still refer to it.", name)
raise exc.MetadefIntegrityError(
record_type='namespace', record_name=name)
else:

View File

@ -48,10 +48,9 @@ def _get_by_name(context, namespace_name, name, session):
name=name, namespace_id=namespace['id'])
metadef_object = query.one()
except sa_orm.exc.NoResultFound:
msg = ("The metadata definition object with name=%(name)s"
" was not found in namespace=%(namespace_name)s."
% {'name': name, 'namespace_name': namespace_name})
LOG.debug(msg)
LOG.debug("The metadata definition object with name=%(name)s"
" was not found in namespace=%(namespace_name)s.",
{'name': name, 'namespace_name': namespace_name})
raise exc.MetadefObjectNotFound(object_name=name,
namespace_name=namespace_name)
@ -80,11 +79,10 @@ def create(context, namespace_name, values, session):
try:
md_object.save(session=session)
except db_exc.DBDuplicateEntry:
msg = ("A metadata definition object with name=%(name)s"
" in namespace=%(namespace_name)s already exists."
% {'name': md_object.name,
'namespace_name': namespace_name})
LOG.debug(msg)
LOG.debug("A metadata definition object with name=%(name)s"
" in namespace=%(namespace_name)s already exists.",
{'name': md_object.name,
'namespace_name': namespace_name})
raise exc.MetadefDuplicateObject(
object_name=md_object.name, namespace_name=namespace_name)
@ -108,11 +106,10 @@ def update(context, namespace_name, object_id, values, session):
md_object.update(values.copy())
md_object.save(session=session)
except db_exc.DBDuplicateEntry:
msg = ("Invalid update. It would result in a duplicate"
" metadata definition object with same name=%(name)s"
" in namespace=%(namespace_name)s."
% {'name': md_object.name, 'namespace_name': namespace_name})
LOG.debug(msg)
LOG.debug("Invalid update. It would result in a duplicate"
" metadata definition object with same name=%(name)s"
" in namespace=%(namespace_name)s.",
{'name': md_object.name, 'namespace_name': namespace_name})
emsg = (_("Invalid update. It would result in a duplicate"
" metadata definition object with the same name=%(name)s"
" in namespace=%(namespace_name)s.")

View File

@ -53,10 +53,9 @@ def _get_by_name(context, namespace_name, name, session):
property_rec = query.one()
except sa_orm.exc.NoResultFound:
msg = ("The metadata definition property with name=%(name)s"
" was not found in namespace=%(namespace_name)s."
% {'name': name, 'namespace_name': namespace_name})
LOG.debug(msg)
LOG.debug("The metadata definition property with name=%(name)s"
" was not found in namespace=%(namespace_name)s.",
{'name': name, 'namespace_name': namespace_name})
raise exc.MetadefPropertyNotFound(property_name=name,
namespace_name=namespace_name)
@ -93,12 +92,11 @@ def create(context, namespace_name, values, session):
try:
property_rec.save(session=session)
except db_exc.DBDuplicateEntry:
msg = ("Can not create metadata definition property. A property"
" with name=%(name)s already exists in"
" namespace=%(namespace_name)s."
% {'name': property_rec.name,
'namespace_name': namespace_name})
LOG.debug(msg)
LOG.debug("Can not create metadata definition property. A property"
" with name=%(name)s already exists in"
" namespace=%(namespace_name)s.",
{'name': property_rec.name,
'namespace_name': namespace_name})
raise exc.MetadefDuplicateProperty(
property_name=property_rec.name,
namespace_name=namespace_name)
@ -117,12 +115,11 @@ def update(context, namespace_name, property_id, values, session):
property_rec.update(values.copy())
property_rec.save(session=session)
except db_exc.DBDuplicateEntry:
msg = ("Invalid update. It would result in a duplicate"
" metadata definition property with the same name=%(name)s"
" in namespace=%(namespace_name)s."
% {'name': property_rec.name,
'namespace_name': namespace_name})
LOG.debug(msg)
LOG.debug("Invalid update. It would result in a duplicate"
" metadata definition property with the same name=%(name)s"
" in namespace=%(namespace_name)s.",
{'name': property_rec.name,
'namespace_name': namespace_name})
emsg = (_("Invalid update. It would result in a duplicate"
" metadata definition property with the same name=%(name)s"
" in namespace=%(namespace_name)s.")

View File

@ -32,8 +32,8 @@ def get(context, name, session):
query = session.query(models.MetadefResourceType).filter_by(name=name)
resource_type = query.one()
except sa_orm.exc.NoResultFound:
msg = "No metadata definition resource-type found with name %s" % name
LOG.debug(msg)
LOG.debug("No metadata definition resource-type found with name %s",
name)
raise exc.MetadefResourceTypeNotFound(resource_type_name=name)
return resource_type.to_dict()
@ -61,10 +61,9 @@ def create(context, values, session):
try:
resource_type.save(session=session)
except db_exc.DBDuplicateEntry:
msg = ("Can not create the metadata definition resource-type."
" A resource-type with name=%s already exists."
% resource_type.name)
LOG.debug(msg)
LOG.debug("Can not create the metadata definition resource-type. "
"A resource-type with name=%s already exists.",
resource_type.name)
raise exc.MetadefDuplicateResourceType(
resource_type_name=resource_type.name)
@ -88,9 +87,8 @@ def delete(context, name, session):
db_rec = get(context, name, session)
if db_rec.protected is True:
msg = ("Delete forbidden. Metadata definition resource-type %s is a"
" seeded-system type and can not be deleted.") % name
LOG.debug(msg)
LOG.debug("Delete forbidden. Metadata definition resource-type %s is a"
" seeded-system type and can not be deleted.", name)
raise exc.ProtectedMetadefResourceTypeSystemDelete(
resource_type_name=name)
@ -99,9 +97,8 @@ def delete(context, name, session):
session.flush()
except db_exc.DBError as e:
if isinstance(e.inner_exception, sa_exc.IntegrityError):
msg = ("Could not delete Metadata definition resource-type %s"
". It still has content") % name
LOG.debug(msg)
LOG.debug("Could not delete Metadata definition resource-type %s"
". It still has content", name)
raise exc.MetadefIntegrityError(
record_type='resource-type', record_name=name)
else:

View File

@ -66,12 +66,11 @@ def _get(context, namespace_name, resource_type_name,
namespace_id=namespace_id, resource_type_id=resource_type_id)
db_rec = query.one()
except sa_orm.exc.NoResultFound:
msg = ("The metadata definition resource-type association of"
" resource_type=%(resource_type_name)s to"
" namespace_name=%(namespace_name)s was not found."
% {'resource_type_name': resource_type_name,
'namespace_name': namespace_name})
LOG.debug(msg)
LOG.debug("The metadata definition resource-type association of"
" resource_type=%(resource_type_name)s to"
" namespace_name=%(namespace_name)s was not found.",
{'resource_type_name': resource_type_name,
'namespace_name': namespace_name})
raise exc.MetadefResourceTypeAssociationNotFound(
resource_type_name=resource_type_name,
namespace_name=namespace_name)
@ -91,12 +90,11 @@ def _create_association(
try:
namespace_resource_type_rec.save(session=session)
except db_exc.DBDuplicateEntry:
msg = ("The metadata definition resource-type association of"
" resource_type=%(resource_type_name)s to"
" namespace=%(namespace_name)s, already exists."
% {'resource_type_name': resource_type_name,
'namespace_name': namespace_name})
LOG.debug(msg)
LOG.debug("The metadata definition resource-type association of"
" resource_type=%(resource_type_name)s to"
" namespace=%(namespace_name)s, already exists.",
{'resource_type_name': resource_type_name,
'namespace_name': namespace_name})
raise exc.MetadefDuplicateResourceTypeAssociation(
resource_type_name=resource_type_name,
namespace_name=namespace_name)
@ -172,7 +170,7 @@ def create(context, namespace_name, values, session):
context, resource_type_name, session)
except exc.NotFound:
resource_type = None
LOG.debug("Creating resource-type %s" % resource_type_name)
LOG.debug("Creating resource-type %s", resource_type_name)
if resource_type is None:
resource_type_dict = {'name': resource_type_name, 'protected': False}

View File

@ -47,10 +47,9 @@ def _get_by_name(context, namespace_name, name, session):
name=name, namespace_id=namespace['id']))
metadef_tag = query.one()
except sa_orm.exc.NoResultFound:
msg = ("The metadata tag with name=%(name)s"
" was not found in namespace=%(namespace_name)s."
% {'name': name, 'namespace_name': namespace_name})
LOG.debug(msg)
LOG.debug("The metadata tag with name=%(name)s"
" was not found in namespace=%(namespace_name)s.",
{'name': name, 'namespace_name': namespace_name})
raise exc.MetadefTagNotFound(name=name,
namespace_name=namespace_name)
return metadef_tag
@ -101,11 +100,10 @@ def create(context, namespace_name, values, session):
try:
metadef_tag.save(session=session)
except db_exc.DBDuplicateEntry:
msg = ("A metadata tag name=%(name)s"
" in namespace=%(namespace_name)s already exists."
% {'name': metadef_tag.name,
'namespace_name': namespace_name})
LOG.debug(msg)
LOG.debug("A metadata tag name=%(name)s"
" in namespace=%(namespace_name)s already exists.",
{'name': metadef_tag.name,
'namespace_name': namespace_name})
raise exc.MetadefDuplicateTag(
name=metadef_tag.name, namespace_name=namespace_name)
@ -133,11 +131,10 @@ def create_tags(context, namespace_name, tag_list, session):
metadef_tag.save(session=session)
metadef_tags_list.append(metadef_tag.to_dict())
except db_exc.DBDuplicateEntry:
msg = ("A metadata tag name=%(name)s"
" in namespace=%(namespace_name)s already exists."
% {'name': metadef_tag.name,
'namespace_name': namespace_name})
LOG.debug(msg)
LOG.debug("A metadata tag name=%(name)s"
" in namespace=%(namespace_name)s already exists.",
{'name': metadef_tag.name,
'namespace_name': namespace_name})
raise exc.MetadefDuplicateTag(
name=metadef_tag.name, namespace_name=namespace_name)
@ -160,12 +157,11 @@ def update(context, namespace_name, id, values, session):
metadata_tag.update(values.copy())
metadata_tag.save(session=session)
except db_exc.DBDuplicateEntry:
msg = ("Invalid update. It would result in a duplicate"
" metadata tag with same name=%(name)s"
" in namespace=%(namespace_name)s."
% {'name': values['name'],
'namespace_name': namespace_name})
LOG.debug(msg)
LOG.debug("Invalid update. It would result in a duplicate"
" metadata tag with same name=%(name)s"
" in namespace=%(namespace_name)s.",
{'name': values['name'],
'namespace_name': namespace_name})
raise exc.MetadefDuplicateTag(
name=values['name'], namespace_name=namespace_name)

View File

@ -254,9 +254,8 @@ class Image(object):
# Noop if already deactive
pass
else:
msg = ("Not allowed to deactivate image in status '%s'"
% self.status)
LOG.debug(msg)
LOG.debug("Not allowed to deactivate image in status '%s'",
self.status)
msg = (_("Not allowed to deactivate image in status '%s'")
% self.status)
raise exception.Forbidden(message=msg)
@ -268,9 +267,8 @@ class Image(object):
# Noop if already active
pass
else:
msg = ("Not allowed to reactivate image in status '%s'"
% self.status)
LOG.debug(msg)
LOG.debug("Not allowed to reactivate image in status '%s'",
self.status)
msg = (_("Not allowed to reactivate image in status '%s'")
% self.status)
raise exception.Forbidden(message=msg)
@ -507,7 +505,7 @@ class TaskExecutorFactory(object):
executor_cls = ('glance.async.%s_executor.'
'TaskExecutor' % task_executor)
LOG.debug("Loading %s executor" % task_executor)
LOG.debug("Loading %s executor", task_executor)
executor = importutils.import_class(executor_cls)
return executor(context,
self.task_repo,

View File

@ -283,7 +283,7 @@ class Driver(base.Driver):
# Make sure that we "pop" the image from the queue...
if self.is_queued(image_id):
LOG.debug("Removing image '%s' from queue after "
"caching it." % image_id)
"caching it.", image_id)
os.unlink(self.get_image_filepath(image_id, 'queue'))
def rollback(e):
@ -292,7 +292,7 @@ class Driver(base.Driver):
invalid_path = self.get_image_filepath(image_id, 'invalid')
LOG.debug("Fetch of cache file failed (%(e)s), rolling back by "
"moving '%(incomplete_path)s' to "
"'%(invalid_path)s'" %
"'%(invalid_path)s'",
{'e': encodeutils.exception_to_unicode(e),
'incomplete_path': incomplete_path,
'invalid_path': invalid_path})
@ -437,7 +437,7 @@ def get_all_regular_files(basepath):
def delete_cached_file(path):
if os.path.exists(path):
LOG.debug("Deleting image cache file '%s'" % path)
LOG.debug("Deleting image cache file '%s'", path)
os.unlink(path)
else:
LOG.warn(_LW("Cached image file '%s' doesn't exist, unable to"

View File

@ -341,8 +341,7 @@ class Controller(object):
"""Return data about the given image id."""
try:
image = self.db_api.image_get(req.context, id)
msg = "Successfully retrieved image %(id)s" % {'id': id}
LOG.debug(msg)
LOG.debug("Successfully retrieved image %(id)s", {'id': id})
except exception.ImageNotFound:
LOG.info(_LI("Image %(id)s not found"), {'id': id})
raise exc.HTTPNotFound()

View File

@ -121,11 +121,10 @@ class RegistryClient(BaseClient):
**kwargs)
status = res.status
request_id = res.getheader('x-openstack-request-id')
msg = ("Registry request %(method)s %(action)s HTTP %(status)s"
" request id %(request_id)s" %
{'method': method, 'action': action,
'status': status, 'request_id': request_id})
LOG.debug(msg)
LOG.debug("Registry request %(method)s %(action)s HTTP %(status)s"
" request id %(request_id)s",
{'method': method, 'action': action,
'status': status, 'request_id': request_id})
except Exception as exc:
with excutils.save_and_reraise_exception():

View File

@ -235,7 +235,7 @@ class Daemon(object):
LOG.debug("Running application")
self.daemon_pool.spawn_n(application.run, self.event)
eventlet.spawn_after(self.wakeup_time, self._run, application)
LOG.debug("Next run scheduled in %s seconds" % self.wakeup_time)
LOG.debug("Next run scheduled in %s seconds", self.wakeup_time)
class Scrubber(object):
@ -322,7 +322,7 @@ class Scrubber(object):
if CONF.metadata_encryption_key:
uri = crypt.urlsafe_decrypt(CONF.metadata_encryption_key, uri)
try:
LOG.debug("Scrubbing image %s from a location." % image_id)
LOG.debug("Scrubbing image %s from a location.", image_id)
try:
self.store_api.delete_from_backend(uri, self.admin_context)
except store_exceptions.NotFound: