Merge "Refactoring Glance logging lowering levels"
This commit is contained in:
commit
44e607df7c
|
@ -19,10 +19,14 @@ from oslo.config import cfg
|
|||
|
||||
from glance.common import exception
|
||||
from glance.openstack.common import excutils
|
||||
from glance.openstack.common import gettextutils
|
||||
from glance.openstack.common import log as logging
|
||||
from glance.openstack.common import units
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
_LE = gettextutils._LE
|
||||
_LI = gettextutils._LI
|
||||
_LW = gettextutils._LW
|
||||
CONF = cfg.CONF
|
||||
|
||||
|
||||
|
@ -46,16 +50,16 @@ def size_checked_iter(response, image_meta, expected_size, image_iter,
|
|||
bytes_written += len(chunk)
|
||||
except Exception as err:
|
||||
with excutils.save_and_reraise_exception():
|
||||
msg = (_("An error occurred reading from backend storage for "
|
||||
"image %(image_id)s: %(err)s") % {'image_id': image_id,
|
||||
'err': err})
|
||||
msg = (_LE("An error occurred reading from backend storage for "
|
||||
"image %(image_id)s: %(err)s") % {'image_id': image_id,
|
||||
'err': err})
|
||||
LOG.error(msg)
|
||||
|
||||
if expected_size != bytes_written:
|
||||
msg = (_("Backend storage for image %(image_id)s "
|
||||
"disconnected after writing only %(bytes_written)d "
|
||||
"bytes") % {'image_id': image_id,
|
||||
'bytes_written': bytes_written})
|
||||
msg = (_LE("Backend storage for image %(image_id)s "
|
||||
"disconnected after writing only %(bytes_written)d "
|
||||
"bytes") % {'image_id': image_id,
|
||||
'bytes_written': bytes_written})
|
||||
LOG.error(msg)
|
||||
raise exception.GlanceException(_("Corrupt image download for "
|
||||
"image %(image_id)s") %
|
||||
|
@ -83,8 +87,8 @@ def image_send_notification(bytes_written, expected_size, image_meta, request,
|
|||
notify('image.send', payload)
|
||||
|
||||
except Exception as err:
|
||||
msg = (_("An error occurred during image.send"
|
||||
" notification: %(err)s") % {'err': err})
|
||||
msg = (_LE("An error occurred during image.send"
|
||||
" notification: %(err)s") % {'err': err})
|
||||
LOG.error(msg)
|
||||
|
||||
|
||||
|
@ -109,8 +113,8 @@ def get_remaining_quota(context, db_api, image_id=None):
|
|||
match = pattern.match(users_quota)
|
||||
|
||||
if not match:
|
||||
LOG.warn(_("Invalid value for option user_storage_quota: "
|
||||
"%(users_quota)s")
|
||||
LOG.warn(_LW("Invalid value for option user_storage_quota: "
|
||||
"%(users_quota)s")
|
||||
% {'users_quota': users_quota})
|
||||
return None
|
||||
|
||||
|
@ -154,18 +158,18 @@ 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(_("User %(user)s attempted to upload an image of"
|
||||
" unknown size that will exceeed the quota."
|
||||
" %(remaining)d bytes remaining.")
|
||||
LOG.info(_LI("User %(user)s attempted to upload an image of"
|
||||
" unknown size that will exceeed the quota."
|
||||
" %(remaining)d bytes remaining.")
|
||||
% {'user': user, 'remaining': remaining})
|
||||
raise exception.StorageQuotaFull(image_size=image_size,
|
||||
remaining=remaining)
|
||||
return
|
||||
|
||||
if image_size > remaining:
|
||||
LOG.info(_("User %(user)s attempted to upload an image of size"
|
||||
" %(size)d that will exceeed the quota. %(remaining)d"
|
||||
" bytes remaining.")
|
||||
LOG.info(_LI("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})
|
||||
raise exception.StorageQuotaFull(image_size=image_size,
|
||||
remaining=remaining)
|
||||
|
|
|
@ -35,10 +35,14 @@ from glance.common import wsgi
|
|||
import glance.db
|
||||
from glance import image_cache
|
||||
from glance import notifier
|
||||
from glance.openstack.common import gettextutils
|
||||
import glance.openstack.common.log as logging
|
||||
import glance.registry.client.v1.api as registry
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
_LI = gettextutils._LI
|
||||
_LE = gettextutils._LE
|
||||
_LW = gettextutils._LW
|
||||
|
||||
PATTERNS = {
|
||||
('v1', 'GET'): re.compile(r'^/v1/images/([^\/]+)$'),
|
||||
|
@ -54,7 +58,7 @@ class CacheFilter(wsgi.Middleware):
|
|||
self.cache = image_cache.ImageCache()
|
||||
self.serializer = images.ImageSerializer()
|
||||
self.policy = policy.Enforcer()
|
||||
LOG.info(_("Initialized image cache middleware"))
|
||||
LOG.info(_LI("Initialized image cache middleware"))
|
||||
super(CacheFilter, self).__init__(app)
|
||||
|
||||
def _verify_metadata(self, image_meta):
|
||||
|
@ -129,9 +133,9 @@ class CacheFilter(wsgi.Middleware):
|
|||
try:
|
||||
return method(request, image_id, image_iterator)
|
||||
except exception.NotFound:
|
||||
msg = _("Image cache contained image file for image '%s', "
|
||||
"however the registry did not contain metadata for "
|
||||
"that image!") % image_id
|
||||
msg = _LE("Image cache contained image file for image '%s', "
|
||||
"however the registry did not contain metadata for "
|
||||
"that image!") % image_id
|
||||
LOG.error(msg)
|
||||
self.cache.delete_cached_image(image_id)
|
||||
|
||||
|
@ -227,7 +231,7 @@ class CacheFilter(wsgi.Middleware):
|
|||
try:
|
||||
process_response_method = getattr(self, method_str)
|
||||
except AttributeError:
|
||||
LOG.error(_('could not find %s') % method_str)
|
||||
LOG.error(_LE('could not find %s') % method_str)
|
||||
# Nothing to do here, move along
|
||||
return resp
|
||||
else:
|
||||
|
@ -247,7 +251,7 @@ class CacheFilter(wsgi.Middleware):
|
|||
image_checksum = resp.headers.get('x-image-meta-checksum')
|
||||
|
||||
if not image_checksum:
|
||||
LOG.error(_("Checksum header is missing."))
|
||||
LOG.error(_LE("Checksum header is missing."))
|
||||
|
||||
# NOTE(zhiyan): image_cache return a generator object and set to
|
||||
# response.app_iter, it will be called by eventlet.wsgi later.
|
||||
|
|
|
@ -21,9 +21,11 @@ import routes
|
|||
|
||||
from glance.api import cached_images
|
||||
from glance.common import wsgi
|
||||
from glance.openstack.common import gettextutils
|
||||
import glance.openstack.common.log as logging
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
_LI = gettextutils._LI
|
||||
|
||||
|
||||
class CacheManageFilter(wsgi.Middleware):
|
||||
|
@ -69,7 +71,7 @@ class CacheManageFilter(wsgi.Middleware):
|
|||
self._mapper = mapper
|
||||
self._resource = resource
|
||||
|
||||
LOG.info(_("Initialized image cache management middleware"))
|
||||
LOG.info(_LI("Initialized image cache management middleware"))
|
||||
super(CacheManageFilter, self).__init__(app)
|
||||
|
||||
def process_request(self, request):
|
||||
|
|
|
@ -20,9 +20,11 @@ Use gzip compression if the client accepts it.
|
|||
import re
|
||||
|
||||
from glance.common import wsgi
|
||||
from glance.openstack.common import gettextutils
|
||||
import glance.openstack.common.log as logging
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
_LI = gettextutils._LI
|
||||
|
||||
|
||||
class GzipMiddleware(wsgi.Middleware):
|
||||
|
@ -30,7 +32,7 @@ class GzipMiddleware(wsgi.Middleware):
|
|||
re_zip = re.compile(r'\bgzip\b')
|
||||
|
||||
def __init__(self, app):
|
||||
LOG.info(_("Initialized gzip middleware"))
|
||||
LOG.info(_LI("Initialized gzip middleware"))
|
||||
super(GzipMiddleware, self).__init__(app)
|
||||
|
||||
def process_response(self, response):
|
||||
|
|
|
@ -42,6 +42,7 @@ from glance.common import utils
|
|||
from glance.common import wsgi
|
||||
from glance import notifier
|
||||
from glance.openstack.common import excutils
|
||||
from glance.openstack.common import gettextutils
|
||||
import glance.openstack.common.log as logging
|
||||
from glance.openstack.common import strutils
|
||||
import glance.registry.client.v1.api as registry
|
||||
|
@ -54,6 +55,7 @@ from glance.store import get_store_from_scheme
|
|||
from glance.store import validate_location
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
_LI = gettextutils._LI
|
||||
SUPPORTED_PARAMS = glance.api.v1.SUPPORTED_PARAMS
|
||||
SUPPORTED_FILTERS = glance.api.v1.SUPPORTED_FILTERS
|
||||
ACTIVE_IMMUTABLE = glance.api.v1.ACTIVE_IMMUTABLE
|
||||
|
@ -696,7 +698,7 @@ class Controller(controller.BaseController):
|
|||
image_meta)
|
||||
image_meta = self._upload_and_activate(req, image_meta)
|
||||
elif copy_from:
|
||||
msg = _('Triggering asynchronous copy from external source')
|
||||
msg = _LI('Triggering asynchronous copy from external source')
|
||||
LOG.info(msg)
|
||||
self.pool.spawn_n(self._upload_and_activate, req, image_meta)
|
||||
else:
|
||||
|
@ -1106,10 +1108,10 @@ class ImageDeserializer(wsgi.JSONRequestDeserializer):
|
|||
|
||||
elif image_size > CONF.image_size_cap:
|
||||
max_image_size = CONF.image_size_cap
|
||||
msg = _("Denying attempt to upload image larger than %d bytes.")
|
||||
LOG.warn(msg % max_image_size)
|
||||
raise HTTPBadRequest(explanation=msg % max_image_size,
|
||||
request=request)
|
||||
msg = (_("Denying attempt to upload image larger than %d"
|
||||
" bytes.") % max_image_size)
|
||||
LOG.warn(msg)
|
||||
raise HTTPBadRequest(explanation=msg, request=request)
|
||||
|
||||
result['image_data'] = data
|
||||
return result
|
||||
|
|
|
@ -21,6 +21,7 @@ from glance.common import store_utils
|
|||
from glance.common import utils
|
||||
import glance.db
|
||||
from glance.openstack.common import excutils
|
||||
from glance.openstack.common import gettextutils
|
||||
import glance.openstack.common.log as logging
|
||||
import glance.registry.client.v1.api as registry
|
||||
import glance.store as store_api
|
||||
|
@ -28,6 +29,8 @@ import glance.store as store_api
|
|||
|
||||
CONF = cfg.CONF
|
||||
LOG = logging.getLogger(__name__)
|
||||
_LE = gettextutils._LE
|
||||
_LI = gettextutils._LI
|
||||
|
||||
|
||||
def initiate_deletion(req, location_data, id):
|
||||
|
@ -66,7 +69,7 @@ def safe_kill(req, image_id):
|
|||
try:
|
||||
_kill(req, image_id)
|
||||
except Exception:
|
||||
LOG.exception(_("Unable to kill image %(id)s: ") % {'id': image_id})
|
||||
LOG.exception(_LE("Unable to kill image %(id)s: ") % {'id': image_id})
|
||||
|
||||
|
||||
def upload_data_to_store(req, image_meta, image_data, store, notifier):
|
||||
|
@ -106,8 +109,8 @@ def upload_data_to_store(req, image_meta, image_data, store, notifier):
|
|||
req.context, size, db_api, image_id=image_id)
|
||||
except exception.StorageQuotaFull:
|
||||
with excutils.save_and_reraise_exception():
|
||||
LOG.info(_('Cleaning up %s after exceeding '
|
||||
'the quota') % image_id)
|
||||
LOG.info(_LI('Cleaning up %s after exceeding '
|
||||
'the quota') % image_id)
|
||||
store_utils.safe_delete_from_backend(
|
||||
req.context, image_meta['id'], location_data)
|
||||
|
||||
|
@ -147,8 +150,8 @@ def upload_data_to_store(req, image_meta, image_data, store, notifier):
|
|||
update_data)
|
||||
|
||||
except exception.NotFound as e:
|
||||
msg = _("Image %s could not be found after upload. The image may "
|
||||
"have been deleted during the upload.") % image_id
|
||||
msg = _LI("Image %s could not be found after upload. The image may"
|
||||
" have been deleted during the upload.") % image_id
|
||||
LOG.info(msg)
|
||||
|
||||
# NOTE(jculp): we need to clean up the datastore if an image
|
||||
|
@ -226,7 +229,7 @@ def upload_data_to_store(req, image_meta, image_data, store, notifier):
|
|||
# but something in the above function calls is affecting the
|
||||
# exception context and we must explicitly re-raise the
|
||||
# caught exception.
|
||||
msg = _("Received HTTP error while uploading image %s") % image_id
|
||||
msg = _LE("Received HTTP error while uploading image %s") % image_id
|
||||
notifier.error('image.upload', msg)
|
||||
with excutils.save_and_reraise_exception():
|
||||
LOG.exception(msg)
|
||||
|
|
|
@ -23,10 +23,12 @@ import glance.db
|
|||
import glance.gateway
|
||||
import glance.notifier
|
||||
from glance.openstack.common import excutils
|
||||
from glance.openstack.common import gettextutils
|
||||
import glance.openstack.common.log as logging
|
||||
import glance.store
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
_LE = gettextutils._LE
|
||||
|
||||
|
||||
class ImageDataController(object):
|
||||
|
@ -54,8 +56,9 @@ class ImageDataController(object):
|
|||
image.status = 'queued'
|
||||
image_repo.save(image)
|
||||
except Exception as e:
|
||||
msg = _("Unable to restore image %(image_id)s: %(e)s") % \
|
||||
{'image_id': image.image_id, 'e': utils.exception_to_str(e)}
|
||||
msg = (_LE("Unable to restore image %(image_id)s: %(e)s") %
|
||||
{'image_id': image.image_id,
|
||||
'e': utils.exception_to_str(e)})
|
||||
LOG.exception(msg)
|
||||
|
||||
@utils.mutating
|
||||
|
@ -141,13 +144,13 @@ class ImageDataController(object):
|
|||
|
||||
except webob.exc.HTTPError as e:
|
||||
with excutils.save_and_reraise_exception():
|
||||
LOG.error(_("Failed to upload image data due to HTTP error"))
|
||||
LOG.error(_LE("Failed to upload image data due to HTTP error"))
|
||||
self._restore(image_repo, image)
|
||||
|
||||
except Exception as e:
|
||||
with excutils.save_and_reraise_exception():
|
||||
LOG.exception(_("Failed to upload image data due to "
|
||||
"internal error"))
|
||||
LOG.exception(_LE("Failed to upload image data due to "
|
||||
"internal error"))
|
||||
self._restore(image_repo, image)
|
||||
|
||||
def download(self, req, image_id):
|
||||
|
|
|
@ -28,6 +28,7 @@ from glance.common import wsgi
|
|||
import glance.db
|
||||
import glance.gateway
|
||||
import glance.notifier
|
||||
from glance.openstack.common import gettextutils
|
||||
from glance.openstack.common import jsonutils as json
|
||||
import glance.openstack.common.log as logging
|
||||
from glance.openstack.common import timeutils
|
||||
|
@ -35,6 +36,8 @@ import glance.schema
|
|||
import glance.store
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
_LI = gettextutils._LI
|
||||
_LW = gettextutils._LW
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.import_opt('disk_formats', 'glance.common.config', group='image_format')
|
||||
|
@ -130,8 +133,8 @@ class ImagesController(object):
|
|||
except exception.InvalidParameterValue as e:
|
||||
raise webob.exc.HTTPBadRequest(explanation=e.msg)
|
||||
except exception.StorageQuotaFull as e:
|
||||
msg = (_("Denying attempt to upload image because it exceeds the ."
|
||||
"quota: %s") % utils.exception_to_str(e))
|
||||
msg = (_LI("Denying attempt to upload image because it exceeds the"
|
||||
" .quota: %s") % utils.exception_to_str(e))
|
||||
LOG.info(msg)
|
||||
raise webob.exc.HTTPRequestEntityTooLarge(
|
||||
explanation=msg, request=req, content_type='text/plain')
|
||||
|
@ -816,9 +819,9 @@ def load_custom_properties():
|
|||
schema_data = schema_file.read()
|
||||
return json.loads(schema_data)
|
||||
else:
|
||||
msg = _('Could not find schema properties file %s. Continuing '
|
||||
'without custom properties')
|
||||
LOG.warn(msg % filename)
|
||||
msg = (_LW('Could not find schema properties file %s. Continuing '
|
||||
'without custom properties') % filename)
|
||||
LOG.warn(msg)
|
||||
return {}
|
||||
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ from glance.common import wsgi
|
|||
import glance.db
|
||||
import glance.gateway
|
||||
import glance.notifier
|
||||
from glance.openstack.common import gettextutils
|
||||
import glance.openstack.common.jsonutils as json
|
||||
import glance.openstack.common.log as logging
|
||||
from glance.openstack.common import timeutils
|
||||
|
@ -35,6 +36,7 @@ import glance.schema
|
|||
import glance.store
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
_LI = gettextutils._LI
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.import_opt('task_time_to_live', 'glance.common.config', group='task')
|
||||
|
@ -63,7 +65,7 @@ class TasksController(object):
|
|||
task_input=task['input'])
|
||||
task_repo.add(new_task)
|
||||
except exception.Forbidden as e:
|
||||
msg = (_("Forbidden to create task. Reason: %(reason)s")
|
||||
msg = (_LI("Forbidden to create task. Reason: %(reason)s")
|
||||
% {'reason': utils.exception_to_str(e)})
|
||||
LOG.info(msg)
|
||||
raise webob.exc.HTTPForbidden(explanation=e.msg)
|
||||
|
@ -101,12 +103,13 @@ class TasksController(object):
|
|||
task_repo = self.gateway.get_task_repo(req.context)
|
||||
task = task_repo.get(task_id)
|
||||
except exception.NotFound as e:
|
||||
msg = (_("Failed to find task %(task_id)s. Reason: %(reason)s") %
|
||||
msg = (_LI("Failed to find task %(task_id)s. Reason: %(reason)s") %
|
||||
{'task_id': task_id, 'reason': utils.exception_to_str(e)})
|
||||
LOG.info(msg)
|
||||
raise webob.exc.HTTPNotFound(explanation=e.msg)
|
||||
except exception.Forbidden as e:
|
||||
msg = (_("Forbidden to get task %(task_id)s. Reason: %(reason)s") %
|
||||
msg = (_LI("Forbidden to get task %(task_id)s. Reason:"
|
||||
" %(reason)s") %
|
||||
{'task_id': task_id, 'reason': utils.exception_to_str(e)})
|
||||
LOG.info(msg)
|
||||
raise webob.exc.HTTPForbidden(explanation=e.msg)
|
||||
|
|
|
@ -46,11 +46,13 @@ from glance.common import utils
|
|||
from glance.db import migration as db_migration
|
||||
from glance.db.sqlalchemy import api as db_api
|
||||
from glance.openstack.common.db.sqlalchemy import migration
|
||||
from glance.openstack.common import gettextutils
|
||||
from glance.openstack.common import log
|
||||
from glance.openstack.common import strutils
|
||||
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
_LW = gettextutils._LW
|
||||
|
||||
manager_opts = [
|
||||
cfg.BoolOpt('db_enforce_mysql_charset',
|
||||
|
@ -84,11 +86,11 @@ class DbCommands(object):
|
|||
|
||||
def _need_sanity_check(self):
|
||||
if not CONF.db_enforce_mysql_charset:
|
||||
LOG.warning(_('Warning: '
|
||||
'The db_enforce_mysql_charset option is now '
|
||||
'deprecated and will be removed in the Juno '
|
||||
'release. Please migrate DB manually e.g. '
|
||||
'convert data of all tables to UTF-8 charset.'))
|
||||
LOG.warning(_LW('Warning: '
|
||||
'The db_enforce_mysql_charset option is now '
|
||||
'deprecated and will be removed in the Juno '
|
||||
'release. Please migrate DB manually e.g. '
|
||||
'convert data of all tables to UTF-8 charset.'))
|
||||
return CONF.db_enforce_mysql_charset
|
||||
|
||||
def version(self):
|
||||
|
|
|
@ -321,11 +321,11 @@ def replication_dump(options, args):
|
|||
client = imageservice(httplib.HTTPConnection(server, port),
|
||||
options.mastertoken)
|
||||
for image in client.get_images():
|
||||
LOG.info(_LI('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):
|
||||
LOG.info(_LI('... storing'))
|
||||
LOG.info(_LI('Storing: %s') % image['id'])
|
||||
|
||||
# Dump glance information
|
||||
with open(data_path, 'w') as f:
|
||||
|
@ -336,7 +336,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.info(_LI('... image is active'))
|
||||
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:
|
||||
|
@ -424,14 +424,16 @@ def replication_load(options, args):
|
|||
del headers[key]
|
||||
|
||||
if _dict_diff(meta, headers):
|
||||
LOG.info(_LI('... metadata has changed'))
|
||||
LOG.info(_LI('Image %s metadata has changed') %
|
||||
image_uuid)
|
||||
headers, body = client.add_image_meta(meta)
|
||||
_check_upload_response_headers(headers, body)
|
||||
updated.append(meta['id'])
|
||||
|
||||
else:
|
||||
if not os.path.exists(os.path.join(path, image_uuid + '.img')):
|
||||
LOG.info(_LI('... dump is missing image data, skipping'))
|
||||
LOG.debug('%s dump is missing image data, skipping' %
|
||||
image_uuid)
|
||||
continue
|
||||
|
||||
# Upload the image itself
|
||||
|
@ -473,7 +475,7 @@ def replication_livecopy(options, args):
|
|||
updated = []
|
||||
|
||||
for image in master_client.get_images():
|
||||
LOG.info(_LI('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',
|
||||
|
@ -497,13 +499,14 @@ def replication_livecopy(options, args):
|
|||
del headers[key]
|
||||
|
||||
if _dict_diff(image, headers):
|
||||
LOG.info(_LI('... metadata has changed'))
|
||||
LOG.info(_LI('Image %s metadata has changed') %
|
||||
image['id'])
|
||||
headers, body = slave_client.add_image_meta(image)
|
||||
_check_upload_response_headers(headers, body)
|
||||
updated.append(image['id'])
|
||||
|
||||
elif image['status'] == 'active':
|
||||
LOG.info(_LI('%s is being synced') % image['id'])
|
||||
LOG.info(_LI('Image %s is being synced') % image['id'])
|
||||
if not options.metaonly:
|
||||
image_response = master_client.get_image(image['id'])
|
||||
try:
|
||||
|
@ -570,7 +573,7 @@ def replication_compare(options, args):
|
|||
% {'image_id': image['id']})
|
||||
|
||||
elif image['status'] == 'active':
|
||||
LOG.info(_LI('%s: entirely missing from the destination')
|
||||
LOG.info(_LI('Image %s entirely missing from the destination')
|
||||
% image['id'])
|
||||
differences[image['id']] = 'missing'
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ from glance.common import exception
|
|||
from glance.db.sqlalchemy import models
|
||||
from glance.openstack.common.db import exception as db_exception
|
||||
from glance.openstack.common.db.sqlalchemy import session
|
||||
from glance.openstack.common import gettextutils
|
||||
import glance.openstack.common.log as os_logging
|
||||
from glance.openstack.common import timeutils
|
||||
|
||||
|
@ -39,6 +40,8 @@ from glance.openstack.common import timeutils
|
|||
BASE = models.BASE
|
||||
sa_logger = None
|
||||
LOG = os_logging.getLogger(__name__)
|
||||
_LI = gettextutils._LI
|
||||
_LW = gettextutils._LW
|
||||
|
||||
|
||||
STATUSES = ['active', 'saving', 'queued', 'killed', 'pending_delete',
|
||||
|
@ -57,7 +60,7 @@ def _retry_on_deadlock(exc):
|
|||
"""Decorator to retry a DB API call if Deadlock was received."""
|
||||
|
||||
if isinstance(exc, db_exception.DBDeadlock):
|
||||
LOG.warn(_("Deadlock detected. Retrying..."))
|
||||
LOG.warn(_LW("Deadlock detected. Retrying..."))
|
||||
return True
|
||||
return False
|
||||
|
||||
|
@ -92,7 +95,7 @@ def clear_db_env():
|
|||
|
||||
def _check_mutate_authorization(context, image_ref):
|
||||
if not is_image_mutable(context, image_ref):
|
||||
LOG.info(_("Attempted to modify image user did not own."))
|
||||
LOG.info(_LI("Attempted to modify image user did not own."))
|
||||
msg = _("You do not own this image")
|
||||
if image_ref.is_public:
|
||||
exc_class = exception.ForbiddenPublicImage
|
||||
|
@ -300,7 +303,7 @@ def _paginate_query(query, model, limit, sort_keys, marker=None,
|
|||
if 'id' not in sort_keys:
|
||||
# TODO(justinsb): If this ever gives a false-positive, check
|
||||
# the actual primary key, rather than assuming its id
|
||||
LOG.warn(_('Id not in sort_keys; is sort_keys unique?'))
|
||||
LOG.warn(_LW('Id not in sort_keys; is sort_keys unique?'))
|
||||
|
||||
assert(not (sort_dir and sort_dirs))
|
||||
|
||||
|
|
|
@ -19,10 +19,12 @@ Various conveniences used for migration scripts
|
|||
|
||||
import sqlalchemy.types
|
||||
|
||||
from glance.openstack.common import gettextutils
|
||||
import glance.openstack.common.log as logging
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
_LI = gettextutils._LI
|
||||
|
||||
|
||||
String = lambda length: sqlalchemy.types.String(
|
||||
|
@ -93,11 +95,11 @@ def from_migration_import(module_name, fromlist):
|
|||
|
||||
def create_tables(tables):
|
||||
for table in tables:
|
||||
LOG.info(_("creating table %(table)s") % {'table': table})
|
||||
LOG.info(_LI("creating table %(table)s") % {'table': table})
|
||||
table.create()
|
||||
|
||||
|
||||
def drop_tables(tables):
|
||||
for table in tables:
|
||||
LOG.info(_("dropping table %(table)s") % {'table': table})
|
||||
LOG.info(_LI("dropping table %(table)s") % {'table': table})
|
||||
table.drop()
|
||||
|
|
|
@ -18,9 +18,11 @@ import sqlalchemy
|
|||
|
||||
from glance.common import exception
|
||||
from glance.common import utils
|
||||
from glance.openstack.common import gettextutils
|
||||
import glance.openstack.common.log as logging
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
_LE = gettextutils._LE
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
|
@ -57,10 +59,10 @@ def migrate_location_credentials(migrate_engine, to_quoted):
|
|||
.values(location=fixed_uri).execute()
|
||||
except exception.BadStoreUri as e:
|
||||
reason = utils.exception_to_str(e)
|
||||
err_msg = _("Invalid store uri for image: %(image_id)s. "
|
||||
"Details: %(reason)s") % {'image_id': image.id,
|
||||
'reason': reason}
|
||||
LOG.exception(err_msg)
|
||||
msg = _LE("Invalid store uri for image: %(image_id)s. "
|
||||
"Details: %(reason)s") % {'image_id': image.id,
|
||||
'reason': reason}
|
||||
LOG.exception(msg)
|
||||
raise
|
||||
|
||||
|
||||
|
|
|
@ -35,10 +35,14 @@ import sqlalchemy
|
|||
from glance.common import crypt
|
||||
from glance.common import exception
|
||||
from glance.common import utils
|
||||
from glance.openstack.common import gettextutils
|
||||
import glance.openstack.common.log as logging
|
||||
import glance.store.swift # noqa
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
_LE = gettextutils._LE
|
||||
_LI = gettextutils._LI
|
||||
_LW = gettextutils._LW
|
||||
CONF = cfg.CONF
|
||||
|
||||
CONF.import_opt('metadata_encryption_key', 'glance.common.config')
|
||||
|
@ -63,9 +67,9 @@ def migrate_location_credentials(migrate_engine, to_quoted):
|
|||
reverse.
|
||||
"""
|
||||
if not CONF.metadata_encryption_key:
|
||||
msg = _("'metadata_encryption_key' was not specified in the config"
|
||||
" file or a config file was not specified. This means that"
|
||||
" this migration is a NOOP.")
|
||||
msg = _LI("'metadata_encryption_key' was not specified in the config"
|
||||
" file or a config file was not specified. This means that"
|
||||
" this migration is a NOOP.")
|
||||
LOG.info(msg)
|
||||
return
|
||||
|
||||
|
@ -83,14 +87,15 @@ def migrate_location_credentials(migrate_engine, to_quoted):
|
|||
.where(images_table.c.id == image['id'])\
|
||||
.values(location=fixed_uri).execute()
|
||||
except exception.Invalid:
|
||||
msg = _("Failed to decrypt location value for image %(image_id)s")
|
||||
LOG.warn(msg % {'image_id': image['id']})
|
||||
msg = _LW("Failed to decrypt location value for image"
|
||||
" %(image_id)s") % {'image_id': image['id']}
|
||||
LOG.warn(msg)
|
||||
except exception.BadStoreUri as e:
|
||||
reason = utils.exception_to_str(e)
|
||||
err_msg = _("Invalid store uri for image: %(image_id)s. "
|
||||
"Details: %(reason)s") % {'image_id': image.id,
|
||||
'reason': reason}
|
||||
LOG.exception(err_msg)
|
||||
msg = _LE("Invalid store uri for image: %(image_id)s. "
|
||||
"Details: %(reason)s") % {'image_id': image.id,
|
||||
'reason': reason}
|
||||
LOG.exception(msg)
|
||||
raise
|
||||
|
||||
|
||||
|
|
|
@ -24,11 +24,15 @@ from oslo.config import cfg
|
|||
from glance.common import exception
|
||||
from glance.common import utils
|
||||
from glance.openstack.common import excutils
|
||||
from glance.openstack.common import gettextutils
|
||||
from glance.openstack.common import importutils
|
||||
import glance.openstack.common.log as logging
|
||||
from glance.openstack.common import units
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
_LE = gettextutils._LE
|
||||
_LI = gettextutils._LI
|
||||
_LW = gettextutils._LW
|
||||
|
||||
image_cache_opts = [
|
||||
cfg.StrOpt('image_cache_driver', default='sqlite',
|
||||
|
@ -61,17 +65,17 @@ class ImageCache(object):
|
|||
driver_module = (__name__ + '.drivers.' + driver_name + '.Driver')
|
||||
try:
|
||||
self.driver_class = importutils.import_class(driver_module)
|
||||
LOG.info(_("Image cache loaded driver '%s'.") %
|
||||
LOG.info(_LI("Image cache loaded driver '%s'.") %
|
||||
driver_name)
|
||||
except ImportError as import_err:
|
||||
LOG.warn(_("Image cache driver "
|
||||
"'%(driver_name)s' failed to load. "
|
||||
"Got error: '%(import_err)s."),
|
||||
LOG.warn(_LW("Image cache driver "
|
||||
"'%(driver_name)s' failed to load. "
|
||||
"Got error: '%(import_err)s."),
|
||||
{'driver_name': driver_name,
|
||||
'import_err': import_err})
|
||||
|
||||
driver_module = __name__ + '.drivers.sqlite.Driver'
|
||||
LOG.info(_("Defaulting to SQLite driver."))
|
||||
LOG.info(_LI("Defaulting to SQLite driver."))
|
||||
self.driver_class = importutils.import_class(driver_module)
|
||||
self.configure_driver()
|
||||
|
||||
|
@ -85,12 +89,12 @@ class ImageCache(object):
|
|||
self.driver.configure()
|
||||
except exception.BadDriverConfiguration as config_err:
|
||||
driver_module = self.driver_class.__module__
|
||||
LOG.warn(_("Image cache driver "
|
||||
"'%(driver_module)s' failed to configure. "
|
||||
"Got error: '%(config_err)s"),
|
||||
LOG.warn(_LW("Image cache driver "
|
||||
"'%(driver_module)s' failed to configure. "
|
||||
"Got error: '%(config_err)s"),
|
||||
{'driver_module': driver_module,
|
||||
'config_err': config_err})
|
||||
LOG.info(_("Defaulting to SQLite driver."))
|
||||
LOG.info(_LI("Defaulting to SQLite driver."))
|
||||
default_module = __name__ + '.drivers.sqlite.Driver'
|
||||
self.driver_class = importutils.import_class(default_module)
|
||||
self.driver = self.driver_class()
|
||||
|
@ -261,9 +265,9 @@ class ImageCache(object):
|
|||
# bad length), or corrupt data (checksum is wrong).
|
||||
LOG.exception(utils.exception_to_str(e))
|
||||
except Exception as e:
|
||||
LOG.exception(_("Exception encountered while tee'ing "
|
||||
"image '%(image_id)s' into cache: %(error)s. "
|
||||
"Continuing with response.") %
|
||||
LOG.exception(_LE("Exception encountered while tee'ing "
|
||||
"image '%(image_id)s' into cache: %(error)s. "
|
||||
"Continuing with response.") %
|
||||
{'image_id': image_id,
|
||||
'error': utils.exception_to_str(e)})
|
||||
|
||||
|
|
|
@ -31,9 +31,13 @@ import sqlite3
|
|||
from glance.common import exception
|
||||
from glance.image_cache.drivers import base
|
||||
from glance.openstack.common import excutils
|
||||
from glance.openstack.common import gettextutils
|
||||
import glance.openstack.common.log as logging
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
_LE = gettextutils._LE
|
||||
_LI = gettextutils._LI
|
||||
_LW = gettextutils._LW
|
||||
|
||||
sqlite_opts = [
|
||||
cfg.StrOpt('image_cache_sqlite_db', default='cache.db',
|
||||
|
@ -390,7 +394,7 @@ class Driver(base.Driver):
|
|||
try:
|
||||
yield conn
|
||||
except sqlite3.DatabaseError as e:
|
||||
msg = _("Error executing SQLite call. Got error: %s") % e
|
||||
msg = _LE("Error executing SQLite call. Got error: %s") % e
|
||||
LOG.error(msg)
|
||||
conn.rollback()
|
||||
finally:
|
||||
|
@ -406,19 +410,19 @@ class Driver(base.Driver):
|
|||
:param image_id: Image ID
|
||||
"""
|
||||
if self.is_cached(image_id):
|
||||
msg = _("Not queueing image '%s'. Already cached.") % image_id
|
||||
LOG.warn(msg)
|
||||
msg = _LI("Not queueing image '%s'. Already cached.") % image_id
|
||||
LOG.info(msg)
|
||||
return False
|
||||
|
||||
if self.is_being_cached(image_id):
|
||||
msg = _("Not queueing image '%s'. Already being "
|
||||
"written to cache") % image_id
|
||||
LOG.warn(msg)
|
||||
msg = _LI("Not queueing image '%s'. Already being "
|
||||
"written to cache") % image_id
|
||||
LOG.info(msg)
|
||||
return False
|
||||
|
||||
if self.is_queued(image_id):
|
||||
msg = _("Not queueing image '%s'. Already queued.") % image_id
|
||||
LOG.warn(msg)
|
||||
msg = _LI("Not queueing image '%s'. Already queued.") % image_id
|
||||
LOG.info(msg)
|
||||
return False
|
||||
|
||||
path = self.get_image_filepath(image_id, 'queue')
|
||||
|
@ -435,7 +439,7 @@ class Driver(base.Driver):
|
|||
"""
|
||||
for path in self.get_cache_files(self.invalid_dir):
|
||||
os.unlink(path)
|
||||
LOG.info(_("Removed invalid cache file %s"), path)
|
||||
LOG.info(_LI("Removed invalid cache file %s") % path)
|
||||
|
||||
def delete_stalled_files(self, older_than):
|
||||
"""
|
||||
|
@ -449,10 +453,10 @@ class Driver(base.Driver):
|
|||
if os.path.getmtime(path) < older_than:
|
||||
try:
|
||||
os.unlink(path)
|
||||
LOG.info(_("Removed stalled cache file %s"), path)
|
||||
LOG.info(_LI("Removed stalled cache file %s") % path)
|
||||
except Exception as e:
|
||||
msg = (_("Failed to delete file %(path)s. "
|
||||
"Got error: %(e)s") %
|
||||
msg = (_LW("Failed to delete file %(path)s. "
|
||||
"Got error: %(e)s"),
|
||||
dict(path=path, e=e))
|
||||
LOG.warn(msg)
|
||||
|
||||
|
@ -488,5 +492,5 @@ def delete_cached_file(path):
|
|||
LOG.debug("Deleting image cache file '%s'", path)
|
||||
os.unlink(path)
|
||||
else:
|
||||
LOG.warn(_("Cached image file '%s' doesn't exist, unable to"
|
||||
" delete"), path)
|
||||
LOG.warn(_LW("Cached image file '%s' doesn't exist, unable to"
|
||||
" delete") % path)
|
||||
|
|
|
@ -65,9 +65,13 @@ from glance.common import exception
|
|||
from glance.common import utils
|
||||
from glance.image_cache.drivers import base
|
||||
from glance.openstack.common import excutils
|
||||
from glance.openstack.common import gettextutils
|
||||
import glance.openstack.common.log as logging
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
_LE = gettextutils._LE
|
||||
_LI = gettextutils._LI
|
||||
_LW = gettextutils._LW
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
||||
|
@ -102,11 +106,11 @@ class Driver(base.Driver):
|
|||
set_xattr(fake_image_filepath, 'hits', '1')
|
||||
except IOError as e:
|
||||
if e.errno == errno.EOPNOTSUPP:
|
||||
msg = (_("The device housing the image cache directory "
|
||||
"%(image_cache_dir)s does not support xattr. It is "
|
||||
"likely you need to edit your fstab and add the "
|
||||
"user_xattr option to the appropriate line for the "
|
||||
"device housing the cache directory.") %
|
||||
msg = (_LE("The device housing the image cache directory "
|
||||
"%(image_cache_dir)s does not support xattr. It is"
|
||||
" likely you need to edit your fstab and add the "
|
||||
"user_xattr option to the appropriate line for the"
|
||||
" device housing the cache directory.") %
|
||||
{'image_cache_dir': image_cache_dir})
|
||||
LOG.error(msg)
|
||||
raise exception.BadDriverConfiguration(driver_name="xattr",
|
||||
|
@ -273,13 +277,13 @@ class Driver(base.Driver):
|
|||
LOG.debug("Fetch finished, moving "
|
||||
"'%(incomplete_path)s' to '%(final_path)s'",
|
||||
dict(incomplete_path=incomplete_path,
|
||||
final_path=final_path))
|
||||
final_path=final_path))
|
||||
os.rename(incomplete_path, final_path)
|
||||
|
||||
# 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):
|
||||
|
@ -288,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': utils.exception_to_str(e),
|
||||
'incomplete_path': incomplete_path,
|
||||
'invalid_path': invalid_path})
|
||||
|
@ -335,19 +339,19 @@ class Driver(base.Driver):
|
|||
:param image_id: Image ID
|
||||
"""
|
||||
if self.is_cached(image_id):
|
||||
msg = _("Not queueing image '%s'. Already cached.") % image_id
|
||||
LOG.warn(msg)
|
||||
msg = _LI("Not queueing image '%s'. Already cached.") % image_id
|
||||
LOG.info(msg)
|
||||
return False
|
||||
|
||||
if self.is_being_cached(image_id):
|
||||
msg = _("Not queueing image '%s'. Already being "
|
||||
"written to cache") % image_id
|
||||
LOG.warn(msg)
|
||||
msg = _LI("Not queueing image '%s'. Already being "
|
||||
"written to cache") % image_id
|
||||
LOG.info(msg)
|
||||
return False
|
||||
|
||||
if self.is_queued(image_id):
|
||||
msg = _("Not queueing image '%s'. Already queued.") % image_id
|
||||
LOG.warn(msg)
|
||||
msg = _LI("Not queueing image '%s'. Already queued.") % image_id
|
||||
LOG.info(msg)
|
||||
return False
|
||||
|
||||
path = self.get_image_filepath(image_id, 'queue')
|
||||
|
@ -392,7 +396,7 @@ class Driver(base.Driver):
|
|||
delete_cached_file(path)
|
||||
reaped += 1
|
||||
|
||||
LOG.info(_("Reaped %(reaped)s %(entry_type)s cache entries"),
|
||||
LOG.info(_LI("Reaped %(reaped)s %(entry_type)s cache entries"),
|
||||
{'reaped': reaped, 'entry_type': entry_type})
|
||||
return reaped
|
||||
|
||||
|
@ -436,11 +440,11 @@ 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(_("Cached image file '%s' doesn't exist, unable to"
|
||||
" delete"), path)
|
||||
LOG.warn(_LW("Cached image file '%s' doesn't exist, unable to"
|
||||
" delete") % path)
|
||||
|
||||
|
||||
def _make_namespaced_xattr_key(key, namespace='user'):
|
||||
|
|
|
@ -22,12 +22,14 @@ import eventlet
|
|||
from glance.common import exception
|
||||
from glance import context
|
||||
from glance.image_cache import base
|
||||
from glance.openstack.common import gettextutils
|
||||
import glance.openstack.common.log as logging
|
||||
import glance.registry.client.v1.api as registry
|
||||
import glance.store
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
_LI = gettextutils._LI
|
||||
_LW = gettextutils._LW
|
||||
|
||||
|
||||
class Prefetcher(base.CacheApp):
|
||||
|
@ -43,17 +45,17 @@ class Prefetcher(base.CacheApp):
|
|||
try:
|
||||
image_meta = registry.get_image_metadata(ctx, image_id)
|
||||
if image_meta['status'] != 'active':
|
||||
LOG.warn(_("Image '%s' is not active. Not caching."),
|
||||
LOG.warn(_LW("Image '%s' is not active. Not caching.") %
|
||||
image_id)
|
||||
return False
|
||||
|
||||
except exception.NotFound:
|
||||
LOG.warn(_("No metadata found for image '%s'"), image_id)
|
||||
LOG.warn(_LW("No metadata found for image '%s'") % image_id)
|
||||
return False
|
||||
|
||||
location = image_meta['location']
|
||||
image_data, image_size = glance.store.get_from_backend(ctx, location)
|
||||
LOG.debug("Caching image '%s'", image_id)
|
||||
LOG.debug("Caching image '%s'" % image_id)
|
||||
cache_tee_iter = self.cache.cache_tee_iter(image_id, image_data,
|
||||
image_meta['checksum'])
|
||||
# Image is tee'd into cache and checksum verified
|
||||
|
@ -75,9 +77,9 @@ class Prefetcher(base.CacheApp):
|
|||
results = pool.imap(self.fetch_image_into_cache, images)
|
||||
successes = sum([1 for r in results if r is True])
|
||||
if successes != num_images:
|
||||
LOG.error(_("Failed to successfully cache all "
|
||||
"images in queue."))
|
||||
LOG.warn(_LW("Failed to successfully cache all "
|
||||
"images in queue."))
|
||||
return False
|
||||
|
||||
LOG.info(_("Successfully cached all %d images"), num_images)
|
||||
LOG.info(_LI("Successfully cached all %d images") % num_images)
|
||||
return True
|
||||
|
|
|
@ -24,10 +24,12 @@ from glance.common import utils
|
|||
import glance.domain
|
||||
import glance.domain.proxy
|
||||
from glance.openstack.common import excutils
|
||||
from glance.openstack.common import gettextutils
|
||||
import glance.openstack.common.log as logging
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
_LI = gettextutils._LI
|
||||
CONF = cfg.CONF
|
||||
CONF.import_opt('image_member_quota', 'glance.common.config')
|
||||
CONF.import_opt('image_property_quota', 'glance.common.config')
|
||||
|
@ -324,7 +326,7 @@ class ImageProxy(glance.domain.proxy.Image):
|
|||
image_id=self.image.image_id)
|
||||
except exception.StorageQuotaFull:
|
||||
with excutils.save_and_reraise_exception():
|
||||
LOG.info(_('Cleaning up %s after exceeding the quota.')
|
||||
LOG.info(_LI('Cleaning up %s after exceeding the quota.')
|
||||
% self.image.image_id)
|
||||
self.store_utils.safe_delete_from_backend(
|
||||
self.context, self.image.image_id, self.image.locations[0])
|
||||
|
|
|
@ -24,12 +24,15 @@ from glance.common import exception
|
|||
from glance.common import utils
|
||||
from glance.common import wsgi
|
||||
import glance.db
|
||||
from glance.openstack.common import gettextutils
|
||||
import glance.openstack.common.log as logging
|
||||
from glance.openstack.common import strutils
|
||||
from glance.openstack.common import timeutils
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
_LE = gettextutils._LE
|
||||
_LI = gettextutils._LI
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
||||
|
@ -118,17 +121,17 @@ class Controller(object):
|
|||
return self.db_api.image_get_all(context, filters=filters,
|
||||
**params)
|
||||
except exception.NotFound:
|
||||
LOG.info(_("Invalid marker. Image %(id)s could not be "
|
||||
"found.") % {'id': params.get('marker')})
|
||||
LOG.info(_LI("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(_("Access denied to image %(id)s but returning "
|
||||
"'not found'") % {'id': params.get('marker')})
|
||||
LOG.info(_LI("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)
|
||||
except Exception:
|
||||
LOG.exception(_("Unable to get images"))
|
||||
LOG.exception(_LE("Unable to get images"))
|
||||
raise
|
||||
|
||||
def index(self, req):
|
||||
|
@ -160,7 +163,7 @@ class Controller(object):
|
|||
result[field] = image[field]
|
||||
results.append(result)
|
||||
|
||||
LOG.info(_("Returning image list"))
|
||||
LOG.debug("Returning image list")
|
||||
return dict(images=results)
|
||||
|
||||
def detail(self, req):
|
||||
|
@ -178,7 +181,7 @@ class Controller(object):
|
|||
|
||||
images = self._get_images(req.context, **params)
|
||||
image_dicts = [make_image_dict(i) for i in images]
|
||||
LOG.info(_("Returning detailed image list"))
|
||||
LOG.debug("Returning detailed image list")
|
||||
return dict(images=image_dicts)
|
||||
|
||||
def _get_query_params(self, req):
|
||||
|
@ -332,20 +335,21 @@ 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")
|
||||
LOG.info(msg % {'id': id})
|
||||
msg = "Successfully retrieved image %(id)s" % {'id': id}
|
||||
LOG.debug(msg)
|
||||
except exception.NotFound:
|
||||
msg = _("Image %(id)s not found")
|
||||
LOG.info(msg % {'id': id})
|
||||
msg = _LI("Image %(id)s not found") % {'id': id}
|
||||
LOG.info(msg)
|
||||
raise exc.HTTPNotFound()
|
||||
except exception.Forbidden:
|
||||
# If it's private and doesn't belong to them, don't let on
|
||||
# that it exists
|
||||
msg = _("Access denied to image %(id)s but returning 'not found'")
|
||||
LOG.info(msg % {'id': id})
|
||||
msg = _LI("Access denied to image %(id)s but returning"
|
||||
" 'not found'") % {'id': id}
|
||||
LOG.info(msg)
|
||||
raise exc.HTTPNotFound()
|
||||
except Exception:
|
||||
LOG.exception(_("Unable to show image %s"), id)
|
||||
LOG.exception(_LE("Unable to show image %s") % id)
|
||||
raise
|
||||
|
||||
return dict(image=make_image_dict(image))
|
||||
|
@ -362,25 +366,26 @@ class Controller(object):
|
|||
"""
|
||||
try:
|
||||
deleted_image = self.db_api.image_destroy(req.context, id)
|
||||
msg = _("Successfully deleted image %(id)s")
|
||||
LOG.info(msg % {'id': id})
|
||||
msg = _LI("Successfully deleted image %(id)s") % {'id': id}
|
||||
LOG.info(msg)
|
||||
return dict(image=make_image_dict(deleted_image))
|
||||
except exception.ForbiddenPublicImage:
|
||||
msg = _("Delete denied for public image %(id)s")
|
||||
LOG.info(msg % {'id': id})
|
||||
msg = _LI("Delete denied for public image %(id)s") % {'id': id}
|
||||
LOG.info(msg)
|
||||
raise exc.HTTPForbidden()
|
||||
except exception.Forbidden:
|
||||
# If it's private and doesn't belong to them, don't let on
|
||||
# that it exists
|
||||
msg = _("Access denied to image %(id)s but returning 'not found'")
|
||||
LOG.info(msg % {'id': id})
|
||||
msg = _LI("Access denied to image %(id)s but returning"
|
||||
" 'not found'") % {'id': id}
|
||||
LOG.info(msg)
|
||||
return exc.HTTPNotFound()
|
||||
except exception.NotFound:
|
||||
msg = _("Image %(id)s not found")
|
||||
LOG.info(msg % {'id': id})
|
||||
msg = _LI("Image %(id)s not found") % {'id': id}
|
||||
LOG.info(msg)
|
||||
return exc.HTTPNotFound()
|
||||
except Exception:
|
||||
LOG.exception(_("Unable to delete image %s"), id)
|
||||
LOG.exception(_LE("Unable to delete image %s") % id)
|
||||
raise
|
||||
|
||||
@utils.mutating
|
||||
|
@ -405,9 +410,9 @@ class Controller(object):
|
|||
|
||||
image_id = image_data.get('id')
|
||||
if image_id and not utils.is_uuid_like(image_id):
|
||||
msg = _("Rejecting image creation request for invalid image "
|
||||
"id '%(bad_id)s'")
|
||||
LOG.info(msg % {'bad_id': image_id})
|
||||
msg = _LI("Rejecting image creation request for invalid image "
|
||||
"id '%(bad_id)s'") % {'bad_id': image_id}
|
||||
LOG.info(msg)
|
||||
msg = _("Invalid image id format")
|
||||
return exc.HTTPBadRequest(explanation=msg)
|
||||
|
||||
|
@ -418,12 +423,13 @@ class Controller(object):
|
|||
image_data = _normalize_image_location_for_db(image_data)
|
||||
image_data = self.db_api.image_create(req.context, image_data)
|
||||
image_data = dict(image=make_image_dict(image_data))
|
||||
msg = _("Successfully created image %(id)s") % image_data['image']
|
||||
msg = (_LI("Successfully created image %(id)s") %
|
||||
image_data['image'])
|
||||
LOG.info(msg)
|
||||
return image_data
|
||||
except exception.Duplicate:
|
||||
msg = _("Image with identifier %s already exists!") % image_id
|
||||
LOG.error(msg)
|
||||
LOG.warn(msg)
|
||||
return exc.HTTPConflict(msg)
|
||||
except exception.Invalid as e:
|
||||
msg = (_("Failed to add image metadata. "
|
||||
|
@ -431,7 +437,7 @@ class Controller(object):
|
|||
LOG.error(msg)
|
||||
return exc.HTTPBadRequest(msg)
|
||||
except Exception:
|
||||
LOG.exception(_("Unable to create image %s"), image_id)
|
||||
LOG.exception(_LE("Unable to create image %s"), image_id)
|
||||
raise
|
||||
|
||||
@utils.mutating
|
||||
|
@ -470,8 +476,8 @@ class Controller(object):
|
|||
purge_props=purge_props,
|
||||
from_state=from_state)
|
||||
|
||||
msg = _("Updating metadata for image %(id)s")
|
||||
LOG.info(msg % {'id': id})
|
||||
msg = _LI("Updating metadata for image %(id)s") % {'id': id}
|
||||
LOG.info(msg)
|
||||
return dict(image=make_image_dict(updated_image))
|
||||
except exception.Invalid as e:
|
||||
msg = (_("Failed to update image metadata. "
|
||||
|
@ -479,20 +485,21 @@ class Controller(object):
|
|||
LOG.error(msg)
|
||||
return exc.HTTPBadRequest(msg)
|
||||
except exception.NotFound:
|
||||
msg = _("Image %(id)s not found")
|
||||
LOG.info(msg % {'id': id})
|
||||
msg = _LI("Image %(id)s not found") % {'id': id}
|
||||
LOG.info(msg)
|
||||
raise exc.HTTPNotFound(body='Image not found',
|
||||
request=req,
|
||||
content_type='text/plain')
|
||||
except exception.ForbiddenPublicImage:
|
||||
msg = _("Update denied for public image %(id)s")
|
||||
LOG.info(msg % {'id': id})
|
||||
msg = _LI("Update denied for public image %(id)s") % {'id': id}
|
||||
LOG.info(msg)
|
||||
raise exc.HTTPForbidden()
|
||||
except exception.Forbidden:
|
||||
# If it's private and doesn't belong to them, don't let on
|
||||
# that it exists
|
||||
msg = _("Access denied to image %(id)s but returning 'not found'")
|
||||
LOG.info(msg % {'id': id})
|
||||
msg = _LI("Access denied to image %(id)s but returning"
|
||||
" 'not found'") % {'id': id}
|
||||
LOG.info(msg)
|
||||
raise exc.HTTPNotFound(body='Image not found',
|
||||
request=req,
|
||||
content_type='text/plain')
|
||||
|
@ -502,7 +509,7 @@ class Controller(object):
|
|||
request=req,
|
||||
content_type='text/plain')
|
||||
except Exception:
|
||||
LOG.exception(_("Unable to update image %s"), id)
|
||||
LOG.exception(_LE("Unable to update image %s") % id)
|
||||
raise
|
||||
|
||||
|
||||
|
|
|
@ -19,10 +19,12 @@ from glance.common import exception
|
|||
from glance.common import utils
|
||||
from glance.common import wsgi
|
||||
import glance.db
|
||||
from glance.openstack.common import gettextutils
|
||||
import glance.openstack.common.log as logging
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
_LI = gettextutils._LI
|
||||
|
||||
|
||||
class Controller(object):
|
||||
|
@ -63,19 +65,20 @@ class Controller(object):
|
|||
try:
|
||||
self.db_api.image_get(req.context, image_id)
|
||||
except exception.NotFound:
|
||||
msg = _("Image %(id)s not found") % {'id': image_id}
|
||||
msg = _LI("Image %(id)s not found") % {'id': image_id}
|
||||
LOG.info(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 = _("Access denied to image %(id)s but returning 'not found'")
|
||||
LOG.info(msg % {'id': image_id})
|
||||
msg = _LI("Access denied to image %(id)s but returning"
|
||||
" 'not found'") % {'id': image_id}
|
||||
LOG.info(msg)
|
||||
raise webob.exc.HTTPNotFound()
|
||||
|
||||
members = self.db_api.image_member_find(req.context, image_id=image_id)
|
||||
msg = _("Returning member list for image %(id)s")
|
||||
LOG.info(msg % {'id': image_id})
|
||||
msg = "Returning member list for image %(id)s" % {'id': image_id}
|
||||
LOG.debug(msg)
|
||||
return dict(members=make_member_list(members,
|
||||
member_id='member',
|
||||
can_share='can_share'))
|
||||
|
@ -103,14 +106,16 @@ class Controller(object):
|
|||
except exception.Forbidden:
|
||||
# If it's private and doesn't belong to them, don't let on
|
||||
# that it exists
|
||||
msg = _("Access denied to image %(id)s but returning 'not found'")
|
||||
LOG.info(msg % {'id': image_id})
|
||||
msg = _LI("Access denied to image %(id)s but returning"
|
||||
" 'not found'") % {'id': image_id}
|
||||
LOG.info(msg)
|
||||
raise webob.exc.HTTPNotFound()
|
||||
|
||||
# Can they manipulate the membership?
|
||||
if not self.is_image_sharable(req.context, image):
|
||||
msg = _("User lacks permission to share image %(id)s")
|
||||
LOG.info(msg % {'id': image_id})
|
||||
msg = (_LI("User lacks permission to share image %(id)s") %
|
||||
{'id': image_id})
|
||||
LOG.info(msg)
|
||||
msg = _("No permission to share that image")
|
||||
raise webob.exc.HTTPForbidden(msg)
|
||||
|
||||
|
@ -119,9 +124,9 @@ class Controller(object):
|
|||
memb_list = body['memberships']
|
||||
except Exception as e:
|
||||
# Malformed entity...
|
||||
msg = _("Invalid membership association specified for "
|
||||
"image %(id)s")
|
||||
LOG.info(msg % {'id': image_id})
|
||||
msg = _LI("Invalid membership association specified for "
|
||||
"image %(id)s") % {'id': image_id}
|
||||
LOG.info(msg)
|
||||
msg = (_("Invalid membership association: %s") %
|
||||
utils.exception_to_str(e))
|
||||
raise webob.exc.HTTPBadRequest(explanation=msg)
|
||||
|
@ -136,9 +141,9 @@ class Controller(object):
|
|||
can_share=None)
|
||||
except Exception as e:
|
||||
# Malformed entity...
|
||||
msg = _("Invalid membership association specified for "
|
||||
"image %(id)s")
|
||||
LOG.info(msg % {'id': image_id})
|
||||
msg = _LI("Invalid membership association specified for "
|
||||
"image %(id)s") % {'id': image_id}
|
||||
LOG.info(msg)
|
||||
msg = (_("Invalid membership association: %s") %
|
||||
utils.exception_to_str(e))
|
||||
raise webob.exc.HTTPBadRequest(explanation=msg)
|
||||
|
@ -188,8 +193,9 @@ class Controller(object):
|
|||
self.db_api.image_member_create(req.context, memb)
|
||||
|
||||
# Make an appropriate result
|
||||
msg = _("Successfully updated memberships for image %(id)s")
|
||||
LOG.info(msg % {'id': image_id})
|
||||
msg = (_LI("Successfully updated memberships for image %(id)s") %
|
||||
{'id': image_id})
|
||||
LOG.info(msg)
|
||||
return webob.exc.HTTPNoContent()
|
||||
|
||||
@utils.mutating
|
||||
|
@ -212,20 +218,22 @@ class Controller(object):
|
|||
try:
|
||||
image = self.db_api.image_get(req.context, image_id)
|
||||
except exception.NotFound:
|
||||
msg = _("Image %(id)s not found") % {'id': image_id}
|
||||
msg = _LI("Image %(id)s not found") % {'id': image_id}
|
||||
LOG.info(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 = _("Access denied to image %(id)s but returning 'not found'")
|
||||
LOG.info(msg % {'id': image_id})
|
||||
msg = _LI("Access denied to image %(id)s but returning"
|
||||
" 'not found'") % {'id': image_id}
|
||||
LOG.info(msg)
|
||||
raise webob.exc.HTTPNotFound()
|
||||
|
||||
# Can they manipulate the membership?
|
||||
if not self.is_image_sharable(req.context, image):
|
||||
msg = _("User lacks permission to share image %(id)s")
|
||||
LOG.info(msg % {'id': image_id})
|
||||
msg = (_LI("User lacks permission to share image %(id)s") %
|
||||
{'id': image_id})
|
||||
LOG.info(msg)
|
||||
msg = _("No permission to share that image")
|
||||
raise webob.exc.HTTPForbidden(msg)
|
||||
|
||||
|
@ -236,9 +244,9 @@ class Controller(object):
|
|||
can_share = bool(body['member']['can_share'])
|
||||
except Exception as e:
|
||||
# Malformed entity...
|
||||
msg = _("Invalid membership association specified for "
|
||||
"image %(id)s")
|
||||
LOG.info(msg % {'id': image_id})
|
||||
msg = _LI("Invalid membership association specified for "
|
||||
"image %(id)s") % {'id': image_id}
|
||||
LOG.info(msg)
|
||||
msg = (_("Invalid membership association: %s") %
|
||||
utils.exception_to_str(e))
|
||||
raise webob.exc.HTTPBadRequest(explanation=msg)
|
||||
|
@ -258,8 +266,9 @@ class Controller(object):
|
|||
can_share=bool(can_share))
|
||||
self.db_api.image_member_create(req.context, values)
|
||||
|
||||
msg = _("Successfully updated a membership for image %(id)s")
|
||||
LOG.info(msg % {'id': image_id})
|
||||
msg = (_LI("Successfully updated a membership for image %(id)s") %
|
||||
{'id': image_id})
|
||||
LOG.info(msg)
|
||||
return webob.exc.HTTPNoContent()
|
||||
|
||||
@utils.mutating
|
||||
|
@ -273,20 +282,22 @@ class Controller(object):
|
|||
try:
|
||||
image = self.db_api.image_get(req.context, image_id)
|
||||
except exception.NotFound:
|
||||
msg = _("Image %(id)s not found") % {'id': image_id}
|
||||
msg = _LI("Image %(id)s not found") % {'id': image_id}
|
||||
LOG.info(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 = _("Access denied to image %(id)s but returning 'not found'")
|
||||
LOG.info(msg % {'id': image_id})
|
||||
msg = _LI("Access denied to image %(id)s but returning"
|
||||
" 'not found'") % {'id': image_id}
|
||||
LOG.info(msg)
|
||||
raise webob.exc.HTTPNotFound()
|
||||
|
||||
# Can they manipulate the membership?
|
||||
if not self.is_image_sharable(req.context, image):
|
||||
msg = _("User lacks permission to share image %(id)s")
|
||||
LOG.info(msg % {'id': image_id})
|
||||
msg = (_LI("User lacks permission to share image %(id)s") %
|
||||
{'id': image_id})
|
||||
LOG.info(msg)
|
||||
msg = _("No permission to share that image")
|
||||
raise webob.exc.HTTPForbidden(msg)
|
||||
|
||||
|
@ -304,8 +315,9 @@ class Controller(object):
|
|||
raise webob.exc.HTTPNotFound(explanation=msg)
|
||||
|
||||
# Make an appropriate result
|
||||
msg = _("Successfully deleted a membership from image %(id)s")
|
||||
LOG.info(msg % {'id': image_id})
|
||||
msg = (_LI("Successfully deleted a membership from image %(id)s") %
|
||||
{'id': image_id})
|
||||
LOG.info(msg)
|
||||
return webob.exc.HTTPNoContent()
|
||||
|
||||
def index_shared_images(self, req, id):
|
||||
|
@ -315,13 +327,13 @@ class Controller(object):
|
|||
try:
|
||||
members = self.db_api.image_member_find(req.context, member=id)
|
||||
except exception.NotFound:
|
||||
msg = _("Member %(id)s not found")
|
||||
LOG.info(msg % {'id': id})
|
||||
msg = _LI("Member %(id)s not found") % {'id': id}
|
||||
LOG.info(msg)
|
||||
msg = _("Membership could not be found.")
|
||||
raise webob.exc.HTTPBadRequest(explanation=msg)
|
||||
|
||||
msg = _("Returning list of images shared with member %(id)s")
|
||||
LOG.info(msg % {'id': id})
|
||||
msg = "Returning list of images shared with member %(id)s" % {'id': id}
|
||||
LOG.debug(msg)
|
||||
return dict(shared_images=make_member_list(members,
|
||||
image_id='image_id',
|
||||
can_share='can_share'))
|
||||
|
|
|
@ -21,11 +21,13 @@ the Glance Registry API
|
|||
from glance.common.client import BaseClient
|
||||
from glance.common import crypt
|
||||
from glance.openstack.common import excutils
|
||||
from glance.openstack.common import gettextutils
|
||||
from glance.openstack.common import jsonutils
|
||||
import glance.openstack.common.log as logging
|
||||
from glance.registry.api.v1 import images
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
_LI = gettextutils._LI
|
||||
|
||||
|
||||
class RegistryClient(BaseClient):
|
||||
|
@ -122,8 +124,8 @@ class RegistryClient(BaseClient):
|
|||
except Exception as exc:
|
||||
with excutils.save_and_reraise_exception():
|
||||
exc_name = exc.__class__.__name__
|
||||
LOG.info(_("Registry client request %(method)s %(action)s "
|
||||
"raised %(exc_name)s"),
|
||||
LOG.info(_LI("Registry client request %(method)s %(action)s "
|
||||
"raised %(exc_name)s"),
|
||||
{'method': method, 'action': action,
|
||||
'exc_name': exc_name})
|
||||
return res
|
||||
|
|
|
@ -26,11 +26,15 @@ from glance.common import crypt
|
|||
from glance.common import exception
|
||||
from glance.common import utils
|
||||
from glance import context
|
||||
from glance.openstack.common import gettextutils
|
||||
from glance.openstack.common import lockutils
|
||||
import glance.openstack.common.log as logging
|
||||
import glance.registry.client.v1.api as registry
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
_LE = gettextutils._LE
|
||||
_LI = gettextutils._LI
|
||||
_LW = gettextutils._LW
|
||||
|
||||
scrubber_opts = [
|
||||
cfg.StrOpt('scrubber_datadir',
|
||||
|
@ -134,7 +138,7 @@ class ScrubFileQueue(ScrubQueue):
|
|||
else:
|
||||
break
|
||||
except Exception:
|
||||
LOG.error(_("%s file can not be read.") % file_path)
|
||||
LOG.error(_LE("%s file can not be read.") % file_path)
|
||||
|
||||
return uris, delete_times
|
||||
|
||||
|
@ -158,7 +162,7 @@ class ScrubFileQueue(ScrubQueue):
|
|||
f.write(''.join(lines))
|
||||
os.chmod(file_path, 0o600)
|
||||
except Exception:
|
||||
LOG.error(_("%s file can not be wrote.") % file_path)
|
||||
LOG.error(_LE("%s file can not be wrote.") % file_path)
|
||||
|
||||
def add_location(self, image_id, location, user_context=None):
|
||||
"""Adding image location to scrub queue.
|
||||
|
@ -185,8 +189,8 @@ class ScrubFileQueue(ScrubQueue):
|
|||
if image['status'] == 'deleted':
|
||||
return True
|
||||
except exception.NotFound as e:
|
||||
LOG.error(_("Failed to find image to delete: %s"),
|
||||
utils.exception_to_str(e))
|
||||
LOG.warn(_LW("Failed to find image to delete: %s"),
|
||||
utils.exception_to_str(e))
|
||||
return False
|
||||
|
||||
delete_time = time.time() + self.scrub_time
|
||||
|
@ -220,7 +224,8 @@ class ScrubFileQueue(ScrubQueue):
|
|||
:retval a list of image image_id and location tuple from scrub queue
|
||||
"""
|
||||
if not os.path.exists(self.scrubber_datadir):
|
||||
LOG.info(_("%s directory does not exist.") % self.scrubber_datadir)
|
||||
LOG.info(_LI("%s directory does not exist.") %
|
||||
self.scrubber_datadir)
|
||||
return []
|
||||
|
||||
ret = []
|
||||
|
@ -369,8 +374,8 @@ def get_scrub_queues():
|
|||
|
||||
class Daemon(object):
|
||||
def __init__(self, wakeup_time=300, threads=1000):
|
||||
LOG.info(_("Starting Daemon: wakeup_time=%(wakeup_time)s "
|
||||
"threads=%(threads)s"),
|
||||
LOG.info(_LI("Starting Daemon: wakeup_time=%(wakeup_time)s "
|
||||
"threads=%(threads)s"),
|
||||
{'wakeup_time': wakeup_time, 'threads': threads})
|
||||
self.wakeup_time = wakeup_time
|
||||
self.event = eventlet.event.Event()
|
||||
|
@ -383,7 +388,7 @@ class Daemon(object):
|
|||
try:
|
||||
self.event.wait()
|
||||
except KeyboardInterrupt:
|
||||
msg = _("Daemon Shutdown on KeyboardInterrupt")
|
||||
msg = _LI("Daemon Shutdown on KeyboardInterrupt")
|
||||
LOG.info(msg)
|
||||
|
||||
def _run(self, application):
|
||||
|
@ -395,7 +400,7 @@ class Daemon(object):
|
|||
|
||||
class Scrubber(object):
|
||||
def __init__(self, store_api):
|
||||
LOG.info(_("Initializing scrubber with configuration: %s") %
|
||||
LOG.info(_LI("Initializing scrubber with configuration: %s") %
|
||||
six.text_type({'scrubber_datadir': CONF.scrubber_datadir,
|
||||
'cleanup': CONF.cleanup_scrubber,
|
||||
'cleanup_time': CONF.cleanup_scrubber_time,
|
||||
|
@ -419,7 +424,7 @@ class Scrubber(object):
|
|||
else:
|
||||
image_id_uri_list = queue.get_all_locations()
|
||||
except Exception:
|
||||
LOG.error(_("Can not %s scrub jobs from queue.") %
|
||||
LOG.error(_LE("Can not %s scrub jobs from queue.") %
|
||||
'pop' if pop else 'get')
|
||||
return None
|
||||
|
||||
|
@ -443,7 +448,7 @@ class Scrubber(object):
|
|||
if len(delete_jobs) == 0:
|
||||
return
|
||||
|
||||
LOG.info(_("Scrubbing image %(id)s from %(count)d locations.") %
|
||||
LOG.info(_LI("Scrubbing image %(id)s from %(count)d locations.") %
|
||||
{'id': image_id, 'count': len(delete_jobs)})
|
||||
# NOTE(bourke): The starmap must be iterated to do work
|
||||
list(pool.starmap(self._delete_image_location_from_backend,
|
||||
|
@ -472,8 +477,9 @@ class Scrubber(object):
|
|||
|
||||
self.store_api.delete_from_backend(admin_context, uri)
|
||||
except Exception:
|
||||
msg = _("Failed to delete URI from image %(image_id)s")
|
||||
LOG.error(msg % {'image_id': image_id})
|
||||
msg = (_LE("Failed to delete URI from image %(image_id)s") %
|
||||
{'image_id': image_id})
|
||||
LOG.error(msg)
|
||||
|
||||
def _read_cleanup_file(self, file_path):
|
||||
"""Reading cleanup to get latest cleanup timestamp.
|
||||
|
@ -508,7 +514,7 @@ class Scrubber(object):
|
|||
os.chmod(file_path, 0o600)
|
||||
os.utime(file_path, (cleanup_time, cleanup_time))
|
||||
except Exception:
|
||||
LOG.error(_("%s file can not be created.") %
|
||||
LOG.error(_LE("%s file can not be created.") %
|
||||
six.text_type(file_path))
|
||||
|
||||
def _cleanup(self, pool):
|
||||
|
@ -523,8 +529,8 @@ class Scrubber(object):
|
|||
if cleanup_time > now:
|
||||
return
|
||||
|
||||
LOG.info(_("Getting images deleted before "
|
||||
"%s") % CONF.cleanup_scrubber_time)
|
||||
LOG.info(_LI("Getting images deleted before %s") %
|
||||
CONF.cleanup_scrubber_time)
|
||||
self._update_cleanup_file(cleanup_file, now)
|
||||
|
||||
delete_jobs = self._get_delete_jobs(self.db_queue, False)
|
||||
|
|
Loading…
Reference in New Issue