diff --git a/nova_powervm/virt/powervm/disk/driver.py b/nova_powervm/virt/powervm/disk/driver.py index 672ca57f..1aec88e3 100644 --- a/nova_powervm/virt/powervm/disk/driver.py +++ b/nova_powervm/virt/powervm/disk/driver.py @@ -21,7 +21,6 @@ import oslo_log.log as logging from oslo_utils import units import six -from nova.i18n import _LW from nova import image import pypowervm.const as pvm_const import pypowervm.tasks.scsi_mapper as tsk_map @@ -29,6 +28,7 @@ import pypowervm.util as pvm_util import pypowervm.wrappers.virtual_io_server as pvm_vios from nova_powervm.virt.powervm import exception as npvmex +from nova_powervm.virt.powervm.i18n import _LW from nova_powervm.virt.powervm import vm LOG = logging.getLogger(__name__) diff --git a/nova_powervm/virt/powervm/disk/localdisk.py b/nova_powervm/virt/powervm/disk/localdisk.py index c7346f3b..70d6c417 100644 --- a/nova_powervm/virt/powervm/disk/localdisk.py +++ b/nova_powervm/virt/powervm/disk/localdisk.py @@ -19,7 +19,6 @@ from oslo_config import cfg from oslo_log import log as logging from nova import exception as nova_exc -from nova.i18n import _LI, _LE from pypowervm import exceptions as pvm_exc from pypowervm.tasks import scsi_mapper as tsk_map from pypowervm.tasks import storage as tsk_stg @@ -29,6 +28,8 @@ from pypowervm.wrappers import virtual_io_server as pvm_vios from nova_powervm.virt.powervm.disk import driver as disk_dvr from nova_powervm.virt.powervm import exception as npvmex +from nova_powervm.virt.powervm.i18n import _LE +from nova_powervm.virt.powervm.i18n import _LI from nova_powervm.virt.powervm import vios from nova_powervm.virt.powervm import vm diff --git a/nova_powervm/virt/powervm/disk/ssp.py b/nova_powervm/virt/powervm/disk/ssp.py index 21ac40f2..4a57485a 100644 --- a/nova_powervm/virt/powervm/disk/ssp.py +++ b/nova_powervm/virt/powervm/disk/ssp.py @@ -19,8 +19,10 @@ import random from oslo_config import cfg import oslo_log.log as logging -from nova.i18n import _LI, _LE from nova_powervm.virt.powervm.disk import driver as disk_drv +from nova_powervm.virt.powervm import exception as npvmex +from nova_powervm.virt.powervm.i18n import _LE +from nova_powervm.virt.powervm.i18n import _LI from nova_powervm.virt.powervm import vios from nova_powervm.virt.powervm import vm @@ -31,7 +33,6 @@ import pypowervm.wrappers.cluster as pvm_clust import pypowervm.wrappers.storage as pvm_stg import pypowervm.wrappers.virtual_io_server as pvm_vios -from nova_powervm.virt.powervm import exception as npvmex ssp_opts = [ cfg.StrOpt('cluster_name', diff --git a/nova_powervm/virt/powervm/driver.py b/nova_powervm/virt/powervm/driver.py index 09c442bb..00d18f98 100644 --- a/nova_powervm/virt/powervm/driver.py +++ b/nova_powervm/virt/powervm/driver.py @@ -21,7 +21,6 @@ from nova.console import type as console_type from nova import context as ctx from nova import exception from nova import image -from nova.i18n import _LI, _LW, _LE, _ from nova.objects import flavor as flavor_obj from nova import utils as n_utils from nova.virt import configdrive @@ -49,6 +48,10 @@ from pypowervm.wrappers import virtual_io_server as pvm_vios from nova_powervm.virt.powervm.disk import driver as disk_dvr from nova_powervm.virt.powervm import host as pvm_host +from nova_powervm.virt.powervm.i18n import _ +from nova_powervm.virt.powervm.i18n import _LE +from nova_powervm.virt.powervm.i18n import _LI +from nova_powervm.virt.powervm.i18n import _LW from nova_powervm.virt.powervm import image as img from nova_powervm.virt.powervm import live_migration as lpm from nova_powervm.virt.powervm import mgmt diff --git a/nova_powervm/virt/powervm/exception.py b/nova_powervm/virt/powervm/exception.py index c392137c..48f5e53e 100644 --- a/nova_powervm/virt/powervm/exception.py +++ b/nova_powervm/virt/powervm/exception.py @@ -18,10 +18,11 @@ import abc from nova import exception as nex -from nova.i18n import _ import six +from nova_powervm.virt.powervm.i18n import _ + @six.add_metaclass(abc.ABCMeta) class AbstractMediaException(nex.NovaException): diff --git a/nova_powervm/virt/powervm/host.py b/nova_powervm/virt/powervm/host.py index cbd93100..711f20ec 100644 --- a/nova_powervm/virt/powervm/host.py +++ b/nova_powervm/virt/powervm/host.py @@ -18,14 +18,13 @@ import math from nova.compute import arch from nova.compute import hv_type from nova.compute import vm_mode -from nova.i18n import _LW -import subprocess - from oslo_concurrency import lockutils from oslo_log import log as logging from oslo_serialization import jsonutils - from pypowervm.tasks.monitor import util as pcm_util +import subprocess + +from nova_powervm.virt.powervm.i18n import _LW LOG = logging.getLogger(__name__) diff --git a/nova_powervm/virt/powervm/i18n.py b/nova_powervm/virt/powervm/i18n.py new file mode 100644 index 00000000..6ab928b0 --- /dev/null +++ b/nova_powervm/virt/powervm/i18n.py @@ -0,0 +1,25 @@ +# Copyright 2015 IBM Corp. +# +# 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 + +# Initialize message translators and short cut methods +_translators = oslo_i18n.TranslatorFactory(domain='nova-powervm') +_ = _translators.primary +_LI = _translators.log_info +_LW = _translators.log_warning +_LE = _translators.log_error +_LC = _translators.log_critical diff --git a/nova_powervm/virt/powervm/live_migration.py b/nova_powervm/virt/powervm/live_migration.py index 266d07db..0b2a056b 100644 --- a/nova_powervm/virt/powervm/live_migration.py +++ b/nova_powervm/virt/powervm/live_migration.py @@ -17,7 +17,6 @@ import abc from nova import exception -from nova.i18n import _, _LE, _LI from pypowervm.tasks import management_console as mgmt_task from pypowervm.tasks import migration as mig from pypowervm.tasks import storage as stor_task @@ -27,6 +26,9 @@ from oslo_config import cfg from oslo_log import log as logging import six +from nova_powervm.virt.powervm.i18n import _ +from nova_powervm.virt.powervm.i18n import _LE +from nova_powervm.virt.powervm.i18n import _LI from nova_powervm.virt.powervm import media from nova_powervm.virt.powervm import vm diff --git a/nova_powervm/virt/powervm/media.py b/nova_powervm/virt/powervm/media.py index b40d4e86..92da861d 100644 --- a/nova_powervm/virt/powervm/media.py +++ b/nova_powervm/virt/powervm/media.py @@ -16,7 +16,6 @@ import copy from nova.api.metadata import base as instance_metadata -from nova.i18n import _LI, _LW from nova.network import model as network_model from nova.virt import configdrive import os @@ -36,6 +35,8 @@ from pypowervm.wrappers import storage as pvm_stg from pypowervm.wrappers import virtual_io_server as pvm_vios from nova_powervm.virt.powervm import exception as npvmex +from nova_powervm.virt.powervm.i18n import _LI +from nova_powervm.virt.powervm.i18n import _LW from nova_powervm.virt.powervm import vm LOG = logging.getLogger(__name__) diff --git a/nova_powervm/virt/powervm/tasks/image.py b/nova_powervm/virt/powervm/tasks/image.py index c4eeb415..f168a42a 100644 --- a/nova_powervm/virt/powervm/tasks/image.py +++ b/nova_powervm/virt/powervm/tasks/image.py @@ -14,11 +14,10 @@ # License for the specific language governing permissions and limitations # under the License. -from nova.i18n import _LI - from oslo_log import log as logging from taskflow import task +from nova_powervm.virt.powervm.i18n import _LI from nova_powervm.virt.powervm import image LOG = logging.getLogger(__name__) diff --git a/nova_powervm/virt/powervm/tasks/network.py b/nova_powervm/virt/powervm/tasks/network.py index b9ac8882..df71108b 100644 --- a/nova_powervm/virt/powervm/tasks/network.py +++ b/nova_powervm/virt/powervm/tasks/network.py @@ -17,13 +17,16 @@ import eventlet from nova import exception -from nova.i18n import _LI, _LW, _LE, _ from nova import utils from oslo_config import cfg from oslo_log import log as logging from taskflow import task +from nova_powervm.virt.powervm.i18n import _ +from nova_powervm.virt.powervm.i18n import _LE +from nova_powervm.virt.powervm.i18n import _LI +from nova_powervm.virt.powervm.i18n import _LW from nova_powervm.virt.powervm import vm LOG = logging.getLogger(__name__) diff --git a/nova_powervm/virt/powervm/tasks/storage.py b/nova_powervm/virt/powervm/tasks/storage.py index 91cd0a2f..bf8396ea 100644 --- a/nova_powervm/virt/powervm/tasks/storage.py +++ b/nova_powervm/virt/powervm/tasks/storage.py @@ -14,7 +14,6 @@ # License for the specific language governing permissions and limitations # under the License. -from nova.i18n import _LI, _LW from pypowervm.tasks import scsi_mapper as pvm_smap from oslo_log import log as logging @@ -23,6 +22,8 @@ from taskflow.types import failure as task_fail from nova_powervm.virt.powervm.disk import driver as disk_driver from nova_powervm.virt.powervm import exception as npvmex +from nova_powervm.virt.powervm.i18n import _LI +from nova_powervm.virt.powervm.i18n import _LW from nova_powervm.virt.powervm import media from nova_powervm.virt.powervm import mgmt diff --git a/nova_powervm/virt/powervm/tasks/vm.py b/nova_powervm/virt/powervm/tasks/vm.py index 8b2270eb..db7453cf 100644 --- a/nova_powervm/virt/powervm/tasks/vm.py +++ b/nova_powervm/virt/powervm/tasks/vm.py @@ -14,7 +14,6 @@ # License for the specific language governing permissions and limitations # under the License. -from nova.i18n import _LI from pypowervm.tasks import power from pypowervm.tasks import storage as pvm_stg @@ -22,6 +21,7 @@ from oslo_log import log as logging from taskflow import task from taskflow.types import failure as task_fail +from nova_powervm.virt.powervm.i18n import _LI from nova_powervm.virt.powervm import vm LOG = logging.getLogger(__name__) diff --git a/nova_powervm/virt/powervm/vm.py b/nova_powervm/virt/powervm/vm.py index b501ba4d..f6334f7f 100644 --- a/nova_powervm/virt/powervm/vm.py +++ b/nova_powervm/virt/powervm/vm.py @@ -15,14 +15,12 @@ # under the License. import json -import re - from oslo_config import cfg from oslo_log import log as logging +import re from nova.compute import power_state from nova import exception -from nova.i18n import _LI, _LE, _ from nova.virt import hardware from pypowervm import exceptions as pvm_exc from pypowervm.helpers import log_helper as pvm_log @@ -39,6 +37,11 @@ from pypowervm.wrappers import managed_system as pvm_ms from pypowervm.wrappers import network as pvm_net from pypowervm.wrappers import shared_proc_pool as pvm_spp +from nova_powervm.virt.powervm.i18n import _ +from nova_powervm.virt.powervm.i18n import _LE +from nova_powervm.virt.powervm.i18n import _LI + + LOG = logging.getLogger(__name__) CONF = cfg.CONF diff --git a/nova_powervm/virt/powervm/volume/npiv.py b/nova_powervm/virt/powervm/volume/npiv.py index 0ec43c42..7633efb1 100644 --- a/nova_powervm/virt/powervm/volume/npiv.py +++ b/nova_powervm/virt/powervm/volume/npiv.py @@ -19,11 +19,12 @@ from oslo_log import log as logging from taskflow import task from nova.compute import task_states -from nova.i18n import _LI, _LW from pypowervm.tasks import vfc_mapper as pvm_vfcm from pypowervm.wrappers import virtual_io_server as pvm_vios from nova_powervm.virt import powervm +from nova_powervm.virt.powervm.i18n import _LI +from nova_powervm.virt.powervm.i18n import _LW from nova_powervm.virt.powervm.volume import driver as v_driver LOG = logging.getLogger(__name__) diff --git a/nova_powervm/virt/powervm/volume/vscsi.py b/nova_powervm/virt/powervm/volume/vscsi.py index f27aea68..07a06c0e 100644 --- a/nova_powervm/virt/powervm/volume/vscsi.py +++ b/nova_powervm/virt/powervm/volume/vscsi.py @@ -14,14 +14,16 @@ # License for the specific language governing permissions and limitations # under the License. -from nova.i18n import _, _LI, _LW, _LE - from oslo_concurrency import lockutils from oslo_config import cfg from oslo_log import log as logging from taskflow import task from nova_powervm.virt.powervm import exception as p_exc +from nova_powervm.virt.powervm.i18n import _ +from nova_powervm.virt.powervm.i18n import _LE +from nova_powervm.virt.powervm.i18n import _LI +from nova_powervm.virt.powervm.i18n import _LW from nova_powervm.virt.powervm import vios from nova_powervm.virt.powervm import vm from nova_powervm.virt.powervm.volume import driver as v_driver diff --git a/tox.ini b/tox.ini index af6edf96..ef6fa98e 100644 --- a/tox.ini +++ b/tox.ini @@ -29,6 +29,3 @@ commands = python setup.py build_sphinx [flake8] ignore = E125,E712,H104,H405,H904 exclude = .venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build,tools - -[hacking] -import_exceptions = nova.i18n