Browse Source

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: Ib1e06cedb7b0e85947a807672473de5bbfc8a6d2
stable/pike
xuqihou 5 years ago committed by Gary Kotton
parent
commit
990c3ef227
  1. 10
      networking_l2gw/_i18n.py
  2. 5
      networking_l2gw/services/l2gateway/agent/base_agent_manager.py
  3. 43
      networking_l2gw/services/l2gateway/agent/ovsdb/base_connection.py
  4. 25
      networking_l2gw/services/l2gateway/agent/ovsdb/manager.py
  5. 17
      networking_l2gw/services/l2gateway/agent/ovsdb/ovsdb_monitor.py
  6. 19
      networking_l2gw/services/l2gateway/agent/ovsdb/ovsdb_writer.py
  7. 5
      networking_l2gw/services/l2gateway/agent_scheduler.py
  8. 3
      networking_l2gw/services/l2gateway/ovsdb/data.py
  9. 33
      networking_l2gw/services/l2gateway/plugin.py
  10. 14
      networking_l2gw/services/l2gateway/service_drivers/rpc_l2gw.py
  11. 5
      networking_l2gw/tests/scenario/test_l2gateways.py
  12. 4
      networking_l2gw/tests/unit/services/l2gateway/agent/ovsdb/test_ovsdb_writer.py

10
networking_l2gw/_i18n.py

@ -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)

5
networking_l2gw/services/l2gateway/agent/base_agent_manager.py

@ -21,7 +21,6 @@ from oslo_log import log as logging
from oslo_service import loopingcall
from oslo_service import periodic_task
from networking_l2gw._i18n import _LE, _LI
from networking_l2gw.services.l2gateway.agent import agent_api
from networking_l2gw.services.l2gateway.common import constants as n_const
from networking_l2gw.services.l2gateway.common import topics
@ -73,14 +72,14 @@ class BaseAgentManager(periodic_task.PeriodicTasks):
True)
self.agent_state['start_flag'] = False
except Exception:
LOG.exception(_LE("Failed reporting state!"))
LOG.exception("Failed reporting state!")
self.handle_report_state_failure()
def handle_report_state_failure(self):
pass
def agent_updated(self, context, payload):
LOG.info(_LI("agent_updated by server side %s!"), payload)
LOG.info("agent_updated by server side %s!", payload)
def set_monitor_agent(self, context, hostname):
"""Handle RPC call from plugin to update agent type.

43
networking_l2gw/services/l2gateway/agent/ovsdb/base_connection.py

@ -25,11 +25,10 @@ from oslo_log import log as logging
from oslo_serialization import jsonutils
from oslo_utils import excutils
from networking_l2gw._i18n import _LE, _LW
from networking_l2gw.services.l2gateway.common import constants as n_const
LOG = logging.getLogger(__name__)
OVSDB_UNREACHABLE_MSG = _LW('Unable to reach OVSDB server %s')
OVSDB_UNREACHABLE_MSG = 'Unable to reach OVSDB server %s'
OVSDB_CONNECTED_MSG = 'Connected to OVSDB server %s'
@ -81,8 +80,8 @@ class BaseConnection(object):
# Give up and return so that it can be tried in
# the next periodic interval.
with excutils.save_and_reraise_exception(reraise=True):
LOG.exception(_LE("Socket error in connecting to "
"the OVSDB server"))
LOG.exception("Socket error in connecting to "
"the OVSDB server")
else:
time.sleep(1)
retryCount += 1
@ -131,26 +130,26 @@ class BaseConnection(object):
client_sock = ssl_conn_stream
else:
if not is_priv_key:
LOG.error(_LE("Could not find private key in"
" %(path)s dir, expecting in the "
"file name %(file)s "),
LOG.error("Could not find private key in"
" %(path)s dir, expecting in the "
"file name %(file)s ",
{'path': priv_key_path,
'file': ovsdb_id + ".key"})
if not is_cert_file:
LOG.error(_LE("Could not find cert in %(path)s dir, "
"expecting in the file name %(file)s"),
LOG.error("Could not find cert in %(path)s dir, "
"expecting in the file name %(file)s",
{'path': cert_path,
'file': ovsdb_id + ".cert"})
if not is_ca_cert_file:
LOG.error(_LE("Could not find cacert in %(path)s "
"dir, expecting in the file name "
"%(file)s"),
LOG.error("Could not find cacert in %(path)s "
"dir, expecting in the file name "
"%(file)s",
{'path': ca_cert_path,
'file': ovsdb_id + ".ca_cert"})
else:
LOG.error(_LE("you have enabled SSL for ovsdb %s, "
"expecting the ovsdb identifier and ovdb IP "
"entry in ovsdb_hosts in l2gateway_agent.ini"),
LOG.error("you have enabled SSL for ovsdb %s, "
"expecting the ovsdb identifier and ovdb IP "
"entry in ovsdb_hosts in l2gateway_agent.ini",
addr)
return client_sock
@ -193,8 +192,8 @@ class BaseConnection(object):
self.mgr.ovsdb_fd._spawn_monitor_table_thread,
addr)
except Exception:
LOG.warning(_LW("Could not send monitor message to the "
"OVSDB server."))
LOG.warning("Could not send monitor message to the "
"OVSDB server.")
self.disconnect(addr)
def _common_sock_rcv_thread(self, addr):
@ -224,7 +223,7 @@ class BaseConnection(object):
prev_char == '\\'):
rc += 1
if rc > lc:
raise Exception(_LE("json string not valid"))
raise Exception("json string not valid")
elif lc == rc and lc is not 0:
chunks.append(response[message_mark:i + 1])
message = "".join(chunks)
@ -276,12 +275,12 @@ class BaseConnection(object):
if bytes_sent:
return True
except Exception as ex:
LOG.exception(_LE("Exception [%s] occurred while sending "
"message to the OVSDB server"), ex)
LOG.exception("Exception [%s] occurred while sending "
"message to the OVSDB server", ex)
retry_count += 1
LOG.warning(_LW("Could not send message to the "
"OVSDB server."))
LOG.warning("Could not send message to the "
"OVSDB server.")
self.disconnect(addr)
return False

25
networking_l2gw/services/l2gateway/agent/ovsdb/manager.py

@ -24,7 +24,6 @@ from oslo_config import cfg
from oslo_log import log as logging
from oslo_service import loopingcall
from networking_l2gw._i18n import _LE
from networking_l2gw.services.l2gateway.agent import base_agent_manager
from networking_l2gw.services.l2gateway.agent import l2gateway_config
from networking_l2gw.services.l2gateway.agent.ovsdb import ovsdb_common_class
@ -91,20 +90,20 @@ class OVSDBManager(base_agent_manager.BaseAgentManager):
is_cert_file = os.path.isfile(cert_file)
is_ca_cert_file = os.path.isfile(ca_cert_file)
if not is_priv_key:
LOG.exception(_LE("Could not find private key in "
"%(path)s dir, expecting in the "
"file name %(file)s "),
LOG.exception("Could not find private key in "
"%(path)s dir, expecting in the "
"file name %(file)s ",
{'path': priv_key_path,
'file': ovsdb_identifier + ".key"})
if not is_cert_file:
LOG.exception(_LE("Could not find cert in %(path)s dir, "
"expecting in the file name %(file)s"),
LOG.exception("Could not find cert in %(path)s dir, "
"expecting in the file name %(file)s",
{'path': cert_path,
'file': ovsdb_identifier + ".cert"})
if not is_ca_cert_file:
LOG.exception(_LE("Could not find cacert in %(path)s "
"dir, expecting in the file name "
"%(file)s"),
LOG.exception("Could not find cacert in %(path)s "
"dir, expecting in the file name "
"%(file)s",
{'path': ca_cert_path,
'file': ovsdb_identifier + ".ca_cert"})
ssl_ovsdb = {'use_ssl': True,
@ -127,8 +126,8 @@ class OVSDBManager(base_agent_manager.BaseAgentManager):
gateway = l2gateway_config.L2GatewayConfig(ovsdb_conf)
self.gateways[ovsdb_identifier] = gateway
except Exception as ex:
LOG.exception(_LE("Exception %(ex)s occurred while processing "
"host %(host)s"), {'ex': ex, 'host': host})
LOG.exception("Exception %(ex)s occurred while processing "
"host %(host)s", {'ex': ex, 'host': host})
def _connect_to_ovsdb_server(self):
"""Initializes the connection to the OVSDB servers."""
@ -149,8 +148,8 @@ class OVSDBManager(base_agent_manager.BaseAgentManager):
ovsdb_states[key] = 'disconnected'
# Log a warning and continue so that it can be
# retried in the next iteration.
LOG.error(_LE("OVSDB server %s is not "
"reachable"), gateway.ovsdb_ip)
LOG.error("OVSDB server %s is not "
"reachable", gateway.ovsdb_ip)
# Continue processing the next element in the list.
continue
gateway.ovsdb_fd = ovsdb_fd

17
networking_l2gw/services/l2gateway/agent/ovsdb/ovsdb_monitor.py

@ -21,7 +21,6 @@ from oslo_log import log as logging
from oslo_serialization import jsonutils
from oslo_utils import excutils
from networking_l2gw._i18n import _LE
from networking_l2gw.services.l2gateway.agent.ovsdb import base_connection
from networking_l2gw.services.l2gateway.common import constants as n_const
from networking_l2gw.services.l2gateway.common import ovsdb_schema
@ -126,8 +125,8 @@ class OVSDBMonitor(base_connection.BaseConnection):
with excutils.save_and_reraise_exception():
if self.enable_manager:
self.check_monitor_table_thread = False
LOG.exception(_LE("Exception while receiving the "
"response for the monitor message"))
LOG.exception("Exception while receiving the "
"response for the monitor message")
self._process_monitor_msg(response_result, addr)
def _update_event_handler(self, message, addr):
@ -200,8 +199,8 @@ class OVSDBMonitor(base_connection.BaseConnection):
else:
self.responses.append(json_m)
except Exception as e:
LOG.exception(_LE("Exception [%s] while handling "
"message"), e)
LOG.exception("Exception [%s] while handling "
"message", e)
def _rcv_thread(self):
chunks = []
@ -232,7 +231,7 @@ class OVSDBMonitor(base_connection.BaseConnection):
prev_char == '\\'):
rc += 1
if rc > lc:
raise Exception(_LE("json string not valid"))
raise Exception("json string not valid")
elif lc == rc and lc is not 0:
chunks.append(response[message_mark:i + 1])
message = "".join(chunks)
@ -249,8 +248,8 @@ class OVSDBMonitor(base_connection.BaseConnection):
except Exception as ex:
self.read_on = False
self.disconnect()
LOG.exception(_LE("Exception [%s] occurred while receiving"
"message from the OVSDB server"), ex)
LOG.exception("Exception [%s] occurred while receiving"
"message from the OVSDB server", ex)
def disconnect(self, addr=None):
"""disconnects the connection from the OVSDB server."""
@ -266,7 +265,7 @@ class OVSDBMonitor(base_connection.BaseConnection):
self.rpc_callback(Activity.Initial,
self._form_ovsdb_data(data_dict, addr))
except Exception as e:
LOG.exception(_LE("_process_monitor_msg:ERROR %s "), e)
LOG.exception("_process_monitor_msg:ERROR %s ", e)
def _get_list(self, resource_list):
return [element.__dict__ for element in resource_list]

19
networking_l2gw/services/l2gateway/agent/ovsdb/ovsdb_writer.py

@ -20,7 +20,6 @@ from oslo_log import log as logging
from oslo_serialization import jsonutils
from oslo_utils import excutils
from networking_l2gw._i18n import _LE, _LW
from networking_l2gw.services.l2gateway.agent.ovsdb import base_connection
from networking_l2gw.services.l2gateway.common import constants as n_const
from networking_l2gw.services.l2gateway.common import ovsdb_schema
@ -72,13 +71,13 @@ class OVSDBWriter(base_connection.BaseConnection):
return True
except Exception as ex:
with excutils.save_and_reraise_exception():
LOG.exception(_LE("Exception while receiving the "
"response for the write request:"
" [%s]"), ex)
LOG.exception("Exception while receiving the "
"response for the write request:"
" [%s]", ex)
count += 1
with excutils.save_and_reraise_exception():
LOG.error(_LE("Could not obtain response from the OVSDB server "
"for the request"))
LOG.error("Could not obtain response from the OVSDB server "
"for the request")
def _send_and_receive(self, query, operation_id, ovsdb_identifier,
rcv_required):
@ -259,12 +258,12 @@ class OVSDBWriter(base_connection.BaseConnection):
prev_char = c
chunks.append(response)
else:
LOG.warning(_LW("Did not receive any reply from the OVSDB "
"server"))
LOG.warning("Did not receive any reply from the OVSDB "
"server")
return
except (socket.error, socket.timeout):
LOG.warning(_LW("Did not receive any reply from the OVSDB "
"server"))
LOG.warning("Did not receive any reply from the OVSDB "
"server")
return
def _get_bindings_to_update(self, l_switch_dict, locator_dicts,

5
networking_l2gw/services/l2gateway/agent_scheduler.py

@ -23,7 +23,6 @@ from oslo_service import loopingcall
from neutron.db import agents_db
from neutron_lib import context as neutron_context
from networking_l2gw._i18n import _LE
from networking_l2gw.services.l2gateway.common import config
from networking_l2gw.services.l2gateway.common import constants as srv_const
@ -70,7 +69,7 @@ class L2GatewayAgentScheduler(agents_db.AgentDbMixin):
LOG.debug("Successfully initialized L2gateway agent scheduler"
" thread with loop interval %s", self.monitor_interval)
except Exception:
LOG.error(_LE("Cannot initialize agent scheduler thread"))
LOG.error("Cannot initialize agent scheduler thread")
def _select_agent_type(self, context, agents_to_process):
"""Select the Monitor agent."""
@ -122,7 +121,7 @@ class L2GatewayAgentScheduler(agents_db.AgentDbMixin):
context,
filters={'agent_type': [srv_const.AGENT_TYPE_L2GATEWAY]})
except Exception:
LOG.exception(_LE("Unable to get the agent list. Continuing..."))
LOG.exception("Unable to get the agent list. Continuing...")
return
# Reset the agents that will be processed for selecting the

3
networking_l2gw/services/l2gateway/ovsdb/data.py

@ -13,7 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from networking_l2gw._i18n import _LE
from networking_l2gw.db.l2gateway import l2gateway_db
from networking_l2gw.db.l2gateway.ovsdb import lib as db
from networking_l2gw.services.l2gateway.common import constants as n_const
@ -158,7 +157,7 @@ class OVSDBData(object):
logical_switch_uuid,
mac)
except Exception as ex:
LOG.exception(_LE("Exception occurred = %s"),
LOG.exception("Exception occurred = %s",
str(ex))
def _setup_entry_table(self):

33
networking_l2gw/services/l2gateway/plugin.py

@ -20,7 +20,6 @@ from neutron.db import servicetype_db as st_db
from neutron.services import provider_configuration as pconf
from neutron.services import service_base
from networking_l2gw._i18n import _LE, _LI
from networking_l2gw.db.l2gateway import l2gateway_db
from networking_l2gw.services.l2gateway.common import config
from networking_l2gw.services.l2gateway.common import constants
@ -49,13 +48,13 @@ class L2GatewayPlugin(l2gateway_db.L2GatewayMixin):
self.service_type_manager.add_provider_configuration(
constants.L2GW, pconf.ProviderConfiguration('networking_l2gw'))
self._load_drivers()
LOG.info(_LI("L2Gateway Service Plugin using Service Driver: %s"),
LOG.info("L2Gateway Service Plugin using Service Driver: %s",
self.default_provider)
self.driver = self.drivers[self.default_provider]
if len(self.drivers) > 1:
LOG.warning(_LI("Multiple drivers configured for L2Gateway, "
"although running multiple drivers in parallel"
" is not yet supported"))
LOG.warning("Multiple drivers configured for L2Gateway, "
"although running multiple drivers in parallel"
" is not yet supported")
super(L2GatewayPlugin, self).__init__()
l2gateway_db.subscribe()
@ -68,7 +67,7 @@ class L2GatewayPlugin(l2gateway_db.L2GatewayMixin):
if provider in self.drivers:
return self.drivers[provider]
# raise if not associated (should never be reached)
raise n_exc.Invalid(_LE("Error retrieving driver for provider %s") %
raise n_exc.Invalid("Error retrieving driver for provider %s" %
provider)
@property
@ -106,8 +105,8 @@ class L2GatewayPlugin(l2gateway_db.L2GatewayMixin):
context, l2_gateway_instance)
except exc.L2GatewayServiceDriverError:
with excutils.save_and_reraise_exception():
LOG.error(_LE("L2GatewayPlugin.create_l2_gateway_postcommit "
"failed, deleting l2gateway '%s'"),
LOG.error("L2GatewayPlugin.create_l2_gateway_postcommit "
"failed, deleting l2gateway '%s'",
l2_gateway_instance['id'])
self.delete_l2_gateway(context, l2_gateway_instance['id'])
return l2_gateway_instance
@ -128,8 +127,8 @@ class L2GatewayPlugin(l2gateway_db.L2GatewayMixin):
context, l2_gateway_instance)
except exc.L2GatewayServiceDriverError:
with excutils.save_and_reraise_exception():
LOG.error(_LE("L2GatewayPlugin.update_l2_gateway_postcommit"
" failed for l2gateway %s"), l2_gateway_id)
LOG.error("L2GatewayPlugin.update_l2_gateway_postcommit"
" failed for l2gateway %s", l2_gateway_id)
return l2_gateway_instance
def delete_l2_gateway(self, context, l2_gateway_id):
@ -144,8 +143,8 @@ class L2GatewayPlugin(l2gateway_db.L2GatewayMixin):
self.driver.delete_l2_gateway_postcommit(context, l2_gateway_id)
except exc.L2GatewayServiceDriverError:
with excutils.save_and_reraise_exception():
LOG.error(_LE("L2GatewayPlugin.delete_l2_gateway_postcommit"
" failed for l2gateway %s"), l2_gateway_id)
LOG.error("L2GatewayPlugin.delete_l2_gateway_postcommit"
" failed for l2gateway %s", l2_gateway_id)
def create_l2_gateway_connection(self, context, l2_gateway_connection):
"""Create an L2Gateway Connection
@ -167,9 +166,9 @@ class L2GatewayPlugin(l2gateway_db.L2GatewayMixin):
context, l2_gateway_conn_instance)
except exc.L2GatewayServiceDriverError:
with excutils.save_and_reraise_exception():
LOG.error(_LE("L2GatewayPlugin."
"create_l2_gateway_connection_postcommit "
"failed, deleting connection '%s'"),
LOG.error("L2GatewayPlugin."
"create_l2_gateway_connection_postcommit "
"failed, deleting connection '%s'",
l2_gateway_conn_instance['id'])
self.delete_l2_gateway_connection(
context, l2_gateway_conn_instance['id'])
@ -195,6 +194,6 @@ class L2GatewayPlugin(l2gateway_db.L2GatewayMixin):
context, l2_gateway_connection_id)
except exc.L2GatewayServiceDriverError:
with excutils.save_and_reraise_exception():
LOG.error(_LE(
LOG.error(
"L2GatewayPlugin.delete_l2_gateway_connection_postcommit"
" failed for connection %s"), l2_gateway_connection_id)
" failed for connection %s", l2_gateway_connection_id)

14
networking_l2gw/services/l2gateway/service_drivers/rpc_l2gw.py

@ -18,7 +18,7 @@ from neutron.common import constants as nc_const
from neutron.common import rpc as n_rpc
from neutron.db import agents_db
from networking_l2gw._i18n import _, _LE
from networking_l2gw._i18n import _
from networking_l2gw.db.l2gateway import l2gateway_db as l2_gw_db
from networking_l2gw.db.l2gateway.ovsdb import lib as db
from networking_l2gw.services.l2gateway import agent_scheduler
@ -144,8 +144,8 @@ class L2gwRpcDriver(service_drivers.L2gwDriver):
except messaging.MessagingTimeout:
# If RPC is timed out, then the RabbitMQ
# will retry the operation.
LOG.exception(_LE("Communication error with "
"the L2 gateway agent"))
LOG.exception("Communication error with "
"the L2 gateway agent")
except Exception:
# The remote OVSDB server may be down.
# We need to retry this operation later.
@ -172,8 +172,8 @@ class L2gwRpcDriver(service_drivers.L2gwDriver):
except messaging.MessagingTimeout:
# If RPC is timed out, then the RabbitMQ
# will retry the operation.
LOG.exception(_LE("Communication error with "
"the L2 gateway agent"))
LOG.exception("Communication error with "
"the L2 gateway agent")
except Exception:
# The remote OVSDB server may be down.
# We need to retry this operation later.
@ -290,8 +290,8 @@ class L2gwRpcDriver(service_drivers.L2gwDriver):
except messaging.MessagingTimeout:
# If RPC is timed out, then the RabbitMQ
# will retry the operation.
LOG.exception(_LE("Communication error with "
"the L2 gateway agent"))
LOG.exception("Communication error with "
"the L2 gateway agent")
except Exception as ex:
# The remote OVSDB server may be down.
# We need to retry this operation later.

5
networking_l2gw/tests/scenario/test_l2gateways.py

@ -14,7 +14,6 @@
# License for the specific language governing permissions and limitations
# under the License.
from networking_l2gw._i18n import _LI
from networking_l2gw.tests.api import base_l2gw
from networking_l2gw.tests.scenario import ovsdb_connections
from networking_l2gw.tests.tempest import config
@ -121,8 +120,8 @@ class TestL2GatewayBasic(base.BaseAdminNetworkTest):
serverstatus = '/'.join((server_status, str(task_state)))
waitsec = (time.time() - start_time)
LOG.info(
_LI('State transition %(oldstatus)s => %(serverstatus)s'
'after %(waitsec)d second wait') %
'State transition %(oldstatus)s => %(serverstatus)s'
'after %(waitsec)d second wait' %
{'oldstatus': oldstatus, 'serverstatus': serverstatus,
'waitsec': waitsec}
)

4
networking_l2gw/tests/unit/services/l2gateway/agent/ovsdb/test_ovsdb_writer.py

@ -21,7 +21,6 @@ import mock
from neutron.tests import base
from networking_l2gw._i18n import _LW
from networking_l2gw.services.l2gateway.agent import l2gateway_config as conf
from networking_l2gw.services.l2gateway.agent.ovsdb import base_connection
from networking_l2gw.services.l2gateway.agent.ovsdb import ovsdb_writer
@ -472,5 +471,4 @@ class TestOVSDBWriter(base.BaseTestCase):
result = l2gw_obj._recv_data(mock.ANY)
self.assertIsNone(result)
fake_warn.assert_called_with(
_LW("Did not receive any reply from the OVSDB "
"server"))
"Did not receive any reply from the OVSDB server")

Loading…
Cancel
Save