Remove log translations from neutron-vpnaas

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: I83e9ab88b0e7084ff828b1c6afaa11bebf532e50
This commit is contained in:
liuyamin 2017-03-21 15:25:33 +08:00
parent af39435310
commit e70f1b02cd
13 changed files with 70 additions and 83 deletions

View File

@ -27,16 +27,6 @@ _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

@ -31,7 +31,7 @@ from oslo_utils import uuidutils
import sqlalchemy as sa
from sqlalchemy.orm import exc
from neutron_vpnaas._i18n import _LW
from neutron_vpnaas.db.vpn import vpn_models
from neutron_vpnaas.db.vpn import vpn_validator
from neutron_vpnaas.extensions import vpn_endpoint_groups
@ -698,7 +698,7 @@ class VPNPluginRpcDbMixin(object):
vpnservice_db = self._get_vpnservice(
context, vpnservice['id'])
except vpnaas.VPNServiceNotFound:
LOG.warning(_LW('vpnservice %s in db is already deleted'),
LOG.warning('vpnservice %s in db is already deleted',
vpnservice['id'])
continue

View File

@ -25,7 +25,7 @@ from oslo_log import log as logging
from oslo_rootwrap import wrapper
import six
from neutron_vpnaas._i18n import _, _LE, _LI
from neutron_vpnaas._i18n import _
if six.PY3:
import configparser as ConfigParser
@ -88,11 +88,11 @@ def filter_command(command, rootwrap_config):
rawconfig.read(rootwrap_config)
rw_config = wrapper.RootwrapConfig(rawconfig)
except ValueError as exc:
LOG.error(_LE('Incorrect value in %(config)s: %(exc)s'),
LOG.error('Incorrect value in %(config)s: %(exc)s',
{'config': rootwrap_config, 'exc': exc.message})
sys.exit(errno.EINVAL)
except ConfigParser.Error:
LOG.error(_LE('Incorrect configuration file: %(config)s'),
LOG.error('Incorrect configuration file: %(config)s',
{'config': rootwrap_config})
sys.exit(errno.EINVAL)
@ -101,14 +101,14 @@ def filter_command(command, rootwrap_config):
try:
wrapper.match_filter(filters, command, exec_dirs=rw_config.exec_dirs)
except wrapper.FilterMatchNotExecutable as exc:
LOG.error(_LE('Command %(command)s is not executable: '
'%(path)s (filter match = %(name)s)'),
LOG.error('Command %(command)s is not executable: '
'%(path)s (filter match = %(name)s)',
{'command': command,
'path': exc.match.exec_path,
'name': exc.match.name})
sys.exit(errno.EINVAL)
except wrapper.NoFilterMatched:
LOG.error(_LE('Unauthorized command: %(cmd)s (no filter matched)'),
LOG.error('Unauthorized command: %(cmd)s (no filter matched)',
{'cmd': command})
sys.exit(errno.EPERM)
@ -118,11 +118,11 @@ def execute_with_mount():
conf()
config.setup_logging()
if not conf.cmd:
LOG.error(_LE('No command provided, exiting'))
LOG.error('No command provided, exiting')
return errno.EINVAL
if not conf.mount_paths:
LOG.error(_LE('No mount path provided, exiting'))
LOG.error('No mount path provided, exiting')
return errno.EINVAL
# Both sudoers and rootwrap.conf will not exist in the directory /etc
@ -138,7 +138,7 @@ def execute_with_mount():
# http://man7.org/linux/man-pages/man7/namespaces.7.html
if os.path.samefile(os.path.join('/proc/1/ns/net'),
os.path.join('/proc', str(os.getpid()), 'ns/net')):
LOG.error(_LE('Cannot run without netns, exiting'))
LOG.error('Cannot run without netns, exiting')
return errno.EINVAL
for path, new_path in conf.mount_paths.items():
@ -149,12 +149,12 @@ def execute_with_mount():
if os.path.isdir(path) and os.path.isabs(path):
return_code = execute(['mount', '--bind', new_path, path])
if return_code == 0:
LOG.info(_LI('%(new_path)s has been '
'bind-mounted in %(path)s'),
LOG.info('%(new_path)s has been '
'bind-mounted in %(path)s',
{'new_path': new_path, 'path': path})
else:
LOG.error(_LE('Failed to bind-mount '
'%(new_path)s in %(path)s'),
LOG.error('Failed to bind-mount '
'%(new_path)s in %(path)s',
{'new_path': new_path, 'path': path})
return execute(conf.cmd)

View File

@ -20,8 +20,6 @@ from oslo_serialization import jsonutils
import requests
from requests import exceptions as r_exc
from neutron_vpnaas._i18n import _LE, _LW
TIMEOUT = 20.0
@ -112,8 +110,8 @@ class CsrRestClient(object):
except (r_exc.Timeout, r_exc.SSLError) as te:
# Should never see SSLError, unless requests package is old (<2.0)
timeout_val = 0.0 if self.timeout is None else self.timeout
LOG.warning(_LW("%(method)s: Request timeout%(ssl)s "
"(%(timeout).3f sec) for CSR(%(host)s)"),
LOG.warning("%(method)s: Request timeout%(ssl)s "
"(%(timeout).3f sec) for CSR(%(host)s)",
{'method': method,
'timeout': timeout_val,
'ssl': '(SSLError)'
@ -121,13 +119,13 @@ class CsrRestClient(object):
'host': self.host})
self.status = requests.codes.REQUEST_TIMEOUT
except r_exc.ConnectionError:
LOG.exception(_LE("%(method)s: Unable to connect to "
"CSR(%(host)s)"),
LOG.exception("%(method)s: Unable to connect to "
"CSR(%(host)s)",
{'method': method, 'host': self.host})
self.status = requests.codes.NOT_FOUND
except Exception as e:
LOG.error(_LE("%(method)s: Unexpected error for CSR (%(host)s): "
"%(error)s"),
LOG.error("%(method)s: Unexpected error for CSR (%(host)s): "
"%(error)s",
{'method': method, 'host': self.host, 'error': e})
self.status = requests.codes.INTERNAL_SERVER_ERROR
else:
@ -156,7 +154,7 @@ class CsrRestClient(object):
self.token = response['token-id']
LOG.debug("Successfully authenticated with CSR %s", self.host)
return True
LOG.error(_LE("Failed authentication with CSR %(host)s [%(status)s]"),
LOG.error("Failed authentication with CSR %(host)s [%(status)s]",
{'host': self.host, 'status': self.status})
def _do_request(self, method, resource, payload=None, more_headers=None,
@ -191,7 +189,7 @@ class CsrRestClient(object):
headers=headers)
if self.status != requests.codes.REQUEST_TIMEOUT:
return response
LOG.error(_LE("%(method)s: Request timeout for CSR(%(host)s)"),
LOG.error("%(method)s: Request timeout for CSR(%(host)s)",
{'method': method, 'host': self.host})
def get_request(self, resource, full_url=False):

View File

@ -26,7 +26,7 @@ from oslo_log import log as logging
import oslo_messaging
from oslo_service import loopingcall
from neutron_vpnaas._i18n import _, _LE, _LI, _LW
from neutron_vpnaas._i18n import _
from neutron_vpnaas.services.vpn.common import topics
from neutron_vpnaas.services.vpn import device_drivers
from neutron_vpnaas.services.vpn.device_drivers import (
@ -329,7 +329,7 @@ class CiscoCsrIPsecDriver(device_drivers.DeviceDriver):
if report:
service_report.append(report)
if service_report:
LOG.info(_LI("Sending status report update to plugin"))
LOG.info("Sending status report update to plugin")
self.agent_rpc.update_status(context, service_report)
LOG.debug("Report: Completed status report processing")
return service_report
@ -615,8 +615,8 @@ class CiscoCsrIPSecConnection(object):
LOG.debug("%(resource)s %(which)s is configured",
{'resource': resource, 'which': which})
return
LOG.error(_LE("Unable to create %(resource)s %(which)s: "
"%(status)d"),
LOG.error("Unable to create %(resource)s %(which)s: "
"%(status)d",
{'resource': resource, 'which': which,
'status': self.csr.status})
# ToDO(pcm): Set state to error
@ -628,7 +628,7 @@ class CiscoCsrIPSecConnection(object):
try:
getattr(self.csr, create_action)(info)
except AttributeError:
LOG.exception(_LE("Internal error - '%s' is not defined"),
LOG.exception("Internal error - '%s' is not defined",
create_action)
raise CsrResourceCreateFailure(resource=title,
which=resource_id)
@ -641,8 +641,8 @@ class CiscoCsrIPSecConnection(object):
LOG.debug("%(resource)s configuration %(which)s was removed",
{'resource': resource, 'which': which})
else:
LOG.warning(_LW("Unable to delete %(resource)s %(which)s: "
"%(status)d"), {'resource': resource,
LOG.warning("Unable to delete %(resource)s %(which)s: "
"%(status)d", {'resource': resource,
'which': which,
'status': status})
@ -656,7 +656,7 @@ class CiscoCsrIPSecConnection(object):
try:
getattr(self.csr, delete_action)(step.resource_id)
except AttributeError:
LOG.exception(_LE("Internal error - '%s' is not defined"),
LOG.exception("Internal error - '%s' is not defined",
delete_action)
raise CsrResourceCreateFailure(resource=step.title,
which=step.resource_id)
@ -709,10 +709,10 @@ class CiscoCsrIPSecConnection(object):
route_id, 'Static Route')
except CsrResourceCreateFailure:
self.do_rollback()
LOG.info(_LI("FAILED: Create of IPSec site-to-site connection %s"),
LOG.info("FAILED: Create of IPSec site-to-site connection %s",
conn_id)
else:
LOG.info(_LI("SUCCESS: Created IPSec site-to-site connection %s"),
LOG.info("SUCCESS: Created IPSec site-to-site connection %s",
conn_id)
def delete_ipsec_site_connection(self, context, conn_id):
@ -723,11 +723,11 @@ class CiscoCsrIPSecConnection(object):
"""
LOG.debug('Deleting IPSec connection %s', conn_id)
if not self.steps:
LOG.warning(_LW('Unable to find connection %s'), conn_id)
LOG.warning('Unable to find connection %s', conn_id)
else:
self.do_rollback()
LOG.info(_LI("SUCCESS: Deleted IPSec site-to-site connection %s"),
LOG.info("SUCCESS: Deleted IPSec site-to-site connection %s",
conn_id)
def set_admin_state(self, is_up):
@ -735,7 +735,7 @@ class CiscoCsrIPSecConnection(object):
self.csr.set_ipsec_connection_state(self.tunnel, admin_up=is_up)
if self.csr.status != requests.codes.NO_CONTENT:
state = "UP" if is_up else "DOWN"
LOG.error(_LE("Unable to change %(tunnel)s admin state to "
"%(state)s"), {'tunnel': self.tunnel,
LOG.error("Unable to change %(tunnel)s admin state to "
"%(state)s", {'tunnel': self.tunnel,
'state': state})
raise CsrAdminStateChangeFailure(tunnel=self.tunnel, state=state)

View File

@ -39,7 +39,7 @@ from oslo_log import log as logging
import oslo_messaging
from oslo_service import loopingcall
from neutron_vpnaas._i18n import _, _LE, _LI, _LW
from neutron_vpnaas._i18n import _
from neutron_vpnaas.extensions import vpnaas
from neutron_vpnaas.services.vpn.common import topics
from neutron_vpnaas.services.vpn import device_drivers
@ -309,7 +309,7 @@ class BaseSwanProcess(object):
self.start()
except RuntimeError:
LOG.exception(
_LE("Failed to enable vpn process on router %s"),
"Failed to enable vpn process on router %s",
self.id)
def disable(self):
@ -320,7 +320,7 @@ class BaseSwanProcess(object):
self.remove_config()
except RuntimeError:
LOG.exception(
_LE("Failed to disable vpn process on router %s"),
"Failed to disable vpn process on router %s",
self.id)
@abc.abstractmethod
@ -463,16 +463,16 @@ class OpenSwanProcess(BaseSwanProcess):
# logging to error instead of debug because it
# indicates something bad has happened and this is
# valuable information for figuring it out.
LOG.error(_LE('Process %(pid)s exists with command '
'line %(cmd_line)s.') %
LOG.error('Process %(pid)s exists with command '
'line %(cmd_line)s.' %
{'pid': pid, 'cmd_line': cmd_line})
return True
except IOError as e:
# This is logged as "info" instead of error because it simply
# means that we couldn't find the files to check on them.
LOG.info(_LI('Unable to find control files on startup for '
'router %(router)s: %(msg)s'),
LOG.info('Unable to find control files on startup for '
'router %(router)s: %(msg)s',
{'router': self.id, 'msg': e})
return False
@ -490,8 +490,8 @@ class OpenSwanProcess(BaseSwanProcess):
os.remove(ctl_file)
except OSError as e:
LOG.error(_LE('Unable to remove pluto control '
'files for router %(router)s. %(msg)s'),
LOG.error('Unable to remove pluto control '
'files for router %(router)s. %(msg)s',
{'router': self.id, 'msg': e})
def get_status(self):
@ -540,8 +540,8 @@ class OpenSwanProcess(BaseSwanProcess):
eventlet.sleep(wait_interval)
wait_interval *= cfg.CONF.pluto.shutdown_check_back_off
else:
LOG.warning(_LW('Server appears to still be running, restart '
'of router %s may fail'), self.id)
LOG.warning('Server appears to still be running, restart '
'of router %s may fail', self.id)
self.start()
return
@ -553,7 +553,7 @@ class OpenSwanProcess(BaseSwanProcess):
addrinfo = socket.getaddrinfo(fqdn, None)[0]
return addrinfo[-1][0]
except socket.gaierror:
LOG.exception(_LE("Peer address %s cannot be resolved"), fqdn)
LOG.exception("Peer address %s cannot be resolved", fqdn)
def _get_nexthop(self, address, connection_id):
# check if address is an ip address or fqdn

View File

@ -27,7 +27,7 @@ import oslo_messaging as messaging
from oslo_service import loopingcall
from oslo_service import periodic_task
from neutron_vpnaas._i18n import _, _LE, _LW
from neutron_vpnaas._i18n import _
from neutron_vpnaas.services.vpn.common import topics
from neutron_vpnaas.services.vpn import device_drivers
@ -75,8 +75,8 @@ class NeutronServerAPI(object):
for conn in svc[_KEY_CONNECTIONS]:
vyatta_vpn_config.validate_svc_connection(conn)
except v_exc.InvalidVPNServiceError:
LOG.error(_LE('Invalid or incomplete VPN service data: '
'id={id}').format(id=svc.get('id')))
LOG.error('Invalid or incomplete VPN service data: '
'id={id}'.format(id=svc.get('id')))
continue
vpn_services.append(svc)
@ -280,8 +280,8 @@ class _VyattaPeriodicTasks(periodic_task.PeriodicTasks):
try:
ipsec_sa = vrouter.get_vpn_ipsec_sa()
except v_exc.VRouterOperationError as e:
LOG.warning(_LW('Failed to fetch tunnel stats from router '
'{0}: {1}').format(router_id, unicode(e)))
LOG.warning('Failed to fetch tunnel stats from router '
'{0}: {1}'.format(router_id, unicode(e)))
continue
conn_ok = vyatta_vpn_config.parse_vpn_connections(

View File

@ -20,7 +20,7 @@ from neutron.services import provider_configuration as pconf
from neutron.services import service_base
from oslo_log import log as logging
from neutron_vpnaas._i18n import _LI
from neutron_vpnaas.db.vpn import vpn_db
LOG = logging.getLogger(__name__)
@ -56,7 +56,7 @@ class VPNDriverPlugin(VPNPlugin, vpn_db.VPNPluginRpcDbMixin):
# Load the service driver from neutron.conf.
drivers, default_provider = service_base.load_drivers(
constants.VPN, self)
LOG.info(_LI("VPN plugin using service driver: %s"), default_provider)
LOG.info("VPN plugin using service driver: %s", default_provider)
self.ipsec_driver = drivers[default_provider]
vpn_db.subscribe()

View File

@ -19,7 +19,7 @@ from oslo_log import log as logging
import sqlalchemy as sa
from sqlalchemy.orm import exc as sql_exc
from neutron_vpnaas._i18n import _, _LI
from neutron_vpnaas._i18n import _
from neutron_vpnaas.db.vpn import vpn_models
LOG = logging.getLogger(__name__)
@ -223,9 +223,9 @@ def create_tunnel_mapping(context, conn_info):
msg = _("Attempt to create duplicate entry in Cisco CSR "
"mapping table for connection %s") % conn_id
raise CsrInternalError(reason=msg)
LOG.info(_LI("Mapped connection %(conn_id)s to Tunnel%(tunnel_id)d "
LOG.info("Mapped connection %(conn_id)s to Tunnel%(tunnel_id)d "
"using IKE policy ID %(ike_id)d and IPSec policy "
"ID %(ipsec_id)d"),
"ID %(ipsec_id)d",
{'conn_id': conn_id, 'tunnel_id': csr_tunnel_id,
'ike_id': csr_ike_id, 'ipsec_id': csr_ipsec_id})
@ -235,4 +235,4 @@ def delete_tunnel_mapping(context, conn_info):
with context.session.begin():
sess_qry = context.session.query(IdentifierMap)
sess_qry.filter_by(ipsec_site_conn_id=conn_id).delete()
LOG.info(_LI("Removed mapping for connection %s"), conn_id)
LOG.info("Removed mapping for connection %s", conn_id)

View File

@ -12,7 +12,6 @@
# License for the specific language governing permissions and limitations
# under the License.
from neutron_vpnaas._i18n import _LI
from rally.common import logging
from rally.task import scenario
from rally.task import types as types
@ -63,7 +62,7 @@ class TestVpnBasicScenario(vpn_base.VpnBase):
self.create_ipsec_site_connections(**kwargs)
self.assert_statuses(final_status='ACTIVE', **kwargs)
self.verify_vpn_connectivity(**kwargs)
LOG.info(_LI("VPN CONNECTIVITY TEST PASSED!"))
LOG.info("VPN CONNECTIVITY TEST PASSED!")
finally:
self.cleanup()

View File

@ -12,7 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from neutron_vpnaas._i18n import _LI
from rally.common import logging
from rally.task import scenario
from rally.task import types as types
@ -63,7 +63,7 @@ class TestVpnStatusScenario(vpn_base.VpnBase):
self.update_router(self.router_ids[0], admin_state_up=True)
self.update_router(self.router_ids[1], admin_state_up=True)
self.assert_statuses(final_status='ACTIVE', **kwargs)
LOG.info(_LI("VPN STATUS TEST PASSED!"))
LOG.info("VPN STATUS TEST PASSED!")
finally:
self.cleanup()

View File

@ -12,7 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from neutron_vpnaas._i18n import _LI
from rally.common import logging
from rally.task import scenario
from rally.task import types as types
@ -56,7 +56,7 @@ class TestVpnTenantScenario(vpn_base.VpnBase):
self.create_vpn_services()
self.create_ipsec_site_connections(**kwargs)
self.assert_statuses(final_status='ACTIVE', **kwargs)
LOG.info(_LI("VPN TENANT TEST PASSED!"))
LOG.info("VPN TENANT TEST PASSED!")
finally:
self.cleanup()

View File

@ -87,7 +87,7 @@ commands = sphinx-build -W -b html doc/source doc/build
# TODO(marun) H404 multi line docstring should start with a summary
# TODO(dougwig) -- uncomment this to test for remaining linkages
# N530 direct neutron imports not allowed
ignore = E125,E126,E128,E129,E265,H404,H405,N530
ignore = E125,E126,E128,E129,E265,H404,H405,N530,N531
show-source = true
exclude = .venv,.git,.tox,dist,doc,.tmp,*lib/python*,*egg,build,tools,.ropeproject,rally-scenarios