Remove log translations

Log messages are no longer being translated. This removes all use of
the _LE, _LI, and _LW translation markers to simplify logging and to
avoid confusion with new contributions.

See:
http://lists.openstack.org/pipermail/openstack-i18n/2016-November/002574.html
http://lists.openstack.org/pipermail/openstack-dev/2017-March/113365.html

Change-Id: If4735fc3ac1803585efd90657539e540d157a59a
This commit is contained in:
shihanzhang 2017-03-28 09:47:09 +08:00
parent 4ef6b4ad5a
commit 1d35146a46
14 changed files with 54 additions and 62 deletions

View File

@ -17,7 +17,7 @@ import abc
import six import six
import traceback import traceback
from kuryr.lib._i18n import _LE from kuryr.lib._i18n import _
from oslo_log import log as logging from oslo_log import log as logging
from oslo_serialization import jsonutils from oslo_serialization import jsonutils
@ -88,7 +88,7 @@ class CNIRunner(object):
elif params.CNI_COMMAND == 'VERSION': elif params.CNI_COMMAND == 'VERSION':
self._write_version(fout) self._write_version(fout)
else: else:
raise k_exc.CNIError(_LE("unknown CNI_COMMAND: %s") raise k_exc.CNIError(_("unknown CNI_COMMAND: %s")
% params.CNI_COMMAND) % params.CNI_COMMAND)
except Exception as ex: except Exception as ex:
# LOG.exception # LOG.exception

View File

@ -12,7 +12,7 @@
import os import os
import sys import sys
from kuryr.lib._i18n import _, _LI from kuryr.lib._i18n import _
from kuryr.lib import config as lib_config from kuryr.lib import config as lib_config
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging from oslo_log import log as logging
@ -104,7 +104,6 @@ def setup_logging():
logging.setup(CONF, 'kuryr-kubernetes') logging.setup(CONF, 'kuryr-kubernetes')
logging.set_defaults(default_log_levels=logging.get_default_log_levels()) logging.set_defaults(default_log_levels=logging.get_default_log_levels())
version_k8s = pbr.version.VersionInfo('kuryr-kubernetes').version_string() version_k8s = pbr.version.VersionInfo('kuryr-kubernetes').version_string()
LOG.info(_LI("Logging enabled!")) LOG.info("Logging enabled!")
LOG.info(_LI("%(prog)s version %(version)s"), LOG.info("%(prog)s version %(version)s",
{'prog': sys.argv[0], {'prog': sys.argv[0], 'version': version_k8s})
'version': version_k8s})

View File

@ -16,7 +16,7 @@
import abc import abc
import six import six
from kuryr.lib._i18n import _LE from kuryr.lib._i18n import _
from stevedore import driver as stv_driver from stevedore import driver as stv_driver
from kuryr_kubernetes import config from kuryr_kubernetes import config
@ -67,11 +67,11 @@ class DriverBase(object):
driver = manager.driver driver = manager.driver
if not isinstance(driver, cls): if not isinstance(driver, cls):
raise TypeError(_LE("Invalid %(alias)r driver type: %(driver)s, " raise TypeError(_("Invalid %(alias)r driver type: %(driver)s, "
"must be a subclass of %(type)s") % { "must be a subclass of %(type)s") % {
'alias': alias, 'alias': alias,
'driver': driver.__class__.__name__, 'driver': driver.__class__.__name__,
'type': cls}) 'type': cls})
return driver return driver

View File

@ -13,7 +13,7 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from kuryr.lib._i18n import _LE from kuryr.lib._i18n import _
from kuryr.lib import constants as kl_const from kuryr.lib import constants as kl_const
from neutronclient.common import exceptions as n_exc from neutronclient.common import exceptions as n_exc
from oslo_log import log as logging from oslo_log import log as logging
@ -82,7 +82,7 @@ class GenericPodVIFDriver(base.PodVIFDriver):
ids = ovu.osvif_to_neutron_network_ids(subnets) ids = ovu.osvif_to_neutron_network_ids(subnets)
if len(ids) != 1: if len(ids) != 1:
raise k_exc.IntegrityError(_LE( raise k_exc.IntegrityError(_(
"Subnet mapping %(subnets)s is not valid: %(num_networks)s " "Subnet mapping %(subnets)s is not valid: %(num_networks)s "
"unique networks found") % { "unique networks found") % {
'subnets': subnets, 'subnets': subnets,

View File

@ -13,7 +13,6 @@
# under the License. # under the License.
from time import sleep from time import sleep
from kuryr.lib._i18n import _LE
from kuryr.lib import constants as kl_const from kuryr.lib import constants as kl_const
from kuryr.lib import segmentation_type_drivers as seg_driver from kuryr.lib import segmentation_type_drivers as seg_driver
from neutronclient.common import exceptions as n_exc from neutronclient.common import exceptions as n_exc
@ -81,9 +80,9 @@ class NestedVlanPodVIFDriver(generic_vif.GenericPodVIFDriver):
try: try:
return port['trunk_details']['trunk_id'] return port['trunk_details']['trunk_id']
except KeyError: except KeyError:
LOG.error(_LE("Neutron port is missing trunk details. " LOG.error("Neutron port is missing trunk details. "
"Please ensure that k8s node port is associated " "Please ensure that k8s node port is associated "
"with a Neutron vlan trunk")) "with a Neutron vlan trunk")
raise k_exc.K8sNodeTrunkPortFailure raise k_exc.K8sNodeTrunkPortFailure
def _get_parent_port(self, neutron, pod): def _get_parent_port(self, neutron, pod):
@ -100,7 +99,7 @@ class NestedVlanPodVIFDriver(generic_vif.GenericPodVIFDriver):
if pod['status']['conditions'][0]['type'] != "Initialized": if pod['status']['conditions'][0]['type'] != "Initialized":
LOG.debug("Pod condition type is not 'Initialized'") LOG.debug("Pod condition type is not 'Initialized'")
LOG.error(_LE("Failed to get parent vm port ip")) LOG.error("Failed to get parent vm port ip")
raise raise
try: try:
@ -108,15 +107,15 @@ class NestedVlanPodVIFDriver(generic_vif.GenericPodVIFDriver):
'ip_address=%s' % str(node_fixed_ip)] 'ip_address=%s' % str(node_fixed_ip)]
ports = neutron.list_ports(fixed_ips=fixed_ips) ports = neutron.list_ports(fixed_ips=fixed_ips)
except n_exc.NeutronClientException as ex: except n_exc.NeutronClientException as ex:
LOG.error(_LE("Parent vm port with fixed ips %s not found!"), LOG.error("Parent vm port with fixed ips %s not found!",
fixed_ips) fixed_ips)
raise ex raise ex
if ports['ports']: if ports['ports']:
return ports['ports'][0] return ports['ports'][0]
else: else:
LOG.error(_LE("Neutron port for vm port with fixed ips %s" LOG.error("Neutron port for vm port with fixed ips %s"
" not found!"), fixed_ips) " not found!", fixed_ips)
raise k_exc.K8sNodeTrunkPortFailure raise k_exc.K8sNodeTrunkPortFailure
def _add_subport(self, neutron, trunk_id, subport): def _add_subport(self, neutron, trunk_id, subport):
@ -135,8 +134,8 @@ class NestedVlanPodVIFDriver(generic_vif.GenericPodVIFDriver):
try: try:
vlan_id = self._get_vlan_id(trunk_id) vlan_id = self._get_vlan_id(trunk_id)
except n_exc.NeutronClientException as ex: except n_exc.NeutronClientException as ex:
LOG.error(_LE("Getting VlanID for subport on " LOG.error("Getting VlanID for subport on "
"trunk %s failed!!"), trunk_id) "trunk %s failed!!", trunk_id)
raise ex raise ex
subport = [{'segmentation_id': vlan_id, subport = [{'segmentation_id': vlan_id,
'port_id': subport, 'port_id': subport,
@ -146,19 +145,19 @@ class NestedVlanPodVIFDriver(generic_vif.GenericPodVIFDriver):
{'sub_ports': subport}) {'sub_ports': subport})
except n_exc.Conflict as ex: except n_exc.Conflict as ex:
if retry_count < DEFAULT_MAX_RETRY_COUNT: if retry_count < DEFAULT_MAX_RETRY_COUNT:
LOG.error(_LE("vlanid already in use on trunk, " LOG.error("vlanid already in use on trunk, "
"%s. Retrying..."), trunk_id) "%s. Retrying...", trunk_id)
retry_count += 1 retry_count += 1
sleep(DEFAULT_RETRY_INTERVAL) sleep(DEFAULT_RETRY_INTERVAL)
continue continue
else: else:
LOG.error(_LE( LOG.error(
"MAX retry count reached. Failed to add subport")) "MAX retry count reached. Failed to add subport")
raise ex raise ex
except n_exc.NeutronClientException as ex: except n_exc.NeutronClientException as ex:
LOG.error(_LE("Error happened during subport" LOG.error("Error happened during subport"
"addition to trunk, %s"), trunk_id) "addition to trunk, %s", trunk_id)
raise ex raise ex
return vlan_id return vlan_id
@ -168,9 +167,9 @@ class NestedVlanPodVIFDriver(generic_vif.GenericPodVIFDriver):
neutron.trunk_remove_subports(trunk_id, neutron.trunk_remove_subports(trunk_id,
{'sub_ports': subport_id}) {'sub_ports': subport_id})
except n_exc.NeutronClientException as ex: except n_exc.NeutronClientException as ex:
LOG.error(_LE( LOG.error(
"Error happened during subport removal from trunk," "Error happened during subport removal from "
"%s"), trunk_id) "trunk, %s", trunk_id)
raise ex raise ex
def _get_vlan_id(self, trunk_id): def _get_vlan_id(self, trunk_id):

View File

@ -13,7 +13,7 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from kuryr.lib._i18n import _LE from kuryr.lib._i18n import _
from oslo_log import log as logging from oslo_log import log as logging
from oslo_serialization import jsonutils from oslo_serialization import jsonutils
import six import six
@ -64,7 +64,7 @@ class LBaaSSpecHandler(k8s_base.ResourceEventHandler):
if ip in subnet.cidr} if ip in subnet.cidr}
if len(subnet_ids) != 1: if len(subnet_ids) != 1:
raise k_exc.IntegrityError(_LE( raise k_exc.IntegrityError(_(
"Found %(num)s subnets for service %(link)s IP %(ip)s") % { "Found %(num)s subnets for service %(link)s IP %(ip)s") % {
'link': service['metadata']['selfLink'], 'link': service['metadata']['selfLink'],
'ip': ip, 'ip': ip,
@ -138,7 +138,7 @@ class LBaaSSpecHandler(k8s_base.ResourceEventHandler):
link_parts = svc_link.split('/') link_parts = svc_link.split('/')
if link_parts[-2] != 'services': if link_parts[-2] != 'services':
raise k_exc.IntegrityError(_LE( raise k_exc.IntegrityError(_(
"Unsupported service link: %(link)s") % { "Unsupported service link: %(link)s") % {
'link': svc_link}) 'link': svc_link})
link_parts[-2] = 'endpoints' link_parts[-2] = 'endpoints'

View File

@ -15,7 +15,6 @@
import sys import sys
from kuryr.lib._i18n import _LI
import os_vif import os_vif
from oslo_log import log as logging from oslo_log import log as logging
from oslo_service import service from oslo_service import service
@ -48,17 +47,17 @@ class KuryrK8sService(service.Service):
pipeline.register(h_lbaas.LBaaSSpecHandler()) pipeline.register(h_lbaas.LBaaSSpecHandler())
def start(self): def start(self):
LOG.info(_LI("Service '%s' starting"), self.__class__.__name__) LOG.info("Service '%s' starting", self.__class__.__name__)
super(KuryrK8sService, self).start() super(KuryrK8sService, self).start()
self.watcher.start() self.watcher.start()
LOG.info(_LI("Service '%s' started"), self.__class__.__name__) LOG.info("Service '%s' started", self.__class__.__name__)
def wait(self): def wait(self):
super(KuryrK8sService, self).wait() super(KuryrK8sService, self).wait()
LOG.info(_LI("Service '%s' stopped"), self.__class__.__name__) LOG.info("Service '%s' stopped", self.__class__.__name__)
def stop(self, graceful=False): def stop(self, graceful=False):
LOG.info(_LI("Service '%s' stopping"), self.__class__.__name__) LOG.info("Service '%s' stopping", self.__class__.__name__)
self.watcher.stop() self.watcher.stop()
super(KuryrK8sService, self).stop(graceful) super(KuryrK8sService, self).stop(graceful)

View File

@ -13,8 +13,6 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from kuryr.lib._i18n import _LE
class K8sClientException(Exception): class K8sClientException(Exception):
pass pass
@ -26,7 +24,7 @@ class IntegrityError(RuntimeError):
class ResourceNotReady(Exception): class ResourceNotReady(Exception):
def __init__(self, resource): def __init__(self, resource):
super(ResourceNotReady, self).__init__(_LE("Resource not ready: %r") super(ResourceNotReady, self).__init__("Resource not ready: %r"
% resource) % resource)

View File

@ -17,7 +17,6 @@ import itertools
from six.moves import queue as six_queue from six.moves import queue as six_queue
import time import time
from kuryr.lib._i18n import _LC
from oslo_log import log as logging from oslo_log import log as logging
@ -104,8 +103,8 @@ class Async(base.EventHandler):
queue = self._queues.pop(group) queue = self._queues.pop(group)
if not queue.empty(): if not queue.empty():
LOG.critical(_LC("Asynchronous handler terminated abnormally; " LOG.critical("Asynchronous handler terminated abnormally; "
"%(count)s events dropped for %(group)s"), "%(count)s events dropped for %(group)s",
{'count': queue.qsize(), 'group': group}) {'count': queue.qsize(), 'group': group})
if not self._queues: if not self._queues:

View File

@ -13,7 +13,6 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from kuryr.lib._i18n import _LE
from oslo_log import log as logging from oslo_log import log as logging
from kuryr_kubernetes.handlers import base from kuryr_kubernetes.handlers import base
@ -37,4 +36,4 @@ class LogExceptions(base.EventHandler):
try: try:
self._handler(event) self._handler(event)
except self._exceptions: except self._exceptions:
LOG.exception(_LE("Failed to handle event %s"), event) LOG.exception("Failed to handle event %s", event)

View File

@ -19,7 +19,6 @@
""" Implements linux net utils""" """ Implements linux net utils"""
from kuryr.lib._i18n import _LE
from oslo_concurrency import processutils from oslo_concurrency import processutils
from oslo_log import log as logging from oslo_log import log as logging
@ -34,7 +33,7 @@ def _ovs_vsctl(args, timeout=None):
try: try:
return processutils.execute(*full_args, run_as_root=True) return processutils.execute(*full_args, run_as_root=True)
except Exception as e: except Exception as e:
LOG.error(_LE("Unable to execute %(cmd)s. Exception: %(exception)s"), LOG.error("Unable to execute %(cmd)s. Exception: %(exception)s",
{'cmd': full_args, 'exception': e}) {'cmd': full_args, 'exception': e})
raise raise

View File

@ -15,7 +15,7 @@
import six import six
from kuryr.lib._i18n import _LE from kuryr.lib._i18n import _
from kuryr.lib.binding.drivers import utils as kl_utils from kuryr.lib.binding.drivers import utils as kl_utils
from kuryr.lib import constants as kl_const from kuryr.lib import constants as kl_const
from os_vif.objects import fixed_ip as osv_fixed_ip from os_vif.objects import fixed_ip as osv_fixed_ip
@ -100,7 +100,7 @@ def _make_vif_subnet(subnets, subnet_id):
network = subnets[subnet_id] network = subnets[subnet_id]
if len(network.subnets.objects) != 1: if len(network.subnets.objects) != 1:
raise k_exc.IntegrityError(_LE( raise k_exc.IntegrityError(_(
"Network object for subnet %(subnet_id)s is invalid, " "Network object for subnet %(subnet_id)s is invalid, "
"must contain a single subnet, but %(num_subnets)s found") % { "must contain a single subnet, but %(num_subnets)s found") % {
'subnet_id': subnet_id, 'subnet_id': subnet_id,
@ -138,7 +138,7 @@ def _make_vif_subnets(neutron_port, subnets):
subnet.ips.objects.append(osv_fixed_ip.FixedIP(address=ip_address)) subnet.ips.objects.append(osv_fixed_ip.FixedIP(address=ip_address))
if not vif_subnets: if not vif_subnets:
raise k_exc.IntegrityError(_LE( raise k_exc.IntegrityError(_(
"No valid subnets found for port %(port_id)s") % { "No valid subnets found for port %(port_id)s") % {
'port_id': neutron_port.get('id')}) 'port_id': neutron_port.get('id')})
@ -158,7 +158,7 @@ def _make_vif_network(neutron_port, subnets):
network = next(net.obj_clone() for net in subnets.values() network = next(net.obj_clone() for net in subnets.values()
if net.id == neutron_port.get('network_id')) if net.id == neutron_port.get('network_id'))
except StopIteration: except StopIteration:
raise k_exc.IntegrityError(_LE( raise k_exc.IntegrityError(_(
"Port %(port_id)s belongs to network %(network_id)s, " "Port %(port_id)s belongs to network %(network_id)s, "
"but requested networks are: %(requested_networks)s") % { "but requested networks are: %(requested_networks)s") % {
'port_id': neutron_port.get('id'), 'port_id': neutron_port.get('id'),
@ -303,7 +303,7 @@ def osvif_to_neutron_fixed_ips(subnets):
for subnet_id, network in six.iteritems(subnets): for subnet_id, network in six.iteritems(subnets):
ips = [] ips = []
if len(network.subnets.objects) > 1: if len(network.subnets.objects) > 1:
raise k_exc.IntegrityError(_LE( raise k_exc.IntegrityError(_(
"Network object for subnet %(subnet_id)s is invalid, " "Network object for subnet %(subnet_id)s is invalid, "
"must contain a single subnet, but %(num_subnets)s found") % { "must contain a single subnet, but %(num_subnets)s found") % {
'subnet_id': subnet_id, 'subnet_id': subnet_id,

View File

@ -13,7 +13,6 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from kuryr.lib._i18n import _LI
from oslo_log import log as logging from oslo_log import log as logging
from kuryr_kubernetes import clients from kuryr_kubernetes import clients
@ -135,7 +134,7 @@ class Watcher(object):
def _watch(self, path): def _watch(self, path):
try: try:
LOG.info(_LI("Started watching '%s'"), path) LOG.info("Started watching '%s'", path)
for event in self._client.watch(path): for event in self._client.watch(path):
self._idle[path] = False self._idle[path] = False
self._handler(event) self._handler(event)
@ -145,4 +144,4 @@ class Watcher(object):
finally: finally:
self._watching.pop(path) self._watching.pop(path)
self._idle.pop(path) self._idle.pop(path)
LOG.info(_LI("Stopped watching '%s'"), path) LOG.info("Stopped watching '%s'", path)

View File

@ -53,7 +53,8 @@ commands = python setup.py build_sphinx
# E265 block comment should start with '# ' # E265 block comment should start with '# '
# TODO(dougwig) -- uncomment this to test for remaining linkages # TODO(dougwig) -- uncomment this to test for remaining linkages
# N530 direct neutron imports not allowed # N530 direct neutron imports not allowed
ignore = E125,E126,E128,E129,E265,H301,N530 # N531 log message does not translate
ignore = E125,E126,E128,E129,E265,H301,N530,N531
show-source = true show-source = true
# TODO(dougw) neutron/tests/unit/vmware exclusion is a temporary services split hack # TODO(dougw) neutron/tests/unit/vmware exclusion is a temporary services split hack