Cleanup i18n marker functions to match Oslo usage
Define marker functions as per usage in documentation in http://docs.openstack.org/developer/oslo.i18n/usage.html and correct message usage as defined in guidelines at http://docs.openstack.org/developer/oslo.i18n/guidelines.html Co-Authored-By: liang.jingtao@zte.com.cn Change-Id: I564f5d1f31314be5c18420b6bc3d694a561d78f2
This commit is contained in:
parent
7207ffaf61
commit
b985ac4afe
|
@ -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',
|
||||
|
|
|
@ -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:..]:<some_port>
|
||||
|
@ -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)
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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: "
|
||||
|
|
|
@ -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__)
|
||||
|
|
|
@ -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__)
|
||||
|
||||
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue