delete unused log translations in kuryr_libnetwork

recent discussions on the ML have led to the decision to eliminate all
translations for messages that are destined for log files but retain
them for messages that are going to be returned as exceptions and
potentially shown to end users via an API. see [1], [2].

This change does that as follows.

1. If a string is being used to generate an exception, it will still be translated.
Still kuryr_libnetwork used _LE, _LW, _LI for these translations

2. If a string is used for a logging message, remove the use of _LE, _LW, _LI.

[1] http://lists.openstack.org/pipermail/openstack-operators/2017-March/012887.html
[2] http://lists.openstack.org/pipermail/openstack-dev/2017-March/113365.html

Change-Id: Ic2efcea9a1e2e785a8678c86a0b1209d68bb2a1c
This commit is contained in:
gecong1973 2017-03-28 17:06:19 +08:00 committed by gecong
parent 837830b496
commit 793a6e52b1
7 changed files with 99 additions and 103 deletions

View File

@ -29,7 +29,7 @@ from oslo_utils import excutils
from kuryr.lib import constants as lib_const from kuryr.lib import constants as lib_const
from kuryr.lib import exceptions from kuryr.lib import exceptions
from kuryr.lib import utils as lib_utils from kuryr.lib import utils as lib_utils
from kuryr.lib._i18n import _LE, _LI, _LW
from kuryr_libnetwork import app from kuryr_libnetwork import app
from kuryr_libnetwork import config from kuryr_libnetwork import config
from kuryr_libnetwork import constants as const from kuryr_libnetwork import constants as const
@ -84,8 +84,8 @@ def check_for_neutron_tag_support(ext_name):
except n_exceptions.NeutronClientException as e: except n_exceptions.NeutronClientException as e:
setattr(app, ext_rename, False) setattr(app, ext_rename, False)
if e.status_code == n_exceptions.NotFound.status_code: if e.status_code == n_exceptions.NotFound.status_code:
LOG.warning(_LW("Neutron extension %s not supported. " LOG.warning("Neutron extension %s not supported. "
"Continue without using them."), ext_name) "Continue without using them.", ext_name)
def load_default_subnet_pools(): def load_default_subnet_pools():
@ -113,8 +113,8 @@ def _cache_default_subnetpool_ids(app):
for subnetpool in subnetpools['subnetpools']: for subnetpool in subnetpools['subnetpools']:
default_subnetpool_id_set.add(subnetpool['id']) default_subnetpool_id_set.add(subnetpool['id'])
except n_exceptions.NeutronClientException as ex: except n_exceptions.NeutronClientException as ex:
LOG.error(_LE("Error happened during retrieving the default" LOG.error("Error happened during retrieving the default"
" subnet pools: %s"), ex) " subnet pools: %s", ex)
app.DEFAULT_POOL_IDS = frozenset(default_subnetpool_id_set) app.DEFAULT_POOL_IDS = frozenset(default_subnetpool_id_set)
@ -207,8 +207,8 @@ def _create_port(endpoint_id, neutron_network_id, interface_mac, fixed_ips):
try: try:
rcvd_port = app.neutron.create_port({'port': port}) rcvd_port = app.neutron.create_port({'port': port})
except n_exceptions.NeutronClientException as ex: except n_exceptions.NeutronClientException as ex:
LOG.error(_LE("Error happened during creating a" LOG.error("Error happened during creating a"
" Neutron port: %s"), ex) " Neutron port: %s", ex)
raise raise
return rcvd_port['port'] return rcvd_port['port']
@ -325,9 +325,9 @@ def _neutron_add_tag(resource_type, resource_id, tag):
try: try:
app.neutron.add_tag(resource_type, resource_id, tag) app.neutron.add_tag(resource_type, resource_id, tag)
except n_exceptions.NotFound: except n_exceptions.NotFound:
LOG.warning(_LW("Neutron tags extension for given " LOG.warning("Neutron tags extension for given "
"resource type is not supported, " "resource type is not supported, "
"cannot add tag to %s."), resource_type) "cannot add tag to %s.", resource_type)
def _neutron_remove_tag(resource_type, resource_id, tag): def _neutron_remove_tag(resource_type, resource_id, tag):
@ -353,8 +353,8 @@ def _port_active(neutron_port_id, vif_plug_timeout):
try: try:
port = app.neutron.show_port(neutron_port_id) port = app.neutron.show_port(neutron_port_id)
except n_exceptions.NeutronClientException as ex: except n_exceptions.NeutronClientException as ex:
LOG.error(_LE('Could not get the port %s to check ' LOG.error('Could not get the port %s to check '
'its status'), ex) 'its status', ex)
else: else:
if port['port']['status'] == lib_const.PORT_STATUS_ACTIVE: if port['port']['status'] == lib_const.PORT_STATUS_ACTIVE:
port_active = True port_active = True
@ -381,8 +381,8 @@ def _program_expose_ports(options, port_id):
sg_id = sg['security_group']['id'] sg_id = sg['security_group']['id']
except n_exceptions.NeutronClientException as ex: except n_exceptions.NeutronClientException as ex:
LOG.error(_LE("Error happened during creating a " LOG.error("Error happened during creating a "
"Neutron security group: %s"), ex) "Neutron security group: %s", ex)
raise exceptions.ExportPortFailure( raise exceptions.ExportPortFailure(
("Could not create required security group {0} " ("Could not create required security group {0} "
"for setting up exported port ").format(sec_group)) "for setting up exported port ").format(sec_group))
@ -396,7 +396,7 @@ def _program_expose_ports(options, port_id):
proto_port_dict[proto].append(port) proto_port_dict[proto].append(port)
except KeyError: except KeyError:
# This should not happen as Docker client catches such errors # This should not happen as Docker client catches such errors
LOG.error(_LE("Unrecognizable protocol %s"), proto) LOG.error("Unrecognizable protocol %s", proto)
app.neutron.delete_security_group(sg_id) app.neutron.delete_security_group(sg_id)
raise exceptions.ExportPortFailure( raise exceptions.ExportPortFailure(
("Bad protocol number for exposed port. Deleting " ("Bad protocol number for exposed port. Deleting "
@ -422,9 +422,9 @@ def _program_expose_ports(options, port_id):
app.neutron.create_security_group_rule({'security_group_rule': app.neutron.create_security_group_rule({'security_group_rule':
sec_group_rule}) sec_group_rule})
except n_exceptions.NeutronClientException as ex: except n_exceptions.NeutronClientException as ex:
LOG.error(_LE("Error happened during creating a " LOG.error("Error happened during creating a "
"Neutron security group " "Neutron security group "
"rule: %s"), ex) "rule: %s", ex)
app.neutron.delete_security_group(sg_id) app.neutron.delete_security_group(sg_id)
raise exceptions.ExportPortFailure( raise exceptions.ExportPortFailure(
("Could not create required security group rules {0} " ("Could not create required security group rules {0} "
@ -442,8 +442,8 @@ def _program_expose_ports(options, port_id):
app.neutron.update_port(port_id, app.neutron.update_port(port_id,
{'port': {'security_groups': sgs}}) {'port': {'security_groups': sgs}})
except n_exceptions.NeutronClientException as ex: except n_exceptions.NeutronClientException as ex:
LOG.error(_LE("Error happened during updating a " LOG.error("Error happened during updating a "
"Neutron port: %s"), ex) "Neutron port: %s", ex)
app.neutron.delete_security_group(sg_id) app.neutron.delete_security_group(sg_id)
raise exceptions.ExportPortFailure( raise exceptions.ExportPortFailure(
("Could not update port with required security groups{0} " ("Could not update port with required security groups{0} "
@ -457,8 +457,8 @@ def _get_cidr_from_subnetpool(**kwargs):
pool_id = pool['id'] pool_id = pool['id']
prefixes = pool['prefixes'] prefixes = pool['prefixes']
if len(prefixes) > 1: if len(prefixes) > 1:
LOG.warning(_LW("More than one prefixes present. " LOG.warning("More than one prefixes present. "
"Picking first one.")) "Picking first one.")
return ipaddress.ip_network(six.text_type(prefixes[0])), pool_id return ipaddress.ip_network(six.text_type(prefixes[0])), pool_id
else: else:
@ -514,15 +514,15 @@ def revoke_expose_ports(port_id):
{'port': {'port':
{'security_groups': existing_sgs}}) {'security_groups': existing_sgs}})
except n_exceptions.NeutronClientException as ex: except n_exceptions.NeutronClientException as ex:
LOG.error(_LE("Error happened during updating a " LOG.error("Error happened during updating a "
"Neutron port with a new list of " "Neutron port with a new list of "
"security groups: {0}").format(ex)) "security groups: {0}".format(ex))
try: try:
for sg in removing_sgs: for sg in removing_sgs:
app.neutron.delete_security_group(sg) app.neutron.delete_security_group(sg)
except n_exceptions.NeutronClientException as ex: except n_exceptions.NeutronClientException as ex:
LOG.error(_LE("Error happened during deleting a " LOG.error("Error happened during deleting a "
"Neutron security group: {0}").format(ex)) "Neutron security group: {0}".format(ex))
def _create_kuryr_subnet(pool_cidr, subnet_cidr, pool_id, network_id, gateway): def _create_kuryr_subnet(pool_cidr, subnet_cidr, pool_id, network_id, gateway):
@ -727,8 +727,8 @@ def network_driver_create_network():
try: try:
neutron_uuid = app.driver.get_default_network_id() neutron_uuid = app.driver.get_default_network_id()
except n_exceptions.NeutronClientException as ex: except n_exceptions.NeutronClientException as ex:
LOG.error(_LE("Failed to retrieve the default driver " LOG.error("Failed to retrieve the default driver "
"network due to Neutron error: %s"), ex) "network due to Neutron error: %s", ex)
raise raise
if not neutron_uuid and not neutron_name: if not neutron_uuid and not neutron_name:
@ -739,8 +739,8 @@ def network_driver_create_network():
_neutron_net_add_tags(network['network']['id'], container_net_id, _neutron_net_add_tags(network['network']['id'], container_net_id,
tags=app.tag) tags=app.tag)
LOG.info(_LI("Created a new network with name " LOG.info("Created a new network with name "
"%(neutron_network_name)s successfully: %(network)s"), "%(neutron_network_name)s successfully: %(network)s",
{'neutron_network_name': neutron_network_name, {'neutron_network_name': neutron_network_name,
'network': network}) 'network': network})
else: else:
@ -757,8 +757,8 @@ def network_driver_create_network():
"exist.").format(specified_network)) "exist.").format(specified_network))
network_id = networks[0]['id'] network_id = networks[0]['id']
except n_exceptions.NeutronClientException as ex: except n_exceptions.NeutronClientException as ex:
LOG.error(_LE("Error happened during listing " LOG.error("Error happened during listing "
"Neutron networks: %s"), ex) "Neutron networks: %s", ex)
raise raise
if app.tag: if app.tag:
_neutron_net_add_tags(network_id, container_net_id, tags=app.tag) _neutron_net_add_tags(network_id, container_net_id, tags=app.tag)
@ -766,12 +766,12 @@ def network_driver_create_network():
else: else:
network = app.neutron.update_network( network = app.neutron.update_network(
neutron_uuid, {'network': {'name': neutron_network_name}}) neutron_uuid, {'network': {'name': neutron_network_name}})
LOG.info(_LI("Updated the network with new name " LOG.info("Updated the network with new name "
"%(neutron_network_name)s successfully: %(network)s"), "%(neutron_network_name)s successfully: %(network)s",
{'neutron_network_name': neutron_network_name, {'neutron_network_name': neutron_network_name,
'network': network}) 'network': network})
LOG.info(_LI("Using existing network %s " LOG.info("Using existing network %s "
"successfully"), specified_network) "successfully", specified_network)
def _get_existing_neutron_subnets(pool_cidr, network_id): def _get_existing_neutron_subnets(pool_cidr, network_id):
cidr = None cidr = None
@ -841,14 +841,14 @@ def network_driver_delete_network():
existing_networks = _get_networks_by_identifier( existing_networks = _get_networks_by_identifier(
existing_network_identifier) existing_network_identifier)
except n_exceptions.NeutronClientException as ex: except n_exceptions.NeutronClientException as ex:
LOG.error(_LE("Error happened during listing " LOG.error("Error happened during listing "
"Neutron networks: %s"), ex) "Neutron networks: %s", ex)
raise raise
if existing_networks: if existing_networks:
LOG.warning(_LW("Network is a pre existing Neutron " LOG.warning("Network is a pre existing Neutron "
"network, not deleting in Neutron. " "network, not deleting in Neutron. "
"removing tags: %s"), existing_network_identifier) "removing tags: %s", existing_network_identifier)
neutron_net_id = existing_networks[0]['id'] neutron_net_id = existing_networks[0]['id']
_neutron_net_remove_tags(neutron_net_id, container_net_id) _neutron_net_remove_tags(neutron_net_id, container_net_id)
_neutron_net_remove_tag(neutron_net_id, _neutron_net_remove_tag(neutron_net_id,
@ -862,23 +862,23 @@ def network_driver_delete_network():
if str(subnet_name).startswith(const.SUBNET_NAME_PREFIX): if str(subnet_name).startswith(const.SUBNET_NAME_PREFIX):
app.neutron.delete_subnet(subnet['id']) app.neutron.delete_subnet(subnet['id'])
except n_exceptions.Conflict as ex: except n_exceptions.Conflict as ex:
LOG.error(_LE("Subnet %s is in use, " LOG.error("Subnet %s is in use, "
"can't be deleted."), subnet['id']) "can't be deleted.", subnet['id'])
except n_exceptions.NeutronClientException as ex: except n_exceptions.NeutronClientException as ex:
LOG.error(_LE("Error happened during deleting a " LOG.error("Error happened during deleting a "
"subnet created by kuryr: %s"), ex) "subnet created by kuryr: %s", ex)
return flask.jsonify(const.SCHEMA['SUCCESS']) return flask.jsonify(const.SCHEMA['SUCCESS'])
try: try:
filtered_networks = _get_networks_by_identifier( filtered_networks = _get_networks_by_identifier(
neutron_network_identifier) neutron_network_identifier)
except n_exceptions.NeutronClientException as ex: except n_exceptions.NeutronClientException as ex:
LOG.error(_LE("Error happened during listing " LOG.error("Error happened during listing "
"Neutron networks: %s"), ex) "Neutron networks: %s", ex)
raise raise
if not filtered_networks: if not filtered_networks:
LOG.warning(_LW("Network with identifier %s cannot be found"), LOG.warning("Network with identifier %s cannot be found",
neutron_network_identifier) neutron_network_identifier)
else: else:
neutron_network_id = filtered_networks[0]['id'] neutron_network_id = filtered_networks[0]['id']
@ -904,22 +904,22 @@ def network_driver_delete_network():
# and continue to proceed. # and continue to proceed.
app.neutron.delete_subnet(subnet['id']) app.neutron.delete_subnet(subnet['id'])
except n_exceptions.Conflict as ex: except n_exceptions.Conflict as ex:
LOG.error(_LE("Subnet, %s, is in use. Network can't " LOG.error("Subnet, %s, is in use. Network can't "
"be deleted."), subnet['id']) "be deleted.", subnet['id'])
raise raise
except n_exceptions.NeutronClientException as ex: except n_exceptions.NeutronClientException as ex:
LOG.error(_LE("Error happened during deleting a " LOG.error("Error happened during deleting a "
"Neutron subnets: %s"), ex) "Neutron subnets: %s", ex)
raise raise
try: try:
app.neutron.delete_network(neutron_network_id) app.neutron.delete_network(neutron_network_id)
except n_exceptions.NeutronClientException as ex: except n_exceptions.NeutronClientException as ex:
LOG.error(_LE("Error happened during deleting a " LOG.error("Error happened during deleting a "
"Neutron network: %s"), ex) "Neutron network: %s", ex)
raise raise
LOG.info(_LI("Deleted the network with ID %s " LOG.info("Deleted the network with ID %s "
"successfully"), neutron_network_id) "successfully", neutron_network_id)
return flask.jsonify(const.SCHEMA['SUCCESS']) return flask.jsonify(const.SCHEMA['SUCCESS'])
@ -994,16 +994,16 @@ def network_driver_create_endpoint():
except (exceptions.VethCreationFailure, except (exceptions.VethCreationFailure,
exceptions.BindingNotSupportedFailure) as ex: exceptions.BindingNotSupportedFailure) as ex:
with excutils.save_and_reraise_exception(): with excutils.save_and_reraise_exception():
LOG.error(_LE('Preparing the veth ' LOG.error('Preparing the veth '
'pair was failed: %s.'), ex) 'pair was failed: %s.', ex)
except processutils.ProcessExecutionError: except processutils.ProcessExecutionError:
with excutils.save_and_reraise_exception(): with excutils.save_and_reraise_exception():
LOG.error(_LE('Could not bind the Neutron port to ' LOG.error('Could not bind the Neutron port to '
'the veth endpoint.')) 'the veth endpoint.')
except (exceptions.KuryrException, except (exceptions.KuryrException,
n_exceptions.NeutronClientException) as ex: n_exceptions.NeutronClientException) as ex:
with excutils.save_and_reraise_exception(): with excutils.save_and_reraise_exception():
LOG.error(_LE('Failed to set up the interface: %s'), ex) LOG.error('Failed to set up the interface: %s', ex)
if app.vif_plug_is_fatal: if app.vif_plug_is_fatal:
port_active = _port_active(neutron_port['id'], port_active = _port_active(neutron_port['id'],
@ -1109,15 +1109,15 @@ def network_driver_delete_endpoint():
LOG.error(stderr) LOG.error(stderr)
except processutils.ProcessExecutionError: except processutils.ProcessExecutionError:
with excutils.save_and_reraise_exception(): with excutils.save_and_reraise_exception():
LOG.error(_LE('Could not unbind the Neutron port from' LOG.error('Could not unbind the Neutron port from'
'the veth endpoint.')) 'the veth endpoint.')
except exceptions.VethDeletionFailure: except exceptions.VethDeletionFailure:
with excutils.save_and_reraise_exception(): with excutils.save_and_reraise_exception():
LOG.error(_LE('Cleaning the veth pair up was failed.')) LOG.error('Cleaning the veth pair up was failed.')
except (exceptions.KuryrException, except (exceptions.KuryrException,
n_exceptions.NeutronClientException) as ex: n_exceptions.NeutronClientException) as ex:
with excutils.save_and_reraise_exception(): with excutils.save_and_reraise_exception():
LOG.error(_LE('Error while removing the interface: %s'), ex) LOG.error('Error while removing the interface: %s', ex)
return flask.jsonify(const.SCHEMA['SUCCESS']) return flask.jsonify(const.SCHEMA['SUCCESS'])
@ -1377,9 +1377,9 @@ def ipam_request_pool():
subnet_cidr = six.text_type(cidr) subnet_cidr = six.text_type(cidr)
subnets_by_cidr = _get_subnets_by_attrs(cidr=subnet_cidr) subnets_by_cidr = _get_subnets_by_attrs(cidr=subnet_cidr)
if len(subnets_by_cidr): if len(subnets_by_cidr):
LOG.warning(_LW("There is already existing subnet for the " LOG.warning("There is already existing subnet for the "
"same cidr. Please check and specify pool name " "same cidr. Please check and specify pool name "
"in Options.")) "in Options.")
if not pool_name and not pool_id: if not pool_name and not pool_id:
pool_name = lib_utils.get_neutron_subnetpool_name(subnet_cidr) pool_name = lib_utils.get_neutron_subnetpool_name(subnet_cidr)
pools = _get_subnetpools_by_attrs(name=pool_name) pools = _get_subnetpools_by_attrs(name=pool_name)
@ -1392,7 +1392,7 @@ def ipam_request_pool():
'name': pool_name, 'name': pool_name,
'default_prefixlen': cidr.prefixlen, 'default_prefixlen': cidr.prefixlen,
'prefixes': [subnet_cidr]} 'prefixes': [subnet_cidr]}
LOG.info(_LI("Creating subnetpool with the given pool CIDR")) LOG.info("Creating subnetpool with the given pool CIDR")
created_subnetpool_response = app.neutron.create_subnetpool( created_subnetpool_response = app.neutron.create_subnetpool(
{'subnetpool': new_subnetpool}) {'subnetpool': new_subnetpool})
pool = created_subnetpool_response['subnetpool'] pool = created_subnetpool_response['subnetpool']
@ -1407,7 +1407,7 @@ def ipam_request_pool():
("Specified subnetpool id/name({0}) does not " ("Specified subnetpool id/name({0}) does not "
"exist.").format(pool_id or pool_name)) "exist.").format(pool_id or pool_name))
pool_id = existing_pools[0]['id'] pool_id = existing_pools[0]['id']
LOG.info(_LI("Using existing Neutron subnetpool %s successfully"), LOG.info("Using existing Neutron subnetpool %s successfully",
pool_id) pool_id)
else: else:
if v6: if v6:
@ -1488,9 +1488,9 @@ def ipam_request_address():
if pool_id in tmp_subnet.get('tags'): if pool_id in tmp_subnet.get('tags'):
subnet = tmp_subnet subnet = tmp_subnet
else: else:
LOG.warning(_LW("subnetpool tag for Neutron " LOG.warning("subnetpool tag for Neutron "
"subnet %s is missing, cannot " "subnet %s is missing, cannot "
"gets the correct subnet."), "gets the correct subnet.",
tmp_subnet['id']) tmp_subnet['id'])
elif len(subnets_by_cidr) == 1: elif len(subnets_by_cidr) == 1:
subnet = subnets_by_cidr[0] subnet = subnets_by_cidr[0]
@ -1557,8 +1557,8 @@ def ipam_request_address():
allocated_address = '{}/{}'.format(allocated_address, allocated_address = '{}/{}'.format(allocated_address,
subnet_cidr.prefixlen) subnet_cidr.prefixlen)
except n_exceptions.NeutronClientException as ex: except n_exceptions.NeutronClientException as ex:
LOG.error(_LE("Error happened during ip allocation on " LOG.error("Error happened during ip allocation on "
"Neutron side: %s"), ex) "Neutron side: %s", ex)
raise raise
else: else:
# Auxiliary address or gw_address is received at network creation time. # Auxiliary address or gw_address is received at network creation time.
@ -1618,11 +1618,11 @@ def ipam_release_pool():
try: try:
app.neutron.delete_subnetpool(pool_id) app.neutron.delete_subnetpool(pool_id)
except n_exceptions.Conflict as ex: except n_exceptions.Conflict as ex:
LOG.info(_LI("The subnetpool with ID %s is still in use." LOG.info("The subnetpool with ID %s is still in use."
" It can't be deleted for now."), pool_id) " It can't be deleted for now.", pool_id)
except n_exceptions.NeutronClientException as ex: except n_exceptions.NeutronClientException as ex:
LOG.error(_LE("Error happened during deleting a " LOG.error("Error happened during deleting a "
"Neutron subnetpool: %s"), ex) "Neutron subnetpool: %s", ex)
raise raise
return flask.jsonify(const.SCHEMA['SUCCESS']) return flask.jsonify(const.SCHEMA['SUCCESS'])
@ -1661,7 +1661,7 @@ def ipam_release_address():
subnet_cidr = six.text_type(_get_cidr_from_subnetpool(id=pool_id)[0]) subnet_cidr = six.text_type(_get_cidr_from_subnetpool(id=pool_id)[0])
subnets = _get_subnets_by_attrs(cidr=subnet_cidr) subnets = _get_subnets_by_attrs(cidr=subnet_cidr)
if not len(subnets): if not len(subnets):
LOG.info(_LI("Subnet already deleted.")) LOG.info("Subnet already deleted.")
return flask.jsonify(const.SCHEMA['SUCCESS']) return flask.jsonify(const.SCHEMA['SUCCESS'])
iface = ipaddress.ip_interface(six.text_type(rel_address)) iface = ipaddress.ip_interface(six.text_type(rel_address))
@ -1684,8 +1684,8 @@ def ipam_release_address():
_neutron_port_remove_tag(port['id'], _neutron_port_remove_tag(port['id'],
const.KURYR_EXISTING_NEUTRON_PORT) const.KURYR_EXISTING_NEUTRON_PORT)
except n_exceptions.NeutronClientException as ex: except n_exceptions.NeutronClientException as ex:
LOG.error(_LE("Error happened while fetching " LOG.error("Error happened while fetching "
"and deleting port, %s"), ex) "and deleting port, %s", ex)
raise raise
return flask.jsonify(const.SCHEMA['SUCCESS']) return flask.jsonify(const.SCHEMA['SUCCESS'])

View File

@ -18,7 +18,6 @@ from oslo_utils import importutils
from neutronclient.common import exceptions as n_exceptions from neutronclient.common import exceptions as n_exceptions
from kuryr.lib._i18n import _LE
from kuryr.lib import constants as lib_const from kuryr.lib import constants as lib_const
from kuryr.lib import exceptions from kuryr.lib import exceptions
from kuryr.lib import utils as lib_utils from kuryr.lib import utils as lib_utils
@ -142,8 +141,8 @@ class Driver(object):
response_port = app.neutron.update_port(port['id'], response_port = app.neutron.update_port(port['id'],
{'port': updated_port}) {'port': updated_port})
except n_exceptions.NeutronClientException as ex: except n_exceptions.NeutronClientException as ex:
LOG.error(_LE("Error happened during updating a " LOG.error("Error happened during updating a "
"Neutron port: %s"), ex) "Neutron port: %s", ex)
raise raise
return response_port['port'] return response_port['port']

View File

@ -13,7 +13,6 @@
from neutronclient.common import exceptions as n_exceptions from neutronclient.common import exceptions as n_exceptions
from oslo_log import log from oslo_log import log
from kuryr.lib._i18n import _LE
from kuryr.lib import binding from kuryr.lib import binding
from kuryr.lib import exceptions from kuryr.lib import exceptions
@ -152,6 +151,6 @@ class NestedDriver(base.BaseNestedDriver):
'allowed_address_pairs': address_pairs 'allowed_address_pairs': address_pairs
}}) }})
except n_exceptions.NeutronClientException as ex: except n_exceptions.NeutronClientException as ex:
LOG.error(_LE("Error happened during updating Neutron " LOG.error("Error happened during updating Neutron "
"port %(port_id)s: %(ex)s"), port_id, ex) "port %(port_id)s: %(ex)s", port_id, ex)
raise raise

View File

@ -13,7 +13,6 @@
from neutronclient.common import exceptions as n_exceptions from neutronclient.common import exceptions as n_exceptions
from oslo_log import log from oslo_log import log
from kuryr.lib._i18n import _LE
from kuryr.lib import binding from kuryr.lib import binding
from kuryr.lib import exceptions from kuryr.lib import exceptions
from kuryr.lib import segmentation_type_drivers as seg_driver from kuryr.lib import segmentation_type_drivers as seg_driver
@ -134,8 +133,8 @@ class VlanDriver(base.BaseNestedDriver):
vm_port['trunk_details']['trunk_id'], vm_port['trunk_details']['trunk_id'],
{'sub_ports': subports}) {'sub_ports': subports})
except n_exceptions.NeutronClientException as ex: except n_exceptions.NeutronClientException as ex:
LOG.error(_LE("Error happened during subport deletion " LOG.error("Error happened during subport deletion "
"%(port_id)s: %(ex)s"), "%(port_id)s: %(ex)s",
{'port_id': neutron_port['id'], 'ex': ex}) {'port_id': neutron_port['id'], 'ex': ex})
raise raise
self._release_segmentation_id(neutron_port['id']) self._release_segmentation_id(neutron_port['id'])
@ -152,8 +151,8 @@ class VlanDriver(base.BaseNestedDriver):
try: try:
app.neutron.trunk_add_subports(trunk_id, {'sub_ports': subport}) app.neutron.trunk_add_subports(trunk_id, {'sub_ports': subport})
except n_exceptions.NeutronClientException as ex: except n_exceptions.NeutronClientException as ex:
LOG.error(_LE("Error happened adding subport %(port_id)s " LOG.error("Error happened adding subport %(port_id)s "
"to trunk port %(trunk_id)s: %(ex)s"), "to trunk port %(trunk_id)s: %(ex)s",
port_id, trunk_id, ex) port_id, trunk_id, ex)
raise raise

View File

@ -15,7 +15,6 @@ import os
from keystoneauth1 import identity from keystoneauth1 import identity
from keystoneauth1 import session as ks from keystoneauth1 import session as ks
from kuryr.lib._i18n import _LW
from neutronclient.v2_0 import client from neutronclient.v2_0 import client
import os_client_config import os_client_config
from oslo_log import log from oslo_log import log
@ -88,10 +87,10 @@ class KuryrBaseTest(base.BaseTestCase):
self.neutron_client = get_neutron_client_from_env() self.neutron_client = get_neutron_client_from_env()
except Exception as e: except Exception as e:
# We may missing or didn't source configured openrc file. # We may missing or didn't source configured openrc file.
message = _LW('Missing environment variable %s in your local. ' message = ("Missing environment variable %s in your local."
'Please add it and also check other missing ' "Please add it and also check other missing "
'environment variables. After that please source ' "environment variables. After that please source "
'the openrc file. ' "the openrc file. "
'Trying credentials from DevStack cloud.yaml ...') "Trying credentials from DevStack cloud.yaml ...")
LOG.warning(message, e.args[0]) LOG.warning(message, e.args[0])
self.neutron_client = get_neutron_client_from_creds() self.neutron_client = get_neutron_client_from_creds()

View File

@ -22,7 +22,6 @@ from oslo_concurrency import processutils
from oslo_log import log from oslo_log import log
from werkzeug import exceptions as w_exceptions from werkzeug import exceptions as w_exceptions
from kuryr.lib._i18n import _LE
from kuryr.lib import exceptions from kuryr.lib import exceptions
from kuryr.lib import utils as lib_utils from kuryr.lib import utils as lib_utils
from kuryr_libnetwork import constants as const from kuryr_libnetwork import constants as const
@ -54,7 +53,7 @@ def make_json_app(import_name, **kwargs):
@app.errorhandler(jsonschema.ValidationError) @app.errorhandler(jsonschema.ValidationError)
@app.errorhandler(processutils.ProcessExecutionError) @app.errorhandler(processutils.ProcessExecutionError)
def make_json_error(ex): def make_json_error(ex):
LOG.error(_LE("Unexpected error happened: %s"), ex) LOG.error("Unexpected error happened: %s", ex)
traceback.print_exc(file=sys.stderr) traceback.print_exc(file=sys.stderr)
response = flask.jsonify({"Err": str(ex)}) response = flask.jsonify({"Err": str(ex)})
response.status_code = w_exceptions.InternalServerError.code response.status_code = w_exceptions.InternalServerError.code

View File

@ -57,7 +57,8 @@ commands = python setup.py build_sphinx
# E129 visually indented line with same indent as next logical line # E129 visually indented line with same indent as next logical line
# E265 block comment should start with '# ' # E265 block comment should start with '# '
# N530 direct neutron imports not allowed # N530 direct neutron imports not allowed
ignore = E125,E126,E128,E129,E265,H301,N530 # N531 Log messages require translation hints
ignore = E125,E126,E128,E129,E265,H301,N530,N531
show-source = true show-source = true
exclude = .venv,.git,.tox,dist,doc,*lib/python*,*egg,build,tools,.ropeproject,rally-scenarios,releasenotes exclude = .venv,.git,.tox,dist,doc,*lib/python*,*egg,build,tools,.ropeproject,rally-scenarios,releasenotes