if os.path.exists(os.path.join(possible_topdir, "cinder", "__init__.py")):
sys.path.insert(0, possible_topdir)
-from cinder.openstack.common import gettextutils
-gettextutils.enable_lazy()
+from cinder import i18n
+i18n.enable_lazy()
# Need to register global_opts
from cinder.common import config # noqa
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder import service
from cinder import utils
if os.path.exists(os.path.join(possible_topdir, "cinder", "__init__.py")):
sys.path.insert(0, possible_topdir)
-from cinder.openstack.common import gettextutils
-gettextutils.enable_lazy()
+from cinder import i18n
+i18n.enable_lazy()
# Need to register global_opts
from cinder.common import config # noqa
if os.path.exists(os.path.join(possible_topdir, 'cinder', '__init__.py')):
sys.path.insert(0, possible_topdir)
-from cinder.openstack.common import gettextutils
-gettextutils.enable_lazy()
+from cinder import i18n
+i18n.enable_lazy()
# Need to register global_opts
from cinder.common import config # noqa
if os.path.exists(os.path.join(POSSIBLE_TOPDIR, 'cinder', '__init__.py')):
sys.path.insert(0, POSSIBLE_TOPDIR)
-from cinder.openstack.common import gettextutils
-gettextutils.enable_lazy()
+from cinder import i18n
+i18n.enable_lazy()
# Need to register global_opts
from cinder.common import config # noqa
from cinder import context
from cinder import db
from cinder.db import migration
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder.openstack.common import uuidutils
from cinder import rpc
import rtslib
-from cinder.openstack.common import gettextutils
-from cinder.openstack.common.gettextutils import _
+from cinder import i18n
+from cinder.i18n import _
-gettextutils.install('cinder')
-gettextutils.enable_lazy()
+i18n.enable_lazy()
class RtstoolError(Exception):
if os.path.exists(os.path.join(possible_topdir, 'cinder', '__init__.py')):
sys.path.insert(0, possible_topdir)
-from cinder.openstack.common import gettextutils
-gettextutils.enable_lazy()
+from cinder import i18n
+i18n.enable_lazy()
# Need to register global_opts
from cinder.common import config # noqa
if os.path.exists(os.path.join(possible_topdir, 'cinder', '__init__.py')):
sys.path.insert(0, possible_topdir)
-from cinder.openstack.common import gettextutils
-gettextutils.enable_lazy()
+from cinder import i18n
+i18n.enable_lazy()
# Need to register global_opts
from cinder.common import config # noqa
if os.path.exists(os.path.join(POSSIBLE_TOPDIR, 'cinder', '__init__.py')):
sys.path.insert(0, POSSIBLE_TOPDIR)
-from cinder.openstack.common import gettextutils
-gettextutils.enable_lazy()
+from cinder import i18n
+i18n.enable_lazy()
from cinder import context
from cinder import db
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder import rpc
from cinder import utils
# under the License.
from cinder.api.middleware import auth
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder.api.openstack import wsgi
from cinder.api import xmlutil
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder import utils
from cinder.api.openstack import wsgi
from cinder import db
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder.openstack.common import strutils
from cinder import rpc
from cinder.api import xmlutil
from cinder import backup as backupAPI
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder import utils
from cinder.api.openstack import wsgi
from cinder.api import xmlutil
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder import volume
from cinder.api import xmlutil
from cinder import db
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder.openstack.common import timeutils
from cinder import utils
from cinder.api.views import qos_specs as view_qos_specs
from cinder.api import xmlutil
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder.openstack.common import strutils
from cinder import rpc
from cinder.api import xmlutil
from cinder import db
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder import quota
from cinder import db
from cinder.db.sqlalchemy import api as sqlalchemy_api
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import strutils
from cinder import quota
from cinder.api import extensions
from cinder.api.openstack import wsgi
from cinder.api.v2 import volumes
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
LOG = logging.getLogger(__name__)
from cinder.api import xmlutil
from cinder import db
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder.openstack.common import timeutils
from cinder import utils
from cinder.api import extensions
from cinder.api.openstack import wsgi
from cinder import db
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
LOG = logging.getLogger(__name__)
from cinder.api import xmlutil
from cinder import db
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder import rpc
from cinder.volume import volume_types
from cinder.api.v1 import types
from cinder.api.views import types as views_types
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder import rpc
from cinder.volume import volume_types
from cinder.api.openstack import wsgi
from cinder.api import xmlutil
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder.openstack.common import strutils
from cinder import utils
from cinder.api.v2.views import volumes as volume_views
from cinder.api.v2 import volumes
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder.openstack.common import uuidutils
from cinder import utils
from cinder.api import xmlutil
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder import transfer as transferAPI
from cinder import utils
from cinder.api import xmlutil
from cinder import db
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder import rpc
from cinder.volume import volume_types
from cinder.api import extensions
from cinder.api.openstack import wsgi
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder import volume
from cinder.api.openstack import wsgi
from cinder.api import xmlutil
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import importutils
from cinder.openstack.common import log as logging
import cinder.policy
from cinder.api.openstack import wsgi
from cinder import context
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import jsonutils
from cinder.openstack.common import log as logging
from cinder.openstack.common.middleware import request_id
from cinder.api.openstack import wsgi
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder import utils
from cinder import wsgi as base_wsgi
import webob.dec
import webob.exc
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder import wsgi
import routes
from cinder.api.openstack import wsgi
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder import wsgi as base_wsgi
# under the License.
from cinder.api import urlmap
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
# under the License.
from cinder.api.v1.router import APIRouter as v1_router
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
LOG = logging.getLogger(__name__)
# under the License.
from cinder.api import versions
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from xml.parsers import expat
from cinder import exception
-from cinder.openstack.common import gettextutils
-from cinder.openstack.common.gettextutils import _
+from cinder import i18n
+from cinder.i18n import _
from cinder.openstack.common import jsonutils
from cinder.openstack.common import log as logging
from cinder import utils
"""
if not self.accept_language:
return None
- all_languages = gettextutils.get_available_languages('cinder')
+ all_languages = i18n.get_available_languages()
return self.accept_language.best_match(all_languages)
fault_data = {
fault_name: {
'code': code,
- 'message': gettextutils.translate(explanation, locale)}}
+ 'message': i18n.translate(explanation, locale)}}
if code == 413:
retry = self.wrapped_exc.headers.get('Retry-After', None)
if retry:
def translate(msg):
locale = request.best_match_language()
- return gettextutils.translate(msg, locale)
+ return i18n.translate(msg, locale)
self.content['overLimitFault']['message'] = \
translate(self.content['overLimitFault']['message'])
# under the License.
from cinder.api.middleware import sizelimit
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
LOG = logging.getLogger(__name__)
from cinder.api.openstack import wsgi
from cinder.api.views import limits as limits_views
from cinder.api import xmlutil
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import importutils
from cinder.openstack.common import jsonutils
from cinder import quota
from cinder.api import common
from cinder.api.openstack import wsgi
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder import volume
from webob import exc
from cinder.api.openstack import wsgi
from cinder.api import xmlutil
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder.openstack.common import strutils
from cinder import utils
from cinder.api import common
from cinder.api.openstack import wsgi
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder import volume
from webob import exc
from cinder.api.openstack import wsgi
from cinder.api import xmlutil
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder.openstack.common import uuidutils
from cinder import utils
from cinder.api.openstack import wsgi
from cinder.api.views import limits as limits_views
from cinder.api import xmlutil
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import importutils
from cinder.openstack.common import jsonutils
from cinder import quota
from cinder.api import common
from cinder.api.openstack import wsgi
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder import volume
from webob import exc
from cinder.api.openstack import wsgi
from cinder.api import xmlutil
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder.openstack.common import strutils
from cinder import utils
from cinder.api.views import types as views_types
from cinder.api import xmlutil
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.volume import volume_types
from cinder.api import common
from cinder.api.openstack import wsgi
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder import volume
from cinder.api.v2.views import volumes as volume_views
from cinder.api import xmlutil
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder.openstack.common import uuidutils
from cinder import utils
from lxml import etree
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder import utils
from cinder import context
from cinder.db import base
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder import utils
from cinder.db import base
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import jsonutils
from cinder.openstack.common import log as logging
from oslo.config import cfg
from cinder.backup.driver import BackupDriver
from cinder import exception
+from cinder.i18n import _
from cinder.openstack.common import excutils
-from cinder.openstack.common.gettextutils import _
from cinder.openstack.common import log as logging
from cinder.openstack.common import strutils
from cinder.openstack.common import units
from cinder.backup.driver import BackupDriver
from cinder import exception
+from cinder.i18n import _
from cinder.openstack.common import excutils
-from cinder.openstack.common.gettextutils import _
from cinder.openstack.common import log as logging
from cinder.openstack.common import timeutils
from cinder.openstack.common import units
from cinder.backup.driver import BackupDriver
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder.openstack.common import processutils
from cinder import utils
from cinder.backup import rpcapi as backup_rpcapi
from cinder import context
from cinder import exception
+from cinder.i18n import _
from cinder import manager
from cinder.openstack.common import excutils
-from cinder.openstack.common.gettextutils import _
from cinder.openstack.common import importutils
from cinder.openstack.common import log as logging
from cinder import utils
"""Exceptions for the Brick library."""
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder.brick.initiator import linuxfc
from cinder.brick.initiator import linuxscsi
from cinder.brick.remotefs import remotefs
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import lockutils
from cinder.openstack.common import log as logging
from cinder.openstack.common import loopingcall
import errno
from cinder.brick.initiator import linuxscsi
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder.openstack.common import processutils as putils
import os
from cinder.brick import executor
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder.openstack.common import processutils as putils
from cinder.brick import exception
from cinder.brick import executor
+from cinder.i18n import _
from cinder.openstack.common import fileutils
-from cinder.openstack.common.gettextutils import _
from cinder.openstack.common import log as logging
from cinder.openstack.common import processutils as putils
from cinder.brick import exception
from cinder.brick import executor
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder.openstack.common import processutils as putils
import six
from cinder.brick import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder.openstack.common import processutils as putils
from oslo.config import cfg
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
CONF = cfg.CONF
import sqlalchemy
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
import copy
import uuid
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import local
from cinder.openstack.common import log as logging
from cinder.openstack.common import timeutils
from cinder.common import sqlalchemyutils
from cinder.db.sqlalchemy import models
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder.openstack.common import timeutils
from cinder.openstack.common import uuidutils
from oslo.config import cfg
-from cinder.openstack.common import gettextutils
-gettextutils.enable_lazy()
+from cinder import i18n
+i18n.enable_lazy()
from cinder.db.sqlalchemy import migrate_repo
from cinder import version
from sqlalchemy import Boolean, Column, DateTime, ForeignKey
from sqlalchemy import Integer, MetaData, String, Table
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from sqlalchemy import Boolean, Column, DateTime
from sqlalchemy import MetaData, Integer, String, Table, ForeignKey
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
LOG = logging.getLogger(__name__)
from sqlalchemy import Column, DateTime, Text, Boolean
from sqlalchemy import MetaData, Integer, String, Table, ForeignKey
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
LOG = logging.getLogger(__name__)
from sqlalchemy import Boolean, Column, DateTime
from sqlalchemy import MetaData, Integer, String, Table
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
LOG = logging.getLogger(__name__)
from sqlalchemy import Boolean, Column, DateTime
from sqlalchemy import Integer, MetaData, String, Table, ForeignKey
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
LOG = logging.getLogger(__name__)
from sqlalchemy import Boolean, Column, DateTime
from sqlalchemy import MetaData, String, Table, ForeignKey
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
LOG = logging.getLogger(__name__)
from sqlalchemy import Boolean, Column, DateTime, Integer
from sqlalchemy import MetaData, String, Table
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
LOG = logging.getLogger(__name__)
from sqlalchemy import Boolean, Column, DateTime, ForeignKey
from sqlalchemy import Integer, MetaData, String, Table
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
LOG = logging.getLogger(__name__)
from sqlalchemy import Column, ForeignKey, MetaData, Table
from sqlalchemy import Boolean, DateTime, Integer, String
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from sqlalchemy import ForeignKey, MetaData, String, Table
from migrate import ForeignKeyConstraint
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
LOG = logging.getLogger(__name__)
from sqlalchemy import Boolean, Column, DateTime
from sqlalchemy import Integer, MetaData, String, Table, ForeignKey
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
LOG = logging.getLogger(__name__)
import datetime
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from oslo.config import cfg
from sqlalchemy import MetaData, Table
from sqlalchemy import Index, MetaData, Table
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
LOG = logging.getLogger(__name__)
from cinder.db.sqlalchemy.api import get_engine
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
INIT_VERSION = 000
_REPOSITORY = None
from oslo.config import cfg
import webob.exc
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from taskflow import task
from taskflow.utils import misc
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
LOG = logging.getLogger(__name__)
--- /dev/null
+# Copyright 2014 IBM Corp.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+"""oslo.i18n integration module.
+
+See http://docs.openstack.org/developer/oslo.i18n/usage.html .
+
+"""
+
+from oslo import i18n
+
+from cinder.openstack.common import gettextutils
+
+DOMAIN = 'cinder'
+
+_translators = i18n.TranslatorFactory(domain=DOMAIN)
+
+# The primary translation function using the well-known name "_"
+_ = _translators.primary
+
+# Translators for log levels.
+#
+# The abbreviated names are meant to reflect the usual use of a short
+# name like '_'. The "L" is for "log" and the other letter comes from
+# the level.
+_LI = _translators.log_info
+_LW = _translators.log_warning
+_LE = _translators.log_error
+_LC = _translators.log_critical
+
+
+def enable_lazy():
+ return i18n.enable_lazy()
+
+
+def translate(value, user_locale=None):
+ return i18n.translate(value, user_locale)
+
+
+def get_available_languages():
+ return i18n.get_available_languages(DOMAIN)
+
+
+# Parts in oslo-incubator are still using gettextutils._(), _LI(), etc., from
+# oslo-incubator. Until these parts are changed to use oslo.i18n, Cinder
+# needs to do something to allow them to work. One option is to continue to
+# initialize gettextutils, but with the way that Cinder has initialization
+# spread out over mutltiple entry points, we'll monkey-patch
+# gettextutils._(), _LI(), etc., to use our oslo.i18n versions.
+
+# FIXME(dims): Remove the monkey-patching and update openstack-common.conf and
+# do a sync with oslo-incubator to remove gettextutils once oslo-incubator
+# isn't using oslo-incubator gettextutils any more.
+
+gettextutils._ = _
+gettextutils._LI = _LI
+gettextutils._LW = _LW
+gettextutils._LE = _LE
+gettextutils._LC = _LC
import six.moves.urllib.parse as urlparse
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import jsonutils
from cinder.openstack.common import log as logging
from cinder.openstack.common import timeutils
from oslo.config import cfg
from cinder import exception
+from cinder.i18n import _
from cinder.openstack.common import fileutils
-from cinder.openstack.common.gettextutils import _
from cinder.openstack.common import imageutils
from cinder.openstack.common import log as logging
from cinder.openstack.common import processutils
from oslo.config import cfg
from cinder import exception
+from cinder.i18n import _
from cinder.keymgr import key
from cinder.keymgr import key_mgr
-from cinder.openstack.common.gettextutils import _
from cinder.openstack.common import log as logging
from oslo.config import cfg
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import policy
from cinder import utils
from cinder import context
from cinder import db
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import importutils
from cinder.openstack.common import log as logging
from cinder.openstack.common import timeutils
# under the License.
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder import quota
from oslo.config import cfg
from cinder import db
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import importutils
from cinder.openstack.common import timeutils
from cinder.volume import rpcapi as volume_rpcapi
from oslo.config import cfg
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder.scheduler import driver
from cinder.scheduler import scheduler_options
import math
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder.openstack.common.scheduler import filters
from cinder import exception
from cinder import flow_utils
+from cinder.i18n import _
from cinder.openstack.common import excutils
-from cinder.openstack.common.gettextutils import _
from cinder.openstack.common import log as logging
from cinder import rpc
from cinder import utils
from cinder import db
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder.openstack.common.scheduler import filters
from cinder.openstack.common.scheduler import weights
from cinder import db
from cinder import exception
from cinder import flow_utils
+from cinder.i18n import _
from cinder import manager
from cinder.openstack.common import excutils
-from cinder.openstack.common.gettextutils import _
from cinder.openstack.common import importutils
from cinder.openstack.common import log as logging
from cinder import quota
from oslo.config import cfg
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder.openstack.common import timeutils
from cinder import context
from cinder import db
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import importutils
from cinder.openstack.common import log as logging
from cinder.openstack.common import loopingcall
import paramiko
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
LOG = logging.getLogger(__name__)
from cinder import context
from cinder import db
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder.openstack.common import timeutils
from cinder import test
import gettext
import mock
+from oslo.i18n import _lazy
import webob.dec
import webob.exc
from cinder.api import common
from cinder.api.openstack import wsgi
from cinder import exception
-from cinder.openstack.common import gettextutils
+from cinder import i18n as cinder_i18n
+from cinder.i18n import _
from cinder.openstack.common import jsonutils
from cinder import test
class TestFaults(test.TestCase):
"""Tests covering `cinder.api.openstack.faults:Fault` class."""
+ def setUp(self):
+ super(TestFaults, self).setUp()
+ back_use_lazy = _lazy.USE_LAZY
+ cinder_i18n.enable_lazy()
+ self.addCleanup(self._restore_use_lazy, back_use_lazy)
+
+ def _restore_use_lazy(self, back_use_lazy):
+ _lazy.USE_LAZY = back_use_lazy
+
def _prepare_xml(self, xml_string):
"""Remove characters from string which hinder XML equality testing."""
xml_string = xml_string.replace(" ", "")
self.assertNotIn('resizeNotAllowed', resp.body)
self.assertIn('forbidden', resp.body)
- def test_raise_http_with_localized_explanation(self):
+ @mock.patch('cinder.api.openstack.wsgi.i18n.translate')
+ def test_raise_http_with_localized_explanation(self, mock_translate):
params = ('blah', )
- expl = gettextutils.Message("String with params: %s" % params, 'test')
+ expl = _("String with params: %s") % params
def _mock_translation(msg, locale):
return "Mensaje traducido"
- self.stubs.Set(gettextutils,
- "translate", _mock_translation)
+ mock_translate.side_effect = _mock_translation
@webob.dec.wsgify
def raiser(req):
self.assertIn(("Mensaje traducido"), resp.body)
self.stubs.UnsetAll()
- @mock.patch('cinder.openstack.common.gettextutils.gettext.translation')
+ @mock.patch('oslo.i18n._message.gettext.translation')
def test_raise_invalid_with_localized_explanation(self, mock_translation):
- msg_template = gettextutils.Message("Invalid input: %(reason)s", "")
- reason = gettextutils.Message("Value is invalid", "")
+ msg_template = _("Invalid input: %(reason)s")
+ reason = _("Value is invalid")
class MockESTranslations(gettext.GNUTranslations):
def ugettext(self, msgid):
return "El valor es invalido"
return msgid
+ def gettext(self, msgid):
+ return self.ugettext(msgid)
+
def translation(domain, localedir=None, languages=None, fallback=None):
return MockESTranslations()
from cinder.brick import exception
from cinder.brick.initiator import connector
from cinder.brick.initiator import host_driver
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder.openstack.common import loopingcall
from cinder.openstack.common import processutils as putils
from cinder.brick import exception
from cinder.brick.remotefs import remotefs
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder import test
# License for the specific language governing permissions and limitations
# under the License.
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder.tests.brick.fake_lvm import FakeBrickLVM
from cinder.volume import driver
import six.moves.urllib.parse as urlparse
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import jsonutils
from cinder.openstack.common import log as logging
from cinder import context
from cinder import db
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import jsonutils
from cinder.openstack.common import log as logging
from cinder.openstack.common import processutils
from cinder import context
from cinder import db
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder import test
from cinder.tests.backup.fake_swift_client import FakeSwiftClient
from cinder import context
from cinder import db
from cinder import exception
+from cinder.i18n import _
from cinder.image import image_utils
-from cinder.openstack.common.gettextutils import _
from cinder.openstack.common import imageutils
from cinder.openstack.common import processutils as putils
from cinder.openstack.common import units
from oslo.config import cfg
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder import test
from cinder.volume import configuration as conf
from cinder.volume.drivers.ibm import xiv_ds8k
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder import test
import six
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder import test
from cinder.volume import configuration as conf
from cinder import context
from cinder import exception
+from cinder.i18n import _
from cinder.image import image_utils
-from cinder.openstack.common.gettextutils import _
from cinder.openstack.common import log as logging
from cinder import test
from cinder.volume import configuration as conf
from cinder import db
from cinder import exception
+from cinder.i18n import _
from cinder.image import image_utils
-from cinder.openstack.common.gettextutils import _
from cinder.openstack.common import log as logging
from cinder.openstack.common import timeutils
from cinder.openstack.common import units
from cinder import context
from cinder import exception
+from cinder.i18n import _
from cinder.openstack.common import excutils
-from cinder.openstack.common.gettextutils import _
from cinder.openstack.common import importutils
from cinder.openstack.common import log as logging
from cinder.openstack.common import processutils
from cinder.db.sqlalchemy import api as db_api
from cinder.db.sqlalchemy import models
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder import test
from cinder.tests import conf_fixture
import urllib2
from oslo.config import cfg
+from oslo.i18n import _lazy
import testtools
import webob
import webob.dec
from cinder import exception
-from cinder.openstack.common import gettextutils
+from cinder import i18n
+from cinder.i18n import _
from cinder import test
import cinder.wsgi
class ExceptionTest(test.TestCase):
+ def setUp(self):
+ super(ExceptionTest, self).setUp()
+ back_use_lazy = _lazy.USE_LAZY
+ i18n.enable_lazy()
+ self.addCleanup(self._restore_use_lazy, back_use_lazy)
+
+ def _restore_use_lazy(self, back_use_lazy):
+ _lazy.USE_LAZY = back_use_lazy
+
def _wsgi_app(self, inner_app):
# NOTE(luisg): In order to test localization, we need to
# make sure the lazy _() is installed in the 'fault' module
# also we don't want to install the _() system-wide and
# potentially break other test cases, so we do it here for this
# test suite only.
- gettextutils.install('')
- gettextutils.enable_lazy()
from cinder.api.middleware import fault
return fault.FaultWrapper(inner_app)
resp = webob.Request.blank('/').get_response(api)
self.assertEqual(500, resp.status_int)
- @mock.patch('cinder.openstack.common.gettextutils.translate')
+ @mock.patch('cinder.i18n.translate')
def test_cinder_exception_with_localized_explanation(self, mock_t9n):
msg = 'My Not Found'
msg_translation = 'Mi No Encontrado'
- message = gettextutils.Message(msg, '')
+ message = _(msg) # noqa
@webob.dec.wsgify
def fail(req):
# Test response with localization
def mock_translate(msgid, locale):
- if isinstance(msgid, gettextutils.Message):
- return msg_translation
- return msgid
+ return msg_translation
mock_t9n.side_effect = mock_translate
from oslo.config import cfg
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import importutils
from cinder.openstack.common import log as logging
from cinder import test
from cinder.db import base
from cinder import exception
+from cinder.i18n import _
from cinder.openstack.common import excutils
-from cinder.openstack.common.gettextutils import _
from cinder.openstack.common import log as logging
from cinder import quota
from cinder.volume import api as volume_api
from cinder.brick.initiator import connector
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import importutils
from cinder.openstack.common import lockutils
from cinder.openstack.common import log as logging
from cinder.db import base
from cinder import exception
from cinder import flow_utils
+from cinder.i18n import _
from cinder.image import glance
from cinder import keymgr
from cinder.openstack.common import excutils
-from cinder.openstack.common.gettextutils import _
from cinder.openstack.common import log as logging
from cinder.openstack.common import timeutils
from cinder.openstack.common import uuidutils
from oslo.config import cfg
from cinder import exception
+from cinder.i18n import _
from cinder.image import image_utils
from cinder.openstack.common import excutils
from cinder.openstack.common import fileutils
-from cinder.openstack.common.gettextutils import _
from cinder.openstack.common import log as logging
from cinder.openstack.common import processutils
from cinder import utils
from cinder import context
from cinder.db.sqlalchemy import api
from cinder import exception
+from cinder.i18n import _
from cinder.image import image_utils
-from cinder.openstack.common.gettextutils import _
from cinder.openstack.common import log as logging
from cinder.volume import driver
from cinder.volume import utils as volutils
import six.moves.urllib.parse as urlparse
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import jsonutils
from cinder.openstack.common import lockutils
from cinder.openstack.common import log as logging
from xml.dom.minidom import parseString
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder.openstack.common import units
from cinder.volume import volume_types
from cinder import context
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder.volume import driver
from cinder.volume.drivers.emc import emc_smis_common
from cinder import exception
from cinder.exception import EMCVnxCLICmdError
+from cinder.i18n import _
from cinder.openstack.common import excutils
-from cinder.openstack.common.gettextutils import _
from cinder.openstack.common import jsonutils as json
from cinder.openstack.common import lockutils
from cinder.openstack.common import log as logging
from oslo.config import cfg
from cinder import exception
+from cinder.i18n import _
from cinder.openstack.common import excutils
-from cinder.openstack.common.gettextutils import _
from cinder.openstack.common import log as logging
from cinder.openstack.common import processutils
from cinder import ssh_utils
from cinder import compute
from cinder import db
from cinder import exception
+from cinder.i18n import _
from cinder.image import image_utils
from cinder.openstack.common import fileutils
-from cinder.openstack.common.gettextutils import _
from cinder.openstack.common import log as logging
from cinder.openstack.common import processutils
from cinder.openstack.common import units
from xml.etree import ElementTree as ETree
from cinder import exception
+from cinder.i18n import _
from cinder.openstack.common import excutils
-from cinder.openstack.common.gettextutils import _
from cinder.openstack.common import log as logging
from cinder import utils
from cinder.volume import driver
from xml.etree import ElementTree as ETree
from cinder import exception
+from cinder.i18n import _
from cinder.openstack.common import excutils
-from cinder.openstack.common.gettextutils import _
from cinder.openstack.common import log as logging
from cinder.openstack.common import units
from cinder.volume import driver
from xml.etree import ElementTree as ETree
from cinder import exception
+from cinder.i18n import _
from cinder.image import image_utils
from cinder.openstack.common import excutils
-from cinder.openstack.common.gettextutils import _
from cinder.openstack.common import log as logging
from cinder.openstack.common import processutils
from cinder.openstack.common import units
from oslo.config import cfg
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder.volume.drivers.huawei import huawei_dorado
from cinder.volume.drivers.huawei import huawei_hvs
import time
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder.volume import driver
from cinder.volume.drivers.huawei import huawei_utils
from xml.etree import ElementTree as ET
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
LOG = logging.getLogger(__name__)
from cinder import context
from cinder import exception
+from cinder.i18n import _
from cinder.openstack.common import excutils
-from cinder.openstack.common.gettextutils import _
from cinder.openstack.common import log as logging
from cinder.openstack.common import units
from cinder import utils
from cinder import context
from cinder import exception
+from cinder.i18n import _
from cinder.openstack.common import excutils
-from cinder.openstack.common.gettextutils import _
from cinder.openstack.common import log as logging
from cinder import ssh_utils
from cinder import utils
from oslo.config import cfg
from cinder import exception
+from cinder.i18n import _
from cinder.image import image_utils
from cinder.openstack.common import fileutils
-from cinder.openstack.common.gettextutils import _
from cinder.openstack.common import log as logging
from cinder.openstack.common import processutils
from cinder.openstack.common import units
from oslo.config import cfg
from cinder import exception
+from cinder.i18n import _
from cinder.image import image_utils
-from cinder.openstack.common.gettextutils import _
from cinder.openstack.common import log as logging
from cinder.openstack.common import processutils
from cinder.openstack.common import units
from cinder import context
from cinder import exception
+from cinder.i18n import _
from cinder.openstack.common import excutils
-from cinder.openstack.common.gettextutils import _
from cinder.openstack.common import log as logging
from cinder.openstack.common import loopingcall
from cinder.openstack.common import units
from cinder import context
from cinder import exception
+from cinder.i18n import _
from cinder.openstack.common import excutils
-from cinder.openstack.common.gettextutils import _
from cinder.openstack.common import log as logging
from cinder.openstack.common import loopingcall
from cinder.openstack.common import strutils
import re
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder.openstack.common import processutils
from cinder.brick import exception as brick_exception
from cinder.brick.local_dev import lvm as lvm
from cinder import exception
+from cinder.i18n import _
from cinder.image import image_utils
from cinder.openstack.common import fileutils
-from cinder.openstack.common.gettextutils import _
from cinder.openstack.common import log as logging
from cinder.openstack.common import processutils
from cinder.openstack.common import units
from lxml import etree
import urllib2
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
LOG = logging.getLogger(__name__)
"""
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import importutils
from cinder.openstack.common import log as logging
from cinder.volume import driver
import six.moves.urllib.parse as urlparse
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from oslo.config import cfg
from cinder import exception
+from cinder.i18n import _
from cinder.openstack.common import excutils
-from cinder.openstack.common.gettextutils import _
from cinder.openstack.common import log as logging
from cinder.openstack.common import units
from cinder import utils as cinder_utils
import uuid
from cinder import exception
+from cinder.i18n import _
from cinder.openstack.common import excutils
-from cinder.openstack.common.gettextutils import _
from cinder.openstack.common import log as logging
from cinder.openstack.common import timeutils
from cinder.openstack.common import units
import six.moves.urllib.parse as urlparse
from cinder import exception
+from cinder.i18n import _
from cinder.image import image_utils
from cinder.openstack.common import excutils
-from cinder.openstack.common.gettextutils import _
from cinder.openstack.common import log as logging
from cinder.openstack.common import processutils
from cinder.openstack.common import units
from threading import Timer
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder.openstack.common import timeutils
from cinder import utils
from cinder import context
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder.openstack.common import timeutils
from cinder import utils
"""
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder.volume import driver
from cinder.volume.drivers import nexenta
import urllib2
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import jsonutils
from cinder.openstack.common import log as logging
from cinder.volume.drivers import nexenta
from cinder import context
from cinder import db
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder.openstack.common import units
from cinder.volume.drivers import nexenta
import six.moves.urllib.parse as urlparse
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import units
from cinder.brick.remotefs import remotefs
from cinder import exception
+from cinder.i18n import _
from cinder.image import image_utils
-from cinder.openstack.common.gettextutils import _
from cinder.openstack.common import log as logging
from cinder.openstack.common import processutils as putils
from cinder.openstack.common import units
from suds import client
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder.openstack.common import units
from cinder.volume.drivers.san.san import SanISCSIDriver
from oslo.config import cfg
from cinder import exception
+from cinder.i18n import _
from cinder.openstack.common import excutils
-from cinder.openstack.common.gettextutils import _
from cinder.openstack.common import log as logging
from cinder.openstack.common import processutils
from cinder.openstack.common import units
from oslo.config import cfg
from cinder import exception
+from cinder.i18n import _
from cinder.image import image_utils
from cinder.openstack.common import fileutils
-from cinder.openstack.common.gettextutils import _
from cinder.openstack.common import log as logging
from cinder.openstack.common import strutils
from cinder.openstack.common import units
from cinder import context
from cinder import exception
from cinder import flow_utils
+from cinder.i18n import _
from cinder.openstack.common import excutils
-from cinder.openstack.common.gettextutils import _
from cinder.openstack.common import log as logging
from cinder.openstack.common import loopingcall
from cinder.openstack.common import units
except ImportError:
hpexceptions = None
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder import utils
import cinder.volume.driver
hpexceptions = None
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder import utils
import cinder.volume.driver
from lxml import etree
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder.openstack.common import processutils
from cinder.openstack.common import units
LeftHand array.
"""
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder import utils
from cinder.volume.driver import VolumeDriver
from cinder import context
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder.openstack.common import units
from cinder.volume.driver import ISCSIDriver
from oslo.config import cfg
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder.volume.drivers.san.hp import hp_msa_client as msa
from oslo.config import cfg
from cinder import exception
+from cinder.i18n import _
from cinder.openstack.common import excutils
-from cinder.openstack.common.gettextutils import _
from cinder.openstack.common import log as logging
from cinder.openstack.common import processutils
from cinder import ssh_utils
from oslo.config import cfg
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder.volume.drivers.san.san import SanISCSIDriver
import six.moves.urllib.parse as urlparse
from cinder import exception
+from cinder.i18n import _
from cinder.image import image_utils
-from cinder.openstack.common.gettextutils import _
from cinder.openstack.common import log as logging
from cinder.openstack.common import units
from cinder.volume import driver
from oslo.config import cfg
from cinder import exception
+from cinder.i18n import _
from cinder.image import image_utils
-from cinder.openstack.common.gettextutils import _
from cinder.openstack.common import log as logging
from cinder.openstack.common import processutils
from cinder.openstack.common import units
from cinder import context
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder.openstack.common import timeutils
from cinder.openstack.common import units
Provides abstraction over cinder.volume.drivers.vmware.vim.Vim SOAP calls.
"""
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder.openstack.common import loopingcall
from cinder.volume.drivers.vmware import error_util
"""
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
NOT_AUTHENTICATED = 'NotAuthenticated'
from eventlet import queue
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
LOG = logging.getLogger(__name__)
import six.moves.urllib.parse as urlparse
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder.volume.drivers.vmware import error_util
from cinder.volume.drivers.vmware import vim_util
import suds
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.volume.drivers.vmware import error_util
from cinder.volume.drivers.vmware import vim_util
from oslo.config import cfg
from cinder import exception
+from cinder.i18n import _
from cinder.openstack.common import excutils
-from cinder.openstack.common.gettextutils import _
from cinder.openstack.common import log as logging
from cinder.openstack.common import units
from cinder.volume import driver
from eventlet import timeout
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder.volume.drivers.vmware import io_util
from cinder.volume.drivers.vmware import read_write_util as rw_util
Implements operations on volumes residing on VMware datastores.
"""
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder.openstack.common import units
from cinder.volume.drivers.vmware import error_util
virtdisk = windll.virtdisk
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder.volume.drivers.windows import constants
from oslo.config import cfg
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder.volume.drivers.windows import constants
from oslo.config import cfg
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder.volume import driver
from cinder import exception
from cinder import flow_utils
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder.openstack.common import timeutils
from cinder.openstack.common import units
import six
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
LOG = logging.getLogger(__name__)
from cinder import exception
from cinder import flow_utils
+from cinder.i18n import _
from cinder.image import glance
-from cinder.openstack.common.gettextutils import _
from cinder.openstack.common import log as logging
from cinder.openstack.common import processutils
from cinder.openstack.common import timeutils
from cinder import exception
from cinder import flow_utils
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder.volume.flows.api import create_volume as create_api
from cinder.volume.flows import common as flow_common
from cinder.brick.iscsi import iscsi
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder.openstack.common import processutils as putils
from cinder.volume import utils
from cinder import context
from cinder import exception
from cinder import flow_utils
+from cinder.i18n import _
from cinder.image import glance
from cinder import manager
from cinder.openstack.common import excutils
-from cinder.openstack.common.gettextutils import _
from cinder.openstack.common import importutils
from cinder.openstack.common import jsonutils
from cinder.openstack.common import log as logging
from cinder import context
from cinder import db
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder.volume import volume_types
from cinder.brick.local_dev import lvm as brick_lvm
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder.openstack.common import processutils
from cinder.openstack.common import strutils
from cinder import context
from cinder import db
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log as logging
import webob.exc
from cinder import exception
+from cinder.i18n import _
from cinder.openstack.common import excutils
-from cinder.openstack.common.gettextutils import _
from cinder.openstack.common import log as logging
from cinder import utils
import paramiko
from cinder import exception
+from cinder.i18n import _
from cinder.openstack.common import excutils
-from cinder.openstack.common.gettextutils import _
from cinder.openstack.common import log as logging
from cinder import utils
from cinder.zonemanager.drivers.brocade import brcd_fabric_opts as fabric_opts
from eventlet import greenthread
from cinder import exception
+from cinder.i18n import _
from cinder.openstack.common import excutils
-from cinder.openstack.common.gettextutils import _
from cinder.openstack.common import log as logging
from cinder.openstack.common import processutils
from cinder import ssh_utils
from oslo.config import cfg
from cinder import exception
+from cinder.i18n import _
from cinder.openstack.common import excutils
-from cinder.openstack.common.gettextutils import _
from cinder.openstack.common import importutils
from cinder.openstack.common import lockutils
from cinder.openstack.common import log as logging
"""
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import importutils
from cinder.openstack.common import log as logging
from cinder.volume import configuration as config
from oslo.config import cfg
from cinder import exception
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import importutils
from cinder.openstack.common import log as logging
from cinder.volume import configuration as config
"""
import logging
-from cinder.openstack.common.gettextutils import _
+from cinder.i18n import _
from cinder.openstack.common import log
from cinder.volume.configuration import Configuration
from cinder.volume import manager
To use gettext, make sure that the strings passed to the logger are wrapped
in a ``_()`` function call. For example::
- LOG.debug(_("block_device_mapping %s"), block_device_mapping)
+ LOG.info(_("block_device_mapping %s") % block_device_mapping)
-If you have multiple arguments, the convention is to use named parameters.
-It's common to use the ``locals()`` dict (which contains the names and values
-of the local variables in the current scope) to do the string interpolation.
-For example::
-
- label = ...
- sr_ref = ...
- LOG.debug(_('Introduced %(label)s as %(sr_ref)s.') % locals())
+Do not use ``locals()`` for formatting messages because:
+1. It is not as clear as using explicit dicts.
+2. It could produce hidden errors during refactoring.
+3. Changing the name of a variable causes a change in the message.
+4. It creates a lot of otherwise unused variables.
If you do not follow the project conventions, your code may cause the
LocalizationTestCase.test_multiple_positional_format_placeholders test to fail
in cinder/tests/test_localization.py.
-The ``_()`` function is brought into the global scope by doing::
+For translation to work properly, the top level scripts for Cinder need
+to first do the following before any Cinder modules are imported::
+
+ from cinder import i18n
+ i18n.enable_lazy()
+
+Any files that use the _() for translation then must have the following
+lines::
- from cinder.openstack.common import gettextutils
- gettextutils.install("cinder")
+ from cinder.i18n import _
-These lines are needed in any toplevel script before any cinder modules are
-imported. If this code is missing, it may result in an error that looks like::
+If the above code is missing, it may result in an error that looks
+like::
NameError: name '_' is not defined
suds>=0.4
WebOb>=1.2.3
wsgiref>=0.1.2
+oslo.i18n>=0.1.0
[hacking]
local-check-factory = cinder.hacking.checks.factory
+import_exceptions = cinder.i18n