Raising glance logging levels

This change complements glance change #106776 by raising some logging
levels and fixing some of the translations of logging.

Related to bp refactoring-glance-logging
Closes-Bug: #1336955

Change-Id: Ib547f4603025ebe4f6c055779032ab4064784490
This commit is contained in:
Erno Kuvaja
2014-08-25 12:38:10 +00:00
parent 5b43c49a69
commit 4f46fb67f2
18 changed files with 142 additions and 126 deletions

View File

@@ -163,7 +163,7 @@ def check_quota(context, image_size, db_api, image_id=None):
# exception is when there is no room left at all, thus we know
# it will not fit
if remaining <= 0:
LOG.info(_LI("User %(user)s attempted to upload an image of"
LOG.warn(_LW("User %(user)s attempted to upload an image of"
" unknown size that will exceeed the quota."
" %(remaining)d bytes remaining.")
% {'user': user, 'remaining': remaining})
@@ -172,7 +172,7 @@ def check_quota(context, image_size, db_api, image_id=None):
return
if image_size > remaining:
LOG.info(_LI("User %(user)s attempted to upload an image of size"
LOG.warn(_LW("User %(user)s attempted to upload an image of size"
" %(size)d that will exceeed the quota. %(remaining)d"
" bytes remaining.")
% {'user': user, 'size': image_size, 'remaining': remaining})

View File

@@ -23,12 +23,15 @@ from oslo.config import cfg
from glance.api import versions
from glance.common import wsgi
from glance import i18n
import glance.openstack.common.log as logging
CONF = cfg.CONF
LOG = logging.getLogger(__name__)
_LW = i18n._LW
class VersionNegotiationFilter(wsgi.Middleware):
@@ -61,7 +64,7 @@ class VersionNegotiationFilter(wsgi.Middleware):
try:
version = self._match_version_string(req_version)
except ValueError:
LOG.debug("Unknown version. Returning version choices.")
LOG.warn(_LW("Unknown version. Returning version choices."))
return self.versions_app
req.environ['api.version'] = version

View File

@@ -24,11 +24,15 @@ from oslo.serialization import jsonutils
from glance.common import exception
import glance.domain.proxy
from glance import i18n
import glance.openstack.common.log as logging
from glance.openstack.common import policy
LOG = logging.getLogger(__name__)
_LI = i18n._LI
_LW = i18n._LW
policy_opts = [
cfg.StrOpt('policy_file', default='policy.json',
help=_('The location of the policy file.')),
@@ -93,7 +97,7 @@ class Enforcer(object):
if policy_file:
return policy_file
else:
LOG.warn(_('Unable to find policy file'))
LOG.warn(_LW('Unable to find policy file'))
return None
def _read_policy_file(self):
@@ -103,7 +107,7 @@ class Enforcer(object):
"""
mtime = os.path.getmtime(self.policy_path)
if not self.policy_file_contents or mtime != self.policy_file_mtime:
LOG.debug("Loading policy from %s" % self.policy_path)
LOG.info(_LI("Loading policy from %s") % self.policy_path)
with open(self.policy_path) as fap:
raw_contents = fap.read()
rules_dict = jsonutils.loads(raw_contents)

View File

@@ -177,7 +177,7 @@ class Controller(controller.BaseController):
"image properties. Attempted: %(num)s, Maximum: "
"%(quota)s") % {'num': len(props),
'quota': CONF.image_property_quota})
LOG.info(msg)
LOG.warn(msg)
raise HTTPRequestEntityTooLarge(explanation=msg,
request=req,
content_type="text/plain")
@@ -195,8 +195,8 @@ class Controller(controller.BaseController):
for key in create_props:
if (self.prop_enforcer.check_property_rules(
key, 'create', req.context) is False):
msg = "Property '%s' is protected" % key
LOG.debug(msg)
msg = _("Property '%s' is protected") % key
LOG.warn(msg)
raise HTTPForbidden(explanation=msg,
request=req,
content_type="text/plain")
@@ -239,8 +239,8 @@ class Controller(controller.BaseController):
key, 'update', req.context) is False and
image_meta['properties'][key] !=
orig_meta['properties'][key]) or not has_read):
msg = "Property '%s' is protected" % key
LOG.debug(msg)
msg = _("Property '%s' is protected") % key
LOG.warn(msg)
raise HTTPForbidden(explanation=msg,
request=req,
content_type="text/plain")
@@ -273,8 +273,8 @@ class Controller(controller.BaseController):
'properties'][key]
elif (self.prop_enforcer.check_property_rules(
key, 'delete', req.context) is False):
msg = "Property '%s' is protected" % key
LOG.debug(msg)
msg = _("Property '%s' is protected") % key
LOG.warn(msg)
raise HTTPForbidden(explanation=msg,
request=req,
content_type="text/plain")
@@ -564,8 +564,7 @@ class Controller(controller.BaseController):
except exception.Invalid as e:
msg = (_("Failed to reserve image. Got error: %s") %
utils.exception_to_str(e))
for line in msg.split('\n'):
LOG.debug(line)
LOG.exception(msg)
raise HTTPBadRequest(explanation=msg,
request=req,
content_type="text/plain")
@@ -762,12 +761,12 @@ class Controller(controller.BaseController):
# size provided by the client will be used as-is.
if (image_size_store and
image_size_store != image_size_meta):
msg = ("Provided image size must match the stored "
"image size. (provided size: %(ps)d, "
"stored size: %(ss)d)" % {
"ps": image_size_meta,
"ss": image_size_store})
LOG.debug(msg)
msg = (_("Provided image size must match the stored"
" image size. (provided size: %(ps)d, "
"stored size: %(ss)d)") %
{"ps": image_size_meta,
"ss": image_size_store})
LOG.warn(msg)
raise HTTPConflict(explanation=msg,
request=req,
content_type="text/plain")
@@ -986,23 +985,23 @@ class Controller(controller.BaseController):
request=req,
content_type="text/plain")
except exception.NotFound as e:
msg = (_("Failed to find image to update: %s") %
utils.exception_to_str(e))
for line in msg.split('\n'):
LOG.info(line)
raise HTTPNotFound(explanation=msg,
msg = _("Failed to find image to update: %s")
lmsg = "Failed to find image to update: %s"
e_str = utils.exception_to_str(e)
LOG.debug(lmsg % e_str)
raise HTTPNotFound(explanation=msg % e_str,
request=req,
content_type="text/plain")
except exception.Forbidden as e:
msg = (_("Forbidden to update image: %s") %
utils.exception_to_str(e))
for line in msg.split('\n'):
LOG.info(line)
raise HTTPForbidden(explanation=msg,
msg = _("Forbidden to update image: %s")
lmsg = "Forbidden to update image: %s"
e_str = utils.exception_to_str(e)
LOG.debug(lmsg % e_str)
raise HTTPForbidden(explanation=msg % e_str,
request=req,
content_type="text/plain")
except (exception.Conflict, exception.Duplicate) as e:
LOG.info(utils.exception_to_str(e))
LOG.warn(utils.exception_to_str(e))
raise HTTPConflict(body='Image operation conflicts',
request=req,
content_type='text/plain')
@@ -1083,24 +1082,21 @@ class Controller(controller.BaseController):
except exception.NotFound as e:
msg = (_("Failed to find image to delete: %s") %
utils.exception_to_str(e))
for line in msg.split('\n'):
LOG.info(line)
LOG.warn(msg)
raise HTTPNotFound(explanation=msg,
request=req,
content_type="text/plain")
except exception.Forbidden as e:
msg = (_("Forbidden to delete image: %s") %
utils.exception_to_str(e))
for line in msg.split('\n'):
LOG.info(line)
LOG.warn(msg)
raise HTTPForbidden(explanation=msg,
request=req,
content_type="text/plain")
except exception.InUseByStore as e:
msg = (_LI("Image %s could not be deleted because it is in use: "
"%s") % (id, utils.exception_to_str(e))) # noqa
for line in msg.split('\n'):
LOG.info(line)
msg = (_("Image %(id)s could not be deleted because it is in use: "
"%(exc)s") % {"id": id, "exc": utils.exception_to_str(e)})
LOG.warn(msg)
raise HTTPConflict(explanation=msg,
request=req,
content_type="text/plain")

View File

@@ -30,6 +30,7 @@ CONF = cfg.CONF
LOG = logging.getLogger(__name__)
_LE = gettextutils._LE
_LI = gettextutils._LI
_LW = gettextutils._LW
def initiate_deletion(req, location_data, id):
@@ -202,7 +203,8 @@ def upload_data_to_store(req, image_meta, image_data, store, notifier):
content_type="text/plain")
except store_api.StorageFull as e:
msg = _("Image storage media is full: %s") % utils.exception_to_str(e)
msg = (_("Image storage media is full: %s") %
utils.exception_to_str(e))
LOG.error(msg)
safe_kill(req, image_id, 'saving')
notifier.error('image.upload', msg)
@@ -223,7 +225,7 @@ def upload_data_to_store(req, image_meta, image_data, store, notifier):
except exception.ImageSizeLimitExceeded as e:
msg = (_("Denying attempt to upload image larger than %d bytes.")
% CONF.image_size_cap)
LOG.info(msg)
LOG.warn(msg)
safe_kill(req, image_id, 'saving')
notifier.error('image.upload', msg)
raise webob.exc.HTTPRequestEntityTooLarge(explanation=msg,
@@ -233,7 +235,7 @@ def upload_data_to_store(req, image_meta, image_data, store, notifier):
except exception.StorageQuotaFull as e:
msg = (_("Denying attempt to upload image because it exceeds the ."
"quota: %s") % utils.exception_to_str(e))
LOG.info(msg)
LOG.warn(msg)
safe_kill(req, image_id, 'saving')
notifier.error('image.upload', msg)
raise webob.exc.HTTPRequestEntityTooLarge(explanation=msg,
@@ -252,8 +254,8 @@ def upload_data_to_store(req, image_meta, image_data, store, notifier):
safe_kill(req, image_id, 'saving')
except (ValueError, IOError) as e:
msg = "Client disconnected before sending all data to backend"
LOG.debug(msg)
msg = _("Client disconnected before sending all data to backend")
LOG.warn(msg)
safe_kill(req, image_id, 'saving')
raise webob.exc.HTTPBadRequest(explanation=msg,
content_type="text/plain",

View File

@@ -74,8 +74,9 @@ class ImageDataController(object):
image_repo.save(image)
except exception.NotFound as e:
msg = (_("Image %(id)s could not be found after upload."
"The image may have been deleted during the upload: "
"%(error)s Cleaning up the chunks uploaded") %
"The image may have been deleted during the "
"upload: %(error)s Cleaning up the chunks "
"uploaded") %
{'id': image_id,
'error': utils.exception_to_str(e)})
LOG.warn(msg)
@@ -106,7 +107,7 @@ class ImageDataController(object):
except exception.InvalidImageStatusTransition as e:
msg = utils.exception_to_str(e)
LOG.debug(msg)
LOG.exception(msg)
raise webob.exc.HTTPConflict(explanation=e.msg, request=req)
except exception.Forbidden as e:

View File

@@ -36,7 +36,6 @@ import glance.openstack.common.log as logging
import glance.schema
LOG = logging.getLogger(__name__)
_LI = gettextutils._LI
_LW = gettextutils._LW
CONF = cfg.CONF
@@ -70,7 +69,7 @@ class ImagesController(object):
except exception.InvalidParameterValue as e:
raise webob.exc.HTTPBadRequest(explanation=e.msg)
except exception.LimitExceeded as e:
LOG.info(utils.exception_to_str(e))
LOG.warn(utils.exception_to_str(e))
raise webob.exc.HTTPRequestEntityTooLarge(
explanation=e.msg, request=req, content_type='text/plain')
except exception.Duplicate as dupex:
@@ -143,13 +142,13 @@ class ImagesController(object):
except exception.InvalidParameterValue as e:
raise webob.exc.HTTPBadRequest(explanation=e.msg)
except exception.StorageQuotaFull as e:
msg = (_LI("Denying attempt to upload image because it exceeds the"
" .quota: %s") % utils.exception_to_str(e))
LOG.info(msg)
msg = (_("Denying attempt to upload image because it exceeds the"
" .quota: %s") % utils.exception_to_str(e))
LOG.warn(msg)
raise webob.exc.HTTPRequestEntityTooLarge(
explanation=msg, request=req, content_type='text/plain')
except exception.LimitExceeded as e:
LOG.info(utils.exception_to_str(e))
LOG.exception(utils.exception_to_str(e))
raise webob.exc.HTTPRequestEntityTooLarge(
explanation=e.msg, request=req, content_type='text/plain')
@@ -215,12 +214,14 @@ class ImagesController(object):
except exception.NotFound as e:
msg = (_("Failed to find image %(image_id)s to delete") %
{'image_id': image_id})
LOG.info(msg)
LOG.warn(msg)
raise webob.exc.HTTPNotFound(explanation=msg)
except exception.InUseByStore as e:
msg = (_LI("Image %s could not be deleted "
"because it is in use: %s") % (image_id, e.msg)) # noqa
LOG.info(msg)
msg = (_("Image %(id)s could not be deleted "
"because it is in use: %(exc)s") %
{"id": image_id,
"exc": e.msg})
LOG.warn(msg)
raise webob.exc.HTTPConflict(explanation=msg)
def _get_locations_op_pos(self, path_pos, max_pos, allow_max):

View File

@@ -122,8 +122,8 @@ class ResourceTypeController(object):
except exception.Forbidden as e:
raise webob.exc.HTTPForbidden(explanation=e.msg)
except exception.NotFound as e:
msg = (_LE("Failed to find resource type %(resourcetype)s to "
"delete") % {'resourcetype': resource_type})
msg = (_("Failed to find resource type %(resourcetype)s to "
"delete") % {'resourcetype': resource_type})
LOG.error(msg)
raise webob.exc.HTTPNotFound(explanation=msg)
except Exception as e:

View File

@@ -36,7 +36,7 @@ import glance.openstack.common.log as logging
import glance.schema
LOG = logging.getLogger(__name__)
_LI = gettextutils._LI
_LW = gettextutils._LW
CONF = cfg.CONF
CONF.import_opt('task_time_to_live', 'glance.common.config', group='task')
@@ -68,9 +68,9 @@ class TasksController(object):
task_executor = executor_factory.new_task_executor(req.context)
new_task.run(task_executor)
except exception.Forbidden as e:
msg = (_LI("Forbidden to create task. Reason: %(reason)s")
msg = (_LW("Forbidden to create task. Reason: %(reason)s")
% {'reason': utils.exception_to_str(e)})
LOG.info(msg)
LOG.warn(msg)
raise webob.exc.HTTPForbidden(explanation=e.msg)
return new_task
@@ -93,10 +93,10 @@ class TasksController(object):
result['next_marker'] = tasks[-1].task_id
except (exception.NotFound, exception.InvalidSortKey,
exception.InvalidFilterRangeValue) as e:
LOG.info(utils.exception_to_str(e))
LOG.warn(utils.exception_to_str(e))
raise webob.exc.HTTPBadRequest(explanation=e.msg)
except exception.Forbidden as e:
LOG.info(utils.exception_to_str(e))
LOG.warn(utils.exception_to_str(e))
raise webob.exc.HTTPForbidden(explanation=e.msg)
result['tasks'] = tasks
return result
@@ -106,15 +106,15 @@ class TasksController(object):
task_repo = self.gateway.get_task_repo(req.context)
task = task_repo.get(task_id)
except exception.NotFound as e:
msg = (_LI("Failed to find task %(task_id)s. Reason: %(reason)s") %
msg = (_LW("Failed to find task %(task_id)s. Reason: %(reason)s") %
{'task_id': task_id, 'reason': utils.exception_to_str(e)})
LOG.info(msg)
LOG.warn(msg)
raise webob.exc.HTTPNotFound(explanation=e.msg)
except exception.Forbidden as e:
msg = (_LI("Forbidden to get task %(task_id)s. Reason:"
msg = (_LW("Forbidden to get task %(task_id)s. Reason:"
" %(reason)s") %
{'task_id': task_id, 'reason': utils.exception_to_str(e)})
LOG.info(msg)
LOG.warn(msg)
raise webob.exc.HTTPForbidden(explanation=e.msg)
return task

View File

@@ -35,6 +35,7 @@ from glance.openstack.common import log
LOG = log.getLogger(__name__)
_LI = gettextutils._LI
_LE = gettextutils._LE
_LW = gettextutils._LW
# If ../glance/__init__.py exists, add ../ to Python search path, so that
# it will override what happens to be installed in /usr/(local/)lib/python...
@@ -557,7 +558,7 @@ def replication_compare(options, args):
for key in image:
if image[key] != headers.get(key, None):
LOG.info(_LI('%(image_id)s: field %(key)s differs '
LOG.warn(_LW('%(image_id)s: field %(key)s differs '
'(source is %(master_value)s, destination '
'is %(slave_value)s)')
% {'image_id': image['id'],
@@ -570,7 +571,7 @@ def replication_compare(options, args):
% {'image_id': image['id']})
elif image['status'] == 'active':
LOG.info(_LI('Image %s entirely missing from the destination')
LOG.warn(_LW('Image %s entirely missing from the destination')
% image['id'])
differences[image['id']] = 'missing'

View File

@@ -22,10 +22,13 @@ from oslo.utils import timeutils
import six
from glance.common import exception
from glance import i18n
import glance.openstack.common.log as logging
LOG = logging.getLogger(__name__)
_LI = i18n._LI
_LW = i18n._LW
DATA = {
'images': {},
@@ -47,12 +50,13 @@ INDEX = 0
def log_call(func):
@functools.wraps(func)
def wrapped(*args, **kwargs):
LOG.info(_('Calling %(funcname)s: args=%(args)s, kwargs=%(kwargs)s') %
LOG.info(_LI('Calling %(funcname)s: args=%(args)s, '
'kwargs=%(kwargs)s') %
{"funcname": func.__name__,
"args": args,
"kwargs": kwargs})
output = func(*args, **kwargs)
LOG.info(_('Returning %(funcname)s: %(output)s') %
LOG.info(_LI('Returning %(funcname)s: %(output)s') %
{"funcname": func.__name__,
"output": output})
return output
@@ -341,15 +345,15 @@ def _image_get(context, image_id, force_show_deleted=False, status=None):
try:
image = DATA['images'][image_id]
except KeyError:
LOG.info(_('Could not find image %s') % image_id)
LOG.warn(_LW('Could not find image %s') % image_id)
raise exception.NotFound()
if image['deleted'] and not (force_show_deleted or context.show_deleted):
LOG.info(_('Unable to get deleted image'))
LOG.warn(_LW('Unable to get deleted image'))
raise exception.NotFound()
if not is_image_visible(context, image):
LOG.info(_('Unable to get unowned image'))
LOG.warn(_LW('Unable to get unowned image'))
raise exception.Forbidden("Image not visible to you")
return image
@@ -858,18 +862,19 @@ def _task_get(context, task_id, force_show_deleted=False):
try:
task = DATA['tasks'][task_id]
except KeyError:
msg = _('Could not find task %s') % task_id
LOG.info(msg)
msg = _LW('Could not find task %s') % task_id
LOG.warn(msg)
raise exception.TaskNotFound(task_id=task_id)
if task['deleted'] and not (force_show_deleted or context.show_deleted):
msg = _('Unable to get deleted task %s') % task_id
LOG.info(msg)
msg = _LW('Unable to get deleted task %s') % task_id
LOG.warn(msg)
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)
msg = _("Forbidding request, task %s is not visible") % task_id
raise exception.Forbidden(msg)
task_info = _task_info_get(task_id)
@@ -1024,8 +1029,8 @@ def _task_info_get(task_id):
try:
task_info = DATA['task_info'][task_id]
except KeyError:
msg = _('Could not find task info %s') % task_id
LOG.info(msg)
msg = _LW('Could not find task info %s') % task_id
LOG.warn(msg)
raise exception.TaskNotFound(task_id=task_id)
return task_info

View File

@@ -108,7 +108,7 @@ def clear_db_env():
def _check_mutate_authorization(context, image_ref):
if not is_image_mutable(context, image_ref):
LOG.info(_LI("Attempted to modify image user did not own."))
LOG.warn(_LW("Attempted to modify image user did not own."))
msg = _("You do not own this image")
if image_ref.is_public:
exc_class = exception.ForbiddenPublicImage

View File

@@ -329,12 +329,12 @@ class Driver(base.Driver):
if os.path.exists(incomplete_path):
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'",
{'e': e,
'incomplete_path': incomplete_path,
'invalid_path': invalid_path})
LOG.warn(_LW("Fetch of cache file failed (%(e)s), rolling "
"back by moving '%(incomplete_path)s' to "
"'%(invalid_path)s'") %
{'e': e,
'incomplete_path': incomplete_path,
'invalid_path': invalid_path})
os.rename(incomplete_path, invalid_path)
db.execute("""DELETE FROM cached_images

View File

@@ -33,6 +33,7 @@ import glance.openstack.common.log as logging
LOG = logging.getLogger(__name__)
_LE = gettextutils._LE
_LI = gettextutils._LI
_LW = gettextutils._LW
CONF = cfg.CONF
@@ -121,12 +122,12 @@ class Controller(object):
return self.db_api.image_get_all(context, filters=filters,
**params)
except exception.NotFound:
LOG.info(_LI("Invalid marker. Image %(id)s could not be "
LOG.warn(_LW("Invalid marker. Image %(id)s could not be "
"found.") % {'id': params.get('marker')})
msg = _("Invalid marker. Image could not be found.")
raise exc.HTTPBadRequest(explanation=msg)
except exception.Forbidden:
LOG.info(_LI("Access denied to image %(id)s but returning "
LOG.warn(_LW("Access denied to image %(id)s but returning "
"'not found'") % {'id': params.get('marker')})
msg = _("Invalid marker. Image could not be found.")
raise exc.HTTPBadRequest(explanation=msg)

View File

@@ -25,6 +25,7 @@ import glance.openstack.common.log as logging
LOG = logging.getLogger(__name__)
_LI = gettextutils._LI
_LW = gettextutils._LW
class Controller(object):
@@ -65,15 +66,15 @@ class Controller(object):
try:
self.db_api.image_get(req.context, image_id)
except exception.NotFound:
msg = _LI("Image %(id)s not found") % {'id': image_id}
LOG.info(msg)
msg = _("Image %(id)s not found") % {'id': image_id}
LOG.warn(msg)
raise webob.exc.HTTPNotFound(msg)
except exception.Forbidden:
# If it's private and doesn't belong to them, don't let on
# that it exists
msg = _LI("Access denied to image %(id)s but returning"
msg = _LW("Access denied to image %(id)s but returning"
" 'not found'") % {'id': image_id}
LOG.info(msg)
LOG.warn(msg)
raise webob.exc.HTTPNotFound()
members = self.db_api.image_member_find(req.context, image_id=image_id)
@@ -101,21 +102,21 @@ class Controller(object):
image = self.db_api.image_get(req.context, image_id)
except exception.NotFound:
msg = _("Image %(id)s not found") % {'id': image_id}
LOG.info(msg)
LOG.warn(msg)
raise webob.exc.HTTPNotFound(msg)
except exception.Forbidden:
# If it's private and doesn't belong to them, don't let on
# that it exists
msg = _LI("Access denied to image %(id)s but returning"
msg = _LW("Access denied to image %(id)s but returning"
" 'not found'") % {'id': image_id}
LOG.info(msg)
LOG.warn(msg)
raise webob.exc.HTTPNotFound()
# Can they manipulate the membership?
if not self.is_image_sharable(req.context, image):
msg = (_LI("User lacks permission to share image %(id)s") %
msg = (_LW("User lacks permission to share image %(id)s") %
{'id': image_id})
LOG.info(msg)
LOG.warn(msg)
msg = _("No permission to share that image")
raise webob.exc.HTTPForbidden(msg)
@@ -124,9 +125,9 @@ class Controller(object):
memb_list = body['memberships']
except Exception as e:
# Malformed entity...
msg = _LI("Invalid membership association specified for "
msg = _LW("Invalid membership association specified for "
"image %(id)s") % {'id': image_id}
LOG.info(msg)
LOG.warn(msg)
msg = (_("Invalid membership association: %s") %
utils.exception_to_str(e))
raise webob.exc.HTTPBadRequest(explanation=msg)
@@ -141,9 +142,9 @@ class Controller(object):
can_share=None)
except Exception as e:
# Malformed entity...
msg = _LI("Invalid membership association specified for "
msg = _LW("Invalid membership association specified for "
"image %(id)s") % {'id': image_id}
LOG.info(msg)
LOG.warn(msg)
msg = (_("Invalid membership association: %s") %
utils.exception_to_str(e))
raise webob.exc.HTTPBadRequest(explanation=msg)
@@ -218,22 +219,22 @@ class Controller(object):
try:
image = self.db_api.image_get(req.context, image_id)
except exception.NotFound:
msg = _LI("Image %(id)s not found") % {'id': image_id}
LOG.info(msg)
msg = _("Image %(id)s not found") % {'id': image_id}
LOG.warn(msg)
raise webob.exc.HTTPNotFound(msg)
except exception.Forbidden:
# If it's private and doesn't belong to them, don't let on
# that it exists
msg = _LI("Access denied to image %(id)s but returning"
msg = _LW("Access denied to image %(id)s but returning"
" 'not found'") % {'id': image_id}
LOG.info(msg)
LOG.warn(msg)
raise webob.exc.HTTPNotFound()
# Can they manipulate the membership?
if not self.is_image_sharable(req.context, image):
msg = (_LI("User lacks permission to share image %(id)s") %
msg = (_LW("User lacks permission to share image %(id)s") %
{'id': image_id})
LOG.info(msg)
LOG.warn(msg)
msg = _("No permission to share that image")
raise webob.exc.HTTPForbidden(msg)
@@ -244,9 +245,9 @@ class Controller(object):
can_share = bool(body['member']['can_share'])
except Exception as e:
# Malformed entity...
msg = _LI("Invalid membership association specified for "
msg = _LW("Invalid membership association specified for "
"image %(id)s") % {'id': image_id}
LOG.info(msg)
LOG.warn(msg)
msg = (_("Invalid membership association: %s") %
utils.exception_to_str(e))
raise webob.exc.HTTPBadRequest(explanation=msg)
@@ -282,22 +283,22 @@ class Controller(object):
try:
image = self.db_api.image_get(req.context, image_id)
except exception.NotFound:
msg = _LI("Image %(id)s not found") % {'id': image_id}
LOG.info(msg)
msg = _("Image %(id)s not found") % {'id': image_id}
LOG.warn(msg)
raise webob.exc.HTTPNotFound(msg)
except exception.Forbidden:
# If it's private and doesn't belong to them, don't let on
# that it exists
msg = _LI("Access denied to image %(id)s but returning"
msg = _LW("Access denied to image %(id)s but returning"
" 'not found'") % {'id': image_id}
LOG.info(msg)
LOG.warn(msg)
raise webob.exc.HTTPNotFound()
# Can they manipulate the membership?
if not self.is_image_sharable(req.context, image):
msg = (_LI("User lacks permission to share image %(id)s") %
msg = (_LW("User lacks permission to share image %(id)s") %
{'id': image_id})
LOG.info(msg)
LOG.warn(msg)
msg = _("No permission to share that image")
raise webob.exc.HTTPForbidden(msg)
@@ -334,8 +335,8 @@ class Controller(object):
try:
members = self.db_api.image_member_find(req.context, member=id)
except exception.NotFound:
msg = _LI("Member %(id)s not found") % {'id': id}
LOG.info(msg)
msg = _LW("Member %(id)s not found") % {'id': id}
LOG.warn(msg)
msg = _("Membership could not be found.")
raise webob.exc.HTTPBadRequest(explanation=msg)

View File

@@ -28,6 +28,7 @@ import glance.openstack.common.log as logging
from glance.registry.api.v1 import images
LOG = logging.getLogger(__name__)
_LE = gettextutils._LE
_LI = gettextutils._LI
@@ -125,10 +126,10 @@ class RegistryClient(BaseClient):
except Exception as exc:
with excutils.save_and_reraise_exception():
exc_name = exc.__class__.__name__
LOG.info(_LI("Registry client request %(method)s %(action)s "
"raised %(exc_name)s"),
{'method': method, 'action': action,
'exc_name': exc_name})
LOG.exception(_LE("Registry client request %(method)s "
"%(action)s raised %(exc_name)s"),
{'method': method, 'action': action,
'exc_name': exc_name})
return res
def get_images_detailed(self, **kwargs):

View File

@@ -254,7 +254,7 @@ class ScrubFileQueue(ScrubQueue):
:retval a list of image id, location id and uri tuple from scrub queue
"""
if not os.path.exists(self.scrubber_datadir):
LOG.info(_LI("%s directory does not exist.") %
LOG.warn(_LW("%s directory does not exist.") %
self.scrubber_datadir)
return []

View File

@@ -125,8 +125,8 @@ class ResourceTypeController(object):
except exception.Forbidden as e:
raise webob.exc.HTTPForbidden(explanation=e.msg)
except exception.NotFound as e:
msg = (_LE("Failed to find resource type %(resourcetype)s to "
"delete") % {'resourcetype': resource_type})
msg = (_("Failed to find resource type %(resourcetype)s to "
"delete") % {'resourcetype': resource_type})
LOG.error(msg)
raise webob.exc.HTTPNotFound(explanation=msg)
except Exception as e: