Switch to internal _i18n pattern, as per oslo_i18n guidelines

- Guidelines referenced from:
  http://docs.openstack.org/developer/oslo.i18n/usage.html

Change-Id: I938919958525b2db0c8a517b951a23f974a7762e
This commit is contained in:
Gary Kotton 2015-12-02 05:14:30 -08:00
parent aa562d7de8
commit 4afa13c3c4
57 changed files with 104 additions and 61 deletions

View File

@ -14,11 +14,12 @@
import logging
from neutron.i18n import _LI
from tabulate import tabulate
from oslo_config import cfg
from oslo_serialization import jsonutils
from tabulate import tabulate
from vmware_nsx._i18n import _LI
LOG = logging.getLogger(__name__)

View File

@ -15,7 +15,7 @@
import logging
import sys
from neutron.i18n import _LI
from vmware_nsx._i18n import _LI
LOG = logging.getLogger(__name__)

View File

@ -21,8 +21,8 @@ import admin.plugins.nsxv.resources.utils as utils
from admin.shell import Operations
from neutron.callbacks import registry
from neutron.i18n import _LI
from vmware_nsx._i18n import _LI
from vmware_nsx.db import nsxv_db
LOG = logging.getLogger(__name__)

View File

@ -24,8 +24,8 @@ import admin.plugins.nsxv.resources.utils as utils
from admin.shell import Operations
from neutron.callbacks import registry
from neutron.i18n import _LE, _LI
from vmware_nsx._i18n import _LE, _LI
from vmware_nsx.db import nsxv_db
LOG = logging.getLogger(__name__)

View File

@ -22,8 +22,8 @@ import admin.plugins.nsxv.resources.utils as utils
from admin.shell import Operations
from neutron.callbacks import registry
from neutron.i18n import _LI
from vmware_nsx._i18n import _LI
from vmware_nsx.db import nsxv_db
LOG = logging.getLogger(__name__)

View File

@ -24,8 +24,8 @@ from neutron.callbacks import registry
from neutron import context as neutron_context
from neutron.db import common_db_mixin as common_db
from neutron.db import securitygroups_db as sg_db
from neutron.i18n import _LI
from vmware_nsx._i18n import _LI
from vmware_nsx.nsxlib.v3 import dfw_api as firewall
LOG = logging.getLogger(__name__)

View File

@ -34,9 +34,8 @@ import sys
from neutron.callbacks import registry
from neutron.common import config as neutron_config
from neutron.i18n import _LE
from neutron.i18n import _LI
from vmware_nsx._i18n import _LE, _LI
from vmware_nsx.common import config # noqa
from oslo_config import cfg

View File

@ -89,5 +89,5 @@ commands =
pylint --rcfile=.pylintrc --output-format=colorized {posargs:vmware_nsx/neutron}
[hacking]
import_exceptions = neutron.i18n
import_exceptions = vmware_nsx._i18n
local-check-factory = neutron.hacking.checks.factory

42
vmware_nsx/_i18n.py Normal file
View File

@ -0,0 +1,42 @@
# All Rights Reserved.
#
# 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.
import oslo_i18n
DOMAIN = "vmware-nsx"
_translators = oslo_i18n.TranslatorFactory(domain=DOMAIN)
# The primary translation function using the well-known name "_"
_ = _translators.primary
# The contextual translation function using the name "_C"
_C = _translators.contextual_form
# The plural translation function using the name "_P"
_P = _translators.plural_form
# 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 get_available_languages():
return oslo_i18n.get_available_languages(DOMAIN)

View File

@ -17,12 +17,12 @@
import abc
import time
from neutron.i18n import _LE, _LI, _LW
from oslo_config import cfg
from oslo_log import log as logging
import six
from six.moves import http_client as httplib
from vmware_nsx._i18n import _LE, _LI, _LW
from vmware_nsx import api_client
LOG = logging.getLogger(__name__)

View File

@ -19,7 +19,7 @@
from oslo_log import log as logging
from six.moves import http_client as httplib
from neutron.i18n import _LE
from vmware_nsx._i18n import _LE
from vmware_nsx.api_client import base
from vmware_nsx.api_client import eventlet_client
from vmware_nsx.api_client import eventlet_request

View File

@ -21,7 +21,7 @@ import eventlet
eventlet.monkey_patch()
from oslo_log import log as logging
from neutron.i18n import _LE
from vmware_nsx._i18n import _LE
from vmware_nsx.api_client import base
from vmware_nsx.api_client import eventlet_request

View File

@ -21,7 +21,7 @@ from oslo_serialization import jsonutils
from six.moves import http_client as httplib
from six.moves.urllib import parse
from neutron.i18n import _LI, _LW
from vmware_nsx._i18n import _LI, _LW
from vmware_nsx.api_client import request
LOG = logging.getLogger(__name__)

View File

@ -27,7 +27,7 @@ import six
from six.moves import http_client as httplib
import six.moves.urllib.parse as urlparse
from neutron.i18n import _LI, _LW
from vmware_nsx._i18n import _LI, _LW
from vmware_nsx import api_client
LOG = logging.getLogger(__name__)

View File

@ -17,7 +17,7 @@
from oslo_log import log as logging
from neutron.i18n import _LW
from vmware_nsx._i18n import _LW
LOG = logging.getLogger(__name__)

View File

@ -16,7 +16,7 @@ import logging
from oslo_config import cfg
from neutron.i18n import _LW
from vmware_nsx._i18n import _LW
from vmware_nsx.common import exceptions as nsx_exc
from vmware_nsx.extensions import routersize

View File

@ -17,10 +17,10 @@ from neutron.api.v2 import attributes as attr
from neutron.common import exceptions as n_exc
from neutron.extensions import multiprovidernet as mpnet
from neutron.extensions import providernet as pnet
from neutron.i18n import _LW
from oslo_log import log
import six
from vmware_nsx._i18n import _LW
from vmware_nsx.api_client import client
from vmware_nsx.api_client import exception as api_exc
from vmware_nsx.common import utils as vmw_utils

View File

@ -28,8 +28,8 @@ from neutron.db import external_net_db
from neutron.db import l3_db
from neutron.db import models_v2
from neutron.extensions import l3
from neutron.i18n import _LE, _LI, _LW
from vmware_nsx._i18n import _LE, _LI, _LW
from vmware_nsx.api_client import exception as api_exc
from vmware_nsx.common import exceptions as nsx_exc
from vmware_nsx.common import nsx_utils

View File

@ -16,13 +16,14 @@
import hashlib
from neutron.api.v2 import attributes
from neutron.i18n import _LE
from neutron import version
from oslo_config import cfg
from oslo_log import log
import retrying
import six
from vmware_nsx._i18n import _LE
LOG = log.getLogger(__name__)
MAX_DISPLAY_NAME_LEN = 40
NEUTRON_VERSION = version.version_info.release_string()

View File

@ -23,8 +23,7 @@ from sqlalchemy import func
from sqlalchemy.orm import exc
from sqlalchemy.sql import expression as expr
from neutron.i18n import _, _LE
from vmware_nsx._i18n import _, _LE
from vmware_nsx.common import exceptions as nsx_exc
from vmware_nsx.common import nsxv_constants
from vmware_nsx.db import nsxv_models

View File

@ -18,11 +18,11 @@ from sqlalchemy.orm import exc
from neutron.api.v2 import attributes as attr
from neutron.db import db_base_plugin_v2
from neutron.db import models_v2
from neutron.i18n import _LI
from oslo_log import log
from oslo_utils import uuidutils
from vmware_nsx._i18n import _LI
from vmware_nsx.db import nsx_models
from vmware_nsx.extensions import qos

View File

@ -21,7 +21,7 @@ from oslo_db import exception as db_exc
from oslo_log import log as logging
from oslo_utils import excutils
from neutron.i18n import _LE, _LW
from vmware_nsx._i18n import _LE, _LW
from vmware_nsx.api_client import exception as api_exc
from vmware_nsx.common import exceptions as p_exc
from vmware_nsx.common import nsx_utils

View File

@ -20,7 +20,7 @@ from neutron.common import exceptions as n_exc
from neutron.extensions import external_net
from oslo_log import log as logging
from neutron.i18n import _LE
from vmware_nsx._i18n import _LE
from vmware_nsx.common import exceptions as p_exc
from vmware_nsx.dhcp_meta import nsx
from vmware_nsx.dhcp_meta import rpc

View File

@ -25,7 +25,8 @@ from neutron.common import exceptions as n_exc
from neutron.db import db_base_plugin_v2
from neutron.db import l3_db
from neutron.extensions import external_net
from neutron.i18n import _LE, _LI
from vmware_nsx._i18n import _LE, _LI
from vmware_nsx.common import exceptions as p_exc
from vmware_nsx.dhcp_meta import constants as d_const
from vmware_nsx.nsxlib.mh import lsn as lsn_api

View File

@ -25,7 +25,8 @@ from neutron.common import constants as const
from neutron.common import exceptions as ntn_exc
from neutron.db import db_base_plugin_v2
from neutron.db import models_v2
from neutron.i18n import _LE, _LI, _LW
from vmware_nsx._i18n import _LE, _LI, _LW
from vmware_nsx.api_client import exception as api_exc
from vmware_nsx.common import config
from vmware_nsx.common import exceptions as nsx_exc

View File

@ -27,8 +27,8 @@ from neutron.common import constants as const
from neutron.common import rpc as n_rpc
from neutron.common import topics
from neutron.db import agents_db
from neutron.i18n import _LW
from vmware_nsx._i18n import _LW
from vmware_nsx.common import config
from vmware_nsx.common import exceptions as nsx_exc
from vmware_nsx.dhcp_meta import combined

View File

@ -17,7 +17,7 @@ from oslo_log import log as logging
from oslo_utils import excutils
from oslo_vmware import vim_util
from neutron.i18n import _LE, _LI
from vmware_nsx._i18n import _LE, _LI
from vmware_nsx.common import exceptions as nsx_exc
from vmware_nsx.dvs import dvs_utils

View File

@ -17,7 +17,7 @@ from oslo_config import cfg
from oslo_log import log as logging
import six
from neutron.i18n import _LI
from vmware_nsx._i18n import _LI
from vmware_nsx.common import exceptions
LOG = logging.getLogger(__name__)

View File

@ -14,10 +14,10 @@
# under the License.
#
from neutron.i18n import _LE
from oslo_log import log
from oslo_serialization import jsonutils
from vmware_nsx._i18n import _LE
from vmware_nsx.api_client import exception as api_exc
from vmware_nsx.common import exceptions as nsx_exc
from vmware_nsx.common import utils

View File

@ -20,7 +20,7 @@ from oslo_serialization import jsonutils
from oslo_utils import excutils
import six
from neutron.i18n import _LE, _LI, _LW
from vmware_nsx._i18n import _LE, _LI, _LW
from vmware_nsx.api_client import exception as api_exc
from vmware_nsx.common import exceptions as nsx_exc
from vmware_nsx.common import utils

View File

@ -19,8 +19,8 @@ from oslo_utils import excutils
from neutron.common import constants
from neutron.common import exceptions
from neutron.i18n import _LW
from vmware_nsx._i18n import _LW
from vmware_nsx.common import utils
from vmware_nsx.nsxlib import mh as nsxlib

View File

@ -20,8 +20,8 @@ from oslo_serialization import jsonutils
from neutron.common import constants
from neutron.common import exceptions as exception
from neutron.i18n import _LE, _LI, _LW
from vmware_nsx._i18n import _LE, _LI, _LW
from vmware_nsx.api_client import exception as api_exc
from vmware_nsx.common import exceptions as nsx_exc
from vmware_nsx.common import utils

View File

@ -16,8 +16,7 @@
from oslo_config import cfg
from oslo_log import log
from neutron.i18n import _LW
from vmware_nsx._i18n import _LW
from vmware_nsx.common import exceptions as nsx_exc
from vmware_nsx.common import nsx_constants
from vmware_nsx.common import utils

View File

@ -15,11 +15,11 @@
#
import requests
from neutron.i18n import _LW, _
from oslo_config import cfg
from oslo_log import log
from oslo_serialization import jsonutils
from vmware_nsx._i18n import _LW, _
from vmware_nsx.common import exceptions as nsx_exc
LOG = log.getLogger(__name__)

View File

@ -20,9 +20,9 @@ NSX-V3 Plugin router module
import random
from neutron.common import exceptions as n_exc
from neutron.i18n import _LW
from oslo_log import log
from vmware_nsx._i18n import _LW
from vmware_nsx.common import exceptions as nsx_exc
from vmware_nsx.common import nsx_constants
from vmware_nsx.nsxlib import v3 as nsxlib

View File

@ -35,11 +35,11 @@ from neutron.extensions import portbindings as pbin
from neutron.extensions import portsecurity as psec
from neutron.extensions import providernet as pnet
from neutron.extensions import securitygroup as ext_sg
from neutron.i18n import _LE, _LW
from neutron.plugins.common import constants
from neutron.plugins.common import utils
import vmware_nsx
from vmware_nsx._i18n import _LE, _LW
from vmware_nsx.common import config # noqa
from vmware_nsx.common import exceptions as nsx_exc
from vmware_nsx.common import nsx_constants

View File

@ -55,11 +55,11 @@ from neutron.extensions import portbindings as pbin
from neutron.extensions import portsecurity as psec
from neutron.extensions import providernet as pnet
from neutron.extensions import securitygroup as ext_sg
from neutron.i18n import _LE, _LI, _LW
from neutron.plugins.common import constants as plugin_const
from neutron.plugins.common import utils
import vmware_nsx
from vmware_nsx._i18n import _LE, _LI, _LW
from vmware_nsx.api_client import exception as api_exc
from vmware_nsx.common import config # noqa
from vmware_nsx.common import exceptions as nsx_exc

View File

@ -18,8 +18,8 @@ from oslo_utils import excutils
from neutron.api.v2 import attributes as attr
from neutron.common import exceptions as n_exc
from neutron.db import l3_db
from neutron.i18n import _LE
from vmware_nsx._i18n import _LE
from vmware_nsx.db import nsxv_db
from vmware_nsx.plugins.nsx_v.drivers import (
abstract_router_driver as router_driver)

View File

@ -18,7 +18,7 @@ import stevedore
from oslo_log import log
from neutron.i18n import _LE, _LI
from vmware_nsx._i18n import _LE, _LI
from vmware_nsx.common import exceptions as nsx_exc
LOG = log.getLogger(__name__)

View File

@ -24,7 +24,7 @@ from neutron import context as neutron_context
from oslo_config import cfg
from oslo_log import log as logging
from neutron.i18n import _LE
from vmware_nsx._i18n import _LE
from vmware_nsx.common import exceptions as nsxv_exc
from vmware_nsx.common import locking
from vmware_nsx.common import nsxv_constants

View File

@ -48,11 +48,11 @@ from neutron.extensions import portbindings as pbin
from neutron.extensions import portsecurity as psec
from neutron.extensions import providernet as pnet
from neutron.extensions import securitygroup as ext_sg
from neutron.i18n import _LE, _LI, _LW
from neutron.plugins.common import constants as plugin_const
from neutron.plugins.common import utils
import vmware_nsx
from vmware_nsx._i18n import _LE, _LI, _LW
from vmware_nsx.common import config # noqa
from vmware_nsx.common import exceptions as nsx_exc
from vmware_nsx.common import locking

View File

@ -21,7 +21,7 @@ from oslo_log import log as logging
from oslo_serialization import jsonutils
from oslo_utils import excutils
from neutron.i18n import _LE, _LI, _LW
from vmware_nsx._i18n import _LE, _LI, _LW
from vmware_nsx.common import nsxv_constants
from vmware_nsx.common import utils
from vmware_nsx.plugins.nsx_v.vshield.common import constants

View File

@ -16,7 +16,7 @@ from neutron.db import db_base_plugin_v2
from oslo_log import log as logging
from oslo_utils import excutils
from neutron.i18n import _, _LE
from vmware_nsx._i18n import _, _LE
from vmware_nsx.db import nsxv_db
from vmware_nsx.plugins.nsx_v.vshield.common import (
exceptions as vcns_exc)

View File

@ -15,7 +15,7 @@
from oslo_log import log as logging
from oslo_utils import excutils
from neutron.i18n import _LE, _LW
from vmware_nsx._i18n import _LE, _LW
from vmware_nsx.plugins.nsx_v.vshield.common import (
exceptions as vcns_exc)

View File

@ -29,9 +29,9 @@ from sqlalchemy.orm import exc as sa_exc
from neutron.common import exceptions as n_exc
from neutron import context as q_context
from neutron.extensions import l3
from neutron.i18n import _LE, _LW
from neutron.plugins.common import constants as plugin_const
from vmware_nsx._i18n import _LE, _LW
from vmware_nsx.common import exceptions as nsx_exc
from vmware_nsx.common import locking
from vmware_nsx.common import nsxv_constants

View File

@ -23,7 +23,7 @@ from oslo_log import log as logging
from oslo_service import loopingcall
import six
from neutron.i18n import _LE, _LI
from vmware_nsx._i18n import _LE, _LI
from vmware_nsx.plugins.nsx_v.vshield.tasks import constants
DEFAULT_INTERVAL = 1000

View File

@ -49,7 +49,6 @@ from neutron.extensions import portbindings as pbin
from neutron.extensions import portsecurity as psec
from neutron.extensions import providernet as pnet
from neutron.extensions import securitygroup as ext_sg
from neutron.i18n import _LE, _LI, _LW
from neutron.plugins.common import constants as plugin_const
from neutron.plugins.common import utils as n_utils
from oslo_config import cfg
@ -57,6 +56,8 @@ from oslo_log import log
from oslo_utils import excutils
from oslo_utils import importutils
from oslo_utils import uuidutils
from vmware_nsx._i18n import _LE, _LI, _LW
from vmware_nsx.common import config # noqa
from vmware_nsx.common import exceptions as nsx_exc
from vmware_nsx.common import locking

View File

@ -18,13 +18,13 @@ from networking_l2gw.db.l2gateway import l2gateway_db
from networking_l2gw.services.l2gateway.common import constants as l2gw_const
from networking_l2gw.services.l2gateway import exceptions as l2gw_exc
from neutron.common import exceptions as n_exc
from neutron.i18n import _LE
from neutron import manager
from oslo_config import cfg
from oslo_log import log as logging
from oslo_utils import excutils
from oslo_utils import uuidutils
from vmware_nsx._i18n import _LE
from vmware_nsx.common import exceptions as nsx_exc
from vmware_nsx.common import nsxv_constants
from vmware_nsx.db import db as nsx_db

View File

@ -30,10 +30,10 @@ from neutron.callbacks import resources
from neutron.common import exceptions as n_exc
from neutron import context
from neutron.extensions import providernet
from neutron.i18n import _LE, _LI
from neutron import manager
from neutron.plugins.common import utils as n_utils
from vmware_nsx._i18n import _LE, _LI
from vmware_nsx.common import exceptions as nsx_exc
from vmware_nsx.common import nsx_constants
from vmware_nsx.common import utils as nsx_utils

View File

@ -14,12 +14,12 @@
# under the License.
from neutron.common import exceptions as n_exc
from neutron.i18n import _LE
from neutron import manager
from neutron.plugins.common import constants
from oslo_log import log as logging
from oslo_utils import excutils
from vmware_nsx._i18n import _LE
from vmware_nsx.common import locking
from vmware_nsx.plugins.nsx_v.vshield.common import exceptions as nsxv_exc
from vmware_nsx.services.lbaas.nsx_v import lbaas_common as lb_common

View File

@ -13,11 +13,11 @@
# License for the specific language governing permissions and limitations
# under the License.
from neutron.i18n import _LE
from oslo_log import helpers as log_helpers
from oslo_log import log as logging
from oslo_utils import excutils
from vmware_nsx._i18n import _LE
from vmware_nsx.common import locking
from vmware_nsx.db import nsxv_db
from vmware_nsx.plugins.nsx_v.vshield.common import exceptions as nsxv_exc

View File

@ -13,11 +13,11 @@
# License for the specific language governing permissions and limitations
# under the License.
from neutron.i18n import _LE
from oslo_log import helpers as log_helpers
from oslo_log import log as logging
from oslo_utils import excutils
from vmware_nsx._i18n import _LE
from vmware_nsx.common import exceptions as nsxv_exc
from vmware_nsx.common import locking
from vmware_nsx.db import nsxv_db

View File

@ -13,11 +13,11 @@
# License for the specific language governing permissions and limitations
# under the License.
from neutron.i18n import _LE
from oslo_log import helpers as log_helpers
from oslo_log import log as logging
from oslo_utils import excutils
from vmware_nsx._i18n import _LE
from vmware_nsx.db import nsxv_db
from vmware_nsx.plugins.nsx_v.vshield.common import exceptions as nsxv_exc
from vmware_nsx.services.lbaas.nsx_v import lbaas_common as lb_common

View File

@ -13,11 +13,11 @@
# License for the specific language governing permissions and limitations
# under the License.
from neutron.i18n import _LE
from oslo_log import helpers as log_helpers
from oslo_log import log as logging
from oslo_utils import excutils
from vmware_nsx._i18n import _LE
from vmware_nsx.common import locking
from vmware_nsx.db import nsxv_db
from vmware_nsx.plugins.nsx_v.vshield.common import exceptions as nsxv_exc

View File

@ -13,11 +13,11 @@
# License for the specific language governing permissions and limitations
# under the License.
from neutron.i18n import _LE
from oslo_log import helpers as log_helpers
from oslo_log import log as logging
from oslo_utils import excutils
from vmware_nsx._i18n import _LE
from vmware_nsx.common import locking
from vmware_nsx.db import nsxv_db
from vmware_nsx.plugins.nsx_v.vshield.common import exceptions as nsxv_exc

View File

@ -18,10 +18,10 @@ from oslo_log import log as logging
from oslo_utils import excutils
from neutron.db import db_base_plugin_common
from neutron.i18n import _LE, _LI
from neutron.objects.qos import policy as policy_object
from neutron.services.qos import qos_plugin
from vmware_nsx._i18n import _LE, _LI
from vmware_nsx.common import utils
from vmware_nsx.nsxlib import v3 as nsxlib

View File

@ -17,12 +17,11 @@ import urllib
import eventlet
import mock
from neutron.i18n import _LI
from neutron.tests import base
from oslo_log import log as logging
from six.moves import http_client as httplib
from vmware_nsx._i18n import _LI
from vmware_nsx.api_client import (
eventlet_client as client)
from vmware_nsx.api_client import (