diff --git a/glance_store/_drivers/filesystem.py b/glance_store/_drivers/filesystem.py index dc89e305..4b0e8045 100644 --- a/glance_store/_drivers/filesystem.py +++ b/glance_store/_drivers/filesystem.py @@ -37,14 +37,11 @@ from glance_store import capabilities from glance_store.common import utils import glance_store.driver from glance_store import exceptions -from glance_store import i18n +from glance_store.i18n import _, _LE, _LW import glance_store.location LOG = logging.getLogger(__name__) -_ = i18n._ -_LE = i18n._LE -_LW = i18n._LW _FILESYSTEM_CONFIGS = [ cfg.StrOpt('filesystem_store_datadir', diff --git a/glance_store/_drivers/http.py b/glance_store/_drivers/http.py index 207b1c9a..985282ad 100644 --- a/glance_store/_drivers/http.py +++ b/glance_store/_drivers/http.py @@ -25,7 +25,7 @@ import requests from glance_store import capabilities import glance_store.driver from glance_store import exceptions -from glance_store.i18n import _ +from glance_store.i18n import _, _LI import glance_store.location LOG = logging.getLogger(__name__) @@ -110,7 +110,7 @@ class StoreLocation(glance_store.location.StoreLocation): else: self.user = None if netloc == '': - LOG.info(_("No address specified in HTTP URL")) + LOG.info(_LI("No address specified in HTTP URL")) raise exceptions.BadStoreUri(uri=uri) else: # IPv6 address has the following format [1223:0:0:..]: @@ -268,7 +268,7 @@ class Store(glance_store.driver.Store): if conn.is_redirect and conn.status_code not in (301, 302): reason = (_("The HTTP URL %(url)s attempted to redirect " - "with an invalid %(status)s status code.") % + "with an invalid %(status)s status code."), {'url': loc.path, 'status': conn.status_code}) LOG.info(reason) raise exceptions.BadStoreUri(message=reason) diff --git a/glance_store/_drivers/rbd.py b/glance_store/_drivers/rbd.py index 78852bf2..c9a1a072 100644 --- a/glance_store/_drivers/rbd.py +++ b/glance_store/_drivers/rbd.py @@ -32,8 +32,7 @@ from glance_store import capabilities from glance_store.common import utils from glance_store import driver from glance_store import exceptions -from glance_store import i18n -from glance_store.i18n import _ +from glance_store.i18n import _, _LE, _LI from glance_store import location try: @@ -50,8 +49,6 @@ DEFAULT_CHUNKSIZE = 8 # in MiB DEFAULT_SNAPNAME = 'snap' LOG = logging.getLogger(__name__) -_LI = i18n._LI -_LE = i18n._LE _RBD_OPTS = [ cfg.IntOpt('rbd_store_chunk_size', default=DEFAULT_CHUNKSIZE, diff --git a/glance_store/_drivers/s3.py b/glance_store/_drivers/s3.py index da451229..499e1e2e 100644 --- a/glance_store/_drivers/s3.py +++ b/glance_store/_drivers/s3.py @@ -36,12 +36,10 @@ from glance_store import capabilities from glance_store.common import utils import glance_store.driver from glance_store import exceptions -from glance_store.i18n import _ +from glance_store.i18n import _, _LE, _LI import glance_store.location LOG = logging.getLogger(__name__) -_LE = glance_store.i18n._LE -_LI = glance_store.i18n._LI DEFAULT_LARGE_OBJECT_SIZE = 100 # 100M DEFAULT_LARGE_OBJECT_CHUNK_SIZE = 10 # 10M diff --git a/glance_store/_drivers/swift/store.py b/glance_store/_drivers/swift/store.py index 01cc4043..8a3b8b9d 100644 --- a/glance_store/_drivers/swift/store.py +++ b/glance_store/_drivers/swift/store.py @@ -43,13 +43,11 @@ from glance_store._drivers.swift import utils as sutils from glance_store import capabilities from glance_store import driver from glance_store import exceptions -from glance_store import i18n +from glance_store.i18n import _, _LE, _LI from glance_store import location -_ = i18n._ LOG = logging.getLogger(__name__) -_LI = i18n._LI DEFAULT_CONTAINER = 'glance' DEFAULT_LARGE_OBJECT_SIZE = 5 * units.Ki # 5GB @@ -307,16 +305,16 @@ def swift_retry_iter(resp_iter, length, store, location, manager): if bytes_read != length: if retries == store.conf.glance_store.swift_store_retry_get_count: # terminate silently and let higher level decide - LOG.error(_("Stopping Swift retries after %d " - "attempts") % retries) + LOG.error(_LE("Stopping Swift retries after %d " + "attempts") % retries) break else: retries += 1 glance_conf = store.conf.glance_store retry_count = glance_conf.swift_store_retry_get_count - LOG.info(_("Retrying Swift connection " - "(%(retries)d/%(max_retries)d) with " - "range=%(start)d-%(end)d") % + LOG.info(_LI("Retrying Swift connection " + "(%(retries)d/%(max_retries)d) with " + "range=%(start)d-%(end)d"), {'retries': retries, 'max_retries': retry_count, 'start': bytes_read, @@ -727,9 +725,9 @@ class BaseStore(driver.Store): except Exception: # Delete orphaned segments from swift backend with excutils.save_and_reraise_exception(): - LOG.exception(_("Error during chunked upload " - "to backend, deleting stale " - "chunks")) + reason = _LE("Error during chunked upload to " + "backend, deleting stale chunks") + LOG.exception(reason) self._delete_stale_chunks( manager.get_connection(), location.container, @@ -1189,7 +1187,8 @@ class MultiTenantStore(BaseStore): default_ref = self.conf.glance_store.default_swift_reference default_swift_reference = ref_params.get(default_ref) if not default_swift_reference: - reason = _("default_swift_reference %s is required.") % default_ref + reason = _("default_swift_reference %s is " + "required."), default_ref LOG.error(reason) raise exceptions.BadStoreConfiguration(message=reason) diff --git a/glance_store/_drivers/swift/utils.py b/glance_store/_drivers/swift/utils.py index e172ebea..97a36124 100644 --- a/glance_store/_drivers/swift/utils.py +++ b/glance_store/_drivers/swift/utils.py @@ -20,44 +20,42 @@ from oslo_config import cfg from six.moves import configparser from glance_store import exceptions -from glance_store import i18n +from glance_store.i18n import _, _LE swift_opts = [ cfg.StrOpt('default_swift_reference', default="ref1", - help=i18n._('The reference to the default swift account/backing' - ' store parameters to use for adding new images.')), + help=_('The reference to the default swift account/backing' + ' store parameters to use for adding new images.')), cfg.StrOpt('swift_store_auth_version', default='2', - help=i18n._('Version of the authentication service to use. ' - 'Valid versions are 2 and 3 for keystone and 1 ' - '(deprecated) for swauth and rackspace.'), + help=_('Version of the authentication service to use. ' + 'Valid versions are 2 and 3 for keystone and 1 ' + '(deprecated) for swauth and rackspace.'), deprecated_for_removal=True, - deprecated_reason=i18n._('Use "auth_version" in ' - 'swift_store_config_file.') - ), + deprecated_reason=_('Use "auth_version" in ' + 'swift_store_config_file.')), cfg.StrOpt('swift_store_auth_address', - help=i18n._('The address where the Swift authentication ' - 'service is listening.'), + help=_('The address where the Swift authentication ' + 'service is listening.'), deprecated_for_removal=True, - deprecated_reason=i18n._('Use "auth_address" in ' - 'swift_store_config_file') - ), + deprecated_reason=_('Use "auth_address" in ' + 'swift_store_config_file')), cfg.StrOpt('swift_store_user', secret=True, - help=i18n._('The user to authenticate against the Swift ' - 'authentication service.'), + help=_('The user to authenticate against the Swift ' + 'authentication service.'), deprecated_for_removal=True, - deprecated_reason=i18n._('Use "user" in ' - 'swift_store_config_file.')), + deprecated_reason=_('Use "user" in ' + 'swift_store_config_file.')), cfg.StrOpt('swift_store_key', secret=True, - help=i18n._('Auth key for the user authenticating against the ' - 'Swift authentication service.'), + help=_('Auth key for the user authenticating against the ' + 'Swift authentication service.'), deprecated_for_removal=True, - deprecated_reason=i18n._('Use "key" in ' - 'swift_store_config_file.') + deprecated_reason=_('Use "key" in ' + 'swift_store_config_file.') ), cfg.StrOpt('swift_store_config_file', secret=True, - help=i18n._('The config file that has the swift account(s)' - 'configs.')), + help=_('The config file that has the swift account(s)' + 'configs.')), ] _config_defaults = {'user_domain_id': 'default', @@ -113,8 +111,8 @@ class SwiftParams(object): conf_file = self.conf.find_file(scf) CONFIG.read(conf_file) except Exception as e: - msg = (i18n._("swift config file " - "%(conf)s:%(exc)s not found") % + msg = (_("swift config file " + "%(conf)s:%(exc)s not found"), {'conf': self.conf.glance_store.swift_store_config_file, 'exc': e}) LOG.error(msg) @@ -143,6 +141,5 @@ class SwiftParams(object): account_params[ref] = reference except (ValueError, SyntaxError, configparser.NoOptionError) as e: - LOG.exception(i18n._("Invalid format of swift store config" - "cfg")) + LOG.exception(_LE("Invalid format of swift store config cfg")) return account_params diff --git a/glance_store/backend.py b/glance_store/backend.py index 2320e458..0cf01e35 100644 --- a/glance_store/backend.py +++ b/glance_store/backend.py @@ -23,15 +23,13 @@ from stevedore import extension from glance_store import capabilities from glance_store import exceptions -from glance_store import i18n +from glance_store.i18n import _ from glance_store import location CONF = cfg.CONF LOG = logging.getLogger(__name__) -_ = i18n._ - _STORE_OPTS = [ cfg.ListOpt('stores', default=['file', 'http'], help=_("List of stores enabled. Valid stores are: " diff --git a/glance_store/capabilities.py b/glance_store/capabilities.py index 8da8ce3a..d6963dab 100644 --- a/glance_store/capabilities.py +++ b/glance_store/capabilities.py @@ -24,9 +24,8 @@ from eventlet import tpool from oslo_utils import reflection from glance_store import exceptions -from glance_store import i18n +from glance_store.i18n import _LW -_LW = i18n._LW _STORE_CAPABILITES_UPDATE_SCHEDULING_BOOK = {} _STORE_CAPABILITES_UPDATE_SCHEDULING_LOCK = threading.Lock() LOG = logging.getLogger(__name__) diff --git a/glance_store/driver.py b/glance_store/driver.py index 9e805cdf..45f69ce3 100644 --- a/glance_store/driver.py +++ b/glance_store/driver.py @@ -25,9 +25,8 @@ from oslo_utils import units from glance_store import capabilities from glance_store import exceptions -from glance_store import i18n +from glance_store.i18n import _ -_ = i18n._ LOG = logging.getLogger(__name__) diff --git a/glance_store/exceptions.py b/glance_store/exceptions.py index fe59630d..e6b19a4e 100644 --- a/glance_store/exceptions.py +++ b/glance_store/exceptions.py @@ -20,9 +20,8 @@ import six import six.moves.urllib.parse as urlparse import warnings -from glance_store import i18n +from glance_store.i18n import _ warnings.simplefilter('always') -_ = i18n._ class BackendException(Exception):