Remove log translations

1. What is the problem?
Log messages were added with translation marker _LE, _LI and _LW,
but log messages are no longer being translated.
2. What is the solution to the problem?
This patch is to remove 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
https://review.openstack.org/#/c/446762/
3. What features need to be implemented to the Tricircle to realize the solution?
None

Change-Id: Idefeb05c686311a63dfe7578fa687492d2135eaa
This commit is contained in:
lihaijing 2017-03-21 14:02:25 +08:00
parent 4631302991
commit bbdbae4209
19 changed files with 88 additions and 128 deletions

View File

@ -25,7 +25,6 @@ from oslo_utils import uuidutils
import tricircle.common.context as t_context import tricircle.common.context as t_context
import tricircle.common.exceptions as t_exc import tricircle.common.exceptions as t_exc
from tricircle.common.i18n import _ from tricircle.common.i18n import _
from tricircle.common.i18n import _LE
from tricircle.common import policy from tricircle.common import policy
from tricircle.db import api as db_api from tricircle.db import api as db_api
@ -95,17 +94,17 @@ class PodsController(rest.RestController):
'dc_name': dc_name, 'dc_name': dc_name,
'az_name': az_name}) 'az_name': az_name})
except db_exc.DBDuplicateEntry as e1: except db_exc.DBDuplicateEntry as e1:
LOG.exception(_LE('Record already exists on %(region_name)s: ' LOG.exception('Record already exists on %(region_name)s: '
'%(exception)s'), '%(exception)s',
{'region_name': region_name, {'region_name': region_name,
'exception': e1}) 'exception': e1})
return Response(_('Record already exists'), 409) return Response(_('Record already exists'), 409)
except Exception as e2: except Exception as e2:
LOG.exception(_LE('Failed to create pod: %(region_name)s,' LOG.exception('Failed to create pod: %(region_name)s,'
'pod_az_name: %(pod_az_name)s,' 'pod_az_name: %(pod_az_name)s,'
'dc_name: %(dc_name)s,' 'dc_name: %(dc_name)s,'
'az_name: %(az_name)s' 'az_name: %(az_name)s'
'%(exception)s '), '%(exception)s ',
{'region_name': region_name, {'region_name': region_name,
'pod_az_name': pod_az_name, 'pod_az_name': pod_az_name,
'dc_name': dc_name, 'dc_name': dc_name,
@ -140,7 +139,7 @@ class PodsController(rest.RestController):
try: try:
return {'pods': db_api.list_pods(context)} return {'pods': db_api.list_pods(context)}
except Exception as e: except Exception as e:
LOG.exception(_LE('Failed to list all pods: %(exception)s '), LOG.exception('Failed to list all pods: %(exception)s ',
{'exception': e}) {'exception': e})
pecan.abort(500, _('Failed to list pods')) pecan.abort(500, _('Failed to list pods'))
@ -162,8 +161,8 @@ class PodsController(rest.RestController):
except t_exc.ResourceNotFound: except t_exc.ResourceNotFound:
return Response(_('Pod not found'), 404) return Response(_('Pod not found'), 404)
except Exception as e: except Exception as e:
LOG.exception(_LE('Failed to delete pod: %(pod_id)s,' LOG.exception('Failed to delete pod: %(pod_id)s,'
'%(exception)s'), '%(exception)s',
{'pod_id': _id, {'pod_id': _id,
'exception': e}) 'exception': e})
@ -179,7 +178,7 @@ class PodsController(rest.RestController):
if pod['az_name'] == '' and pod['region_name'] != '': if pod['az_name'] == '' and pod['region_name'] != '':
return pod['region_name'] return pod['region_name']
except Exception as e: except Exception as e:
LOG.exception(_LE('Failed to get top region: %(exception)s '), LOG.exception('Failed to get top region: %(exception)s ',
{'exception': e}) {'exception': e})
return top_region_name return top_region_name

View File

@ -21,7 +21,6 @@ from tricircle.common import constants
import tricircle.common.context as t_context import tricircle.common.context as t_context
import tricircle.common.exceptions as t_exc import tricircle.common.exceptions as t_exc
from tricircle.common.i18n import _ from tricircle.common.i18n import _
from tricircle.common.i18n import _LE
from tricircle.common import policy from tricircle.common import policy
from tricircle.common import utils from tricircle.common import utils
@ -81,8 +80,8 @@ class RoutingController(rest.RestController):
return utils.format_api_error( return utils.format_api_error(
409, _('Resource routing already exists')) 409, _('Resource routing already exists'))
except Exception as e: except Exception as e:
LOG.exception(_LE('Failed to create resource routing: ' LOG.exception('Failed to create resource routing: '
'%(exception)s '), {'exception': e}) '%(exception)s ', {'exception': e})
return utils.format_api_error( return utils.format_api_error(
500, _('Failed to create resource routing')) 500, _('Failed to create resource routing'))
@ -120,8 +119,8 @@ class RoutingController(rest.RestController):
return {'routings': db_api.list_resource_routings(context, return {'routings': db_api.list_resource_routings(context,
filters)} filters)}
except Exception as e: except Exception as e:
LOG.exception(_LE('Failed to show all resource routings: ' LOG.exception('Failed to show all resource routings: '
'%(exception)s '), {'exception': e}) '%(exception)s ', {'exception': e})
return utils.format_api_error( return utils.format_api_error(
500, _('Failed to show all resource routings')) 500, _('Failed to show all resource routings'))
@ -157,8 +156,8 @@ class RoutingController(rest.RestController):
pecan.response.status = 200 pecan.response.status = 200
return pecan.response return pecan.response
except Exception as e: except Exception as e:
LOG.exception(_LE('Failed to delete the resource routing: ' LOG.exception('Failed to delete the resource routing: '
'%(exception)s '), {'exception': e}) '%(exception)s ', {'exception': e})
return utils.format_api_error( return utils.format_api_error(
500, _('Failed to delete the resource routing')) 500, _('Failed to delete the resource routing'))
@ -208,8 +207,8 @@ class RoutingController(rest.RestController):
400, _("The pod %(new_pod_id)s doesn't" 400, _("The pod %(new_pod_id)s doesn't"
" exist") % {'new_pod_id': new_pod_id}) " exist") % {'new_pod_id': new_pod_id})
except Exception as e: except Exception as e:
LOG.exception(_LE('Failed to update resource routing: ' LOG.exception('Failed to update resource routing: '
'%(exception)s '), {'exception': e}) '%(exception)s ', {'exception': e})
return utils.format_api_error( return utils.format_api_error(
500, _('Failed to update resource routing')) 500, _('Failed to update resource routing'))
@ -218,7 +217,7 @@ class RoutingController(rest.RestController):
context, _id, update_dict) context, _id, update_dict)
return {'routing': routing_updated} return {'routing': routing_updated}
except Exception as e: except Exception as e:
LOG.exception(_LE('Failed to update resource routing: ' LOG.exception('Failed to update resource routing: '
'%(exception)s '), {'exception': e}) '%(exception)s ', {'exception': e})
return utils.format_api_error( return utils.format_api_error(
500, _('Failed to update resource routing')) 500, _('Failed to update resource routing'))

View File

@ -28,7 +28,6 @@ from oslo_log import log as logging
from tricircle.api import app from tricircle.api import app
from tricircle.common import config from tricircle.common import config
from tricircle.common.i18n import _LI
CONFIG_FILE = 'api.conf' CONFIG_FILE = 'api.conf'
@ -50,7 +49,7 @@ def init_application():
conf_file = _get_config_file() conf_file = _get_config_file()
config.init(app.common_opts, ['--config-file', conf_file]) config.init(app.common_opts, ['--config-file', conf_file])
LOG.info(_LI("Configuration:")) LOG.info("Configuration:")
CONF.log_opt_values(LOG, logging.INFO) CONF.log_opt_values(LOG, logging.INFO)
# return WSGI app # return WSGI app

View File

@ -24,8 +24,6 @@ from oslo_service import wsgi
from tricircle.api import app from tricircle.api import app
from tricircle.common import config from tricircle.common import config
from tricircle.common.i18n import _LI
from tricircle.common.i18n import _LW
from tricircle.common import restapp from tricircle.common import restapp
@ -42,16 +40,16 @@ def main():
workers = CONF.api_workers workers = CONF.api_workers
if workers < 1: if workers < 1:
LOG.warning(_LW("Wrong worker number, worker = %(workers)s"), workers) LOG.warning("Wrong worker number, worker = %(workers)s", workers)
workers = 1 workers = 1
LOG.info(_LI("Admin API on http://%(host)s:%(port)s with %(workers)s"), LOG.info("Admin API on http://%(host)s:%(port)s with %(workers)s",
{'host': host, 'port': port, 'workers': workers}) {'host': host, 'port': port, 'workers': workers})
service = wsgi.Server(CONF, 'Tricircle Admin_API', application, host, port) service = wsgi.Server(CONF, 'Tricircle Admin_API', application, host, port)
restapp.serve(service, CONF, workers) restapp.serve(service, CONF, workers)
LOG.info(_LI("Configuration:")) LOG.info("Configuration:")
CONF.log_opt_values(LOG, logging.INFO) CONF.log_opt_values(LOG, logging.INFO)
restapp.wait() restapp.wait()

View File

@ -26,7 +26,6 @@ from oslo_config import cfg
from oslo_log import log as logging from oslo_log import log as logging
from tricircle.common import config from tricircle.common import config
from tricircle.common.i18n import _LI, _LW
from tricircle.xjob import xservice from tricircle.xjob import xservice
@ -41,15 +40,15 @@ def main():
workers = CONF.workers workers = CONF.workers
if workers < 1: if workers < 1:
LOG.warning(_LW("Wrong worker number, worker = %(workers)s"), workers) LOG.warning("Wrong worker number, worker = %(workers)s", workers)
workers = 1 workers = 1
LOG.info(_LI("XJob Server on http://%(host)s with %(workers)s"), LOG.info("XJob Server on http://%(host)s with %(workers)s",
{'host': host, 'workers': workers}) {'host': host, 'workers': workers})
xservice.serve(xservice.create_service(), workers) xservice.serve(xservice.create_service(), workers)
LOG.info(_LI("Configuration:")) LOG.info("Configuration:")
CONF.log_opt_values(LOG, logging.INFO) CONF.log_opt_values(LOG, logging.INFO)
xservice.wait() xservice.wait()

View File

@ -28,7 +28,6 @@ from oslo_log import log as logging
import tricircle.common.context as tricircle_context import tricircle.common.context as tricircle_context
from tricircle.common import exceptions from tricircle.common import exceptions
from tricircle.common.i18n import _LW
from tricircle.common import resource_handle from tricircle.common import resource_handle
from tricircle.db import api from tricircle.db import api
from tricircle.db import models from tricircle.db import models
@ -98,8 +97,8 @@ def _safe_operation(operation_name):
if i == retries: if i == retries:
raise raise
if cfg.CONF.client.auto_refresh_endpoint: if cfg.CONF.client.auto_refresh_endpoint:
LOG.warning(_LW('%(exception)s, ' LOG.warning('%(exception)s, '
'update endpoint and try again'), 'update endpoint and try again',
{'exception': e.message}) {'exception': e.message})
instance._update_endpoint_from_keystone(context, True) instance._update_endpoint_from_keystone(context, True)
else: else:
@ -109,8 +108,8 @@ def _safe_operation(operation_name):
# for the given pod and service, we add default behaviours # for the given pod and service, we add default behaviours
# for the handle functions # for the handle functions
if i < retries and cfg.CONF.client.auto_refresh_endpoint: if i < retries and cfg.CONF.client.auto_refresh_endpoint:
LOG.warning(_LW('%(exception)s, ' LOG.warning('%(exception)s, '
'update endpoint and try again'), 'update endpoint and try again',
{'exception': e.message}) {'exception': e.message})
instance._update_endpoint_from_keystone(context, True) instance._update_endpoint_from_keystone(context, True)
continue continue

View File

@ -22,8 +22,6 @@ from oslo_config import cfg
import oslo_log.log as logging import oslo_log.log as logging
from oslo_policy import opts as policy_opts from oslo_policy import opts as policy_opts
from tricircle.common.i18n import _LI
from tricircle.common import policy from tricircle.common import policy
from tricircle.common import rpc from tricircle.common import rpc
from tricircle.common import version from tricircle.common import version
@ -53,8 +51,8 @@ def _setup_logging():
"""Sets up the logging options for a log with supplied name.""" """Sets up the logging options for a log with supplied name."""
product_name = "tricircle" product_name = "tricircle"
logging.setup(cfg.CONF, product_name) logging.setup(cfg.CONF, product_name)
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.version_info}) 'version': version.version_info})
LOG.debug("command line: %s", " ".join(sys.argv)) LOG.debug("command line: %s", " ".join(sys.argv))

View File

@ -23,7 +23,6 @@ from neutron_lib import exceptions
from oslo_log import log as logging from oslo_log import log as logging
from tricircle.common.i18n import _ from tricircle.common.i18n import _
from tricircle.common.i18n import _LE
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@ -91,8 +90,8 @@ class TricircleException(Exception):
def _should_format(self): def _should_format(self):
if self.kwargs['message'] is None and '%(message)' in self.message: if self.kwargs['message'] is None and '%(message)' in self.message:
LOG.error(_LE('\%(message)s in message ' LOG.error('\%(message)s in message '
'but init parameter is None')) 'but init parameter is None')
return self.kwargs['message'] is None or '%(message)' in self.message return self.kwargs['message'] is None or '%(message)' in self.message

View File

@ -21,7 +21,6 @@ from oslo_log import log as logging
from tricircle.common import client from tricircle.common import client
from tricircle.common import constants as cons from tricircle.common import constants as cons
from tricircle.common.i18n import _LE
from tricircle.db import api as db_api from tricircle.db import api as db_api
@ -172,7 +171,7 @@ def get_res_routing_ref(context, _id, t_url, s_type):
s_type=s_type) s_type=s_type)
if s_ctx['b_url'] == '': if s_ctx['b_url'] == '':
LOG.error(_LE("bottom pod endpoint incorrect %s") % LOG.error("bottom pod endpoint incorrect %s" %
region_name) region_name)
return s_ctx return s_ctx

View File

@ -18,13 +18,3 @@ _translators = oslo_i18n.TranslatorFactory(domain='tricircle')
# The primary translation function using the well-known name "_" # The primary translation function using the well-known name "_"
_ = _translators.primary _ = _translators.primary
# 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

View File

@ -31,7 +31,6 @@ import oslo_log.log as logging
from oslo_policy import policy from oslo_policy import policy
from tricircle.common import exceptions as t_exec from tricircle.common import exceptions as t_exec
from tricircle.common.i18n import _LE
_ENFORCER = None _ENFORCER = None
CONF = cfg.CONF CONF = cfg.CONF
@ -185,6 +184,6 @@ def enforce(context, rule=None, target=None, *args, **kwargs):
except t_exec.PolicyNotAuthorized as e: except t_exec.PolicyNotAuthorized as e:
result = False result = False
LOG.exception(_LE("%(msg)s, %(rule)s, %(target)s"), LOG.exception("%(msg)s, %(rule)s, %(target)s",
{'msg': str(e), 'rule': rule, 'target': target}) {'msg': str(e), 'rule': rule, 'target': target})
return result return result

View File

@ -29,7 +29,6 @@ from tricircle.common import constants
from tricircle.common.context import is_admin_context as _is_admin_context from tricircle.common.context import is_admin_context as _is_admin_context
from tricircle.common import exceptions from tricircle.common import exceptions
from tricircle.common.i18n import _ from tricircle.common.i18n import _
from tricircle.common.i18n import _LW
from tricircle.db import core from tricircle.db import core
from tricircle.db import models from tricircle.db import models
@ -562,8 +561,8 @@ def _retry_on_deadlock(f):
try: try:
return f(*args, **kwargs) return f(*args, **kwargs)
except db_exc.DBDeadlock: except db_exc.DBDeadlock:
LOG.warning(_LW("Deadlock detected when running " LOG.warning("Deadlock detected when running "
"'%(func_name)s': Retrying..."), "'%(func_name)s': Retrying...",
dict(func_name=f.__name__)) dict(func_name=f.__name__))
# Retry! # Retry!
time.sleep(0.5) time.sleep(0.5)

View File

@ -57,7 +57,7 @@ import tricircle.common.client as t_client
import tricircle.common.constants as t_constants import tricircle.common.constants as t_constants
import tricircle.common.context as t_context import tricircle.common.context as t_context
import tricircle.common.exceptions as t_exceptions import tricircle.common.exceptions as t_exceptions
from tricircle.common.i18n import _, _LE, _LI, _LW from tricircle.common.i18n import _
from tricircle.common import xrpcapi from tricircle.common import xrpcapi
import tricircle.db.api as db_api import tricircle.db.api as db_api
from tricircle.db import core from tricircle.db import core
@ -151,7 +151,7 @@ class TricirclePlugin(db_base_plugin_v2.NeutronDbPluginV2,
def __init__(self): def __init__(self):
super(TricirclePlugin, self).__init__() super(TricirclePlugin, self).__init__()
LOG.info(_LI("Starting Tricircle Neutron Plugin")) LOG.info("Starting Tricircle Neutron Plugin")
self.clients = {} self.clients = {}
self.xjob_handler = xrpcapi.XJobAPI() self.xjob_handler = xrpcapi.XJobAPI()
self._setup_rpc() self._setup_rpc()
@ -568,7 +568,7 @@ class TricirclePlugin(db_base_plugin_v2.NeutronDbPluginV2,
updated_sens_attrs.append('%s = %s' % (key, request_body[key])) updated_sens_attrs.append('%s = %s' % (key, request_body[key]))
warning_attrs = ', '.join(updated_sens_attrs) warning_attrs = ', '.join(updated_sens_attrs)
LOG.warning(_LW('update port: %(port_id)s , %(warning_attrs)s'), LOG.warning('update port: %(port_id)s , %(warning_attrs)s',
{'port_id': port_id, 'warning_attrs': warning_attrs}) {'port_id': port_id, 'warning_attrs': warning_attrs})
def _handle_bottom_security_group(self, t_ctx, top_sg, bottom_pod): def _handle_bottom_security_group(self, t_ctx, top_sg, bottom_pod):
@ -698,8 +698,8 @@ class TricirclePlugin(db_base_plugin_v2.NeutronDbPluginV2,
b_client.update_ports(t_ctx, b_port_id, port) b_client.update_ports(t_ctx, b_port_id, port)
except q_cli_exceptions.NotFound: except q_cli_exceptions.NotFound:
LOG.error( LOG.error(
_LE('port: %(port_id)s not found, ' ('port: %(port_id)s not found, '
'region name: %(name)s'), 'region name: %(name)s'),
{'port_id': b_port_id, 'name': b_region_name}) {'port_id': b_port_id, 'name': b_region_name})
if request_body.get('security_groups', None): if request_body.get('security_groups', None):
@ -1681,8 +1681,8 @@ class TricirclePlugin(db_base_plugin_v2.NeutronDbPluginV2,
floating_ip.update(org_data) floating_ip.update(org_data)
except Exception as e: except Exception as e:
# log the exception and re-raise it # log the exception and re-raise it
LOG.exception(_LE('Fail to rollback floating ip data, reason: ' LOG.exception('Fail to rollback floating ip data, reason: '
'%(reason)s') % {'reason': e.message}) '%(reason)s' % {'reason': e.message})
raise raise
def update_floatingip(self, context, _id, floatingip): def update_floatingip(self, context, _id, floatingip):
@ -1708,9 +1708,9 @@ class TricirclePlugin(db_base_plugin_v2.NeutronDbPluginV2,
# NOTE(zhiyuan) when exception occurs, we update floating ip object # NOTE(zhiyuan) when exception occurs, we update floating ip object
# to rollback fixed_port_id, fixed_ip_address, router_id # to rollback fixed_port_id, fixed_ip_address, router_id
LOG.exception( LOG.exception(
_LE('Fail to update floating ip, reason: ' 'Fail to update floating ip, reason: '
'%(reason)s, rollback floating ip data') % { '%(reason)s, rollback floating ip data' %
'reason': e.message}) {'reason': e.message})
org_data = { org_data = {
'fixed_port_id': org_floatingip_dict['port_id'], 'fixed_port_id': org_floatingip_dict['port_id'],
'fixed_ip_address': org_floatingip_dict['fixed_ip_address'], 'fixed_ip_address': org_floatingip_dict['fixed_ip_address'],
@ -1754,8 +1754,8 @@ class TricirclePlugin(db_base_plugin_v2.NeutronDbPluginV2,
# top and bottom internal port, this is an inconsistent state, # top and bottom internal port, this is an inconsistent state,
# but since bottom internal port does not exist, no operation # but since bottom internal port does not exist, no operation
# in bottom pod is required # in bottom pod is required
LOG.warning(_LW('Internal port associated with floating ip ' LOG.warning('Internal port associated with floating ip '
'does not exist in bottom pod.')) 'does not exist in bottom pod.')
return return
b_int_net_pod, b_int_port_id = mappings[0] b_int_net_pod, b_int_port_id = mappings[0]

View File

@ -23,7 +23,6 @@ from neutron.plugins.ml2 import driver_api
from neutron.plugins.ml2.drivers import type_vlan from neutron.plugins.ml2.drivers import type_vlan
from tricircle.common import constants from tricircle.common import constants
from tricircle.common.i18n import _LE, _LI
LOG = log.getLogger(__name__) LOG = log.getLogger(__name__)
@ -37,10 +36,10 @@ class VLANTypeDriver(type_vlan.VlanTypeDriver):
self.network_vlan_ranges = plugin_utils.parse_network_vlan_ranges( self.network_vlan_ranges = plugin_utils.parse_network_vlan_ranges(
cfg.CONF.tricircle.network_vlan_ranges) cfg.CONF.tricircle.network_vlan_ranges)
except Exception: except Exception:
LOG.exception(_LE('Failed to parse network_vlan_ranges. ' LOG.exception('Failed to parse network_vlan_ranges. '
'Service terminated!')) 'Service terminated!')
sys.exit(1) sys.exit(1)
LOG.info(_LI('Network VLAN ranges: %s'), self.network_vlan_ranges) LOG.info('Network VLAN ranges: %s', self.network_vlan_ranges)
def get_type(self): def get_type(self):
return constants.NT_VLAN return constants.NT_VLAN

View File

@ -21,7 +21,6 @@ from neutron.plugins.ml2.drivers import type_vxlan
from neutron_lib import exceptions as n_exc from neutron_lib import exceptions as n_exc
from tricircle.common import constants from tricircle.common import constants
from tricircle.common.i18n import _LE
LOG = log.getLogger(__name__) LOG = log.getLogger(__name__)
@ -37,8 +36,8 @@ class VxLANTypeDriver(type_vxlan.VxlanTypeDriver):
try: try:
self._initialize(cfg.CONF.tricircle.vni_ranges) self._initialize(cfg.CONF.tricircle.vni_ranges)
except n_exc.NetworkTunnelRangeError: except n_exc.NetworkTunnelRangeError:
LOG.exception(_LE("Failed to parse vni_ranges. " LOG.exception("Failed to parse vni_ranges. "
"Service terminated!")) "Service terminated!")
raise SystemExit() raise SystemExit()
def reserve_provider_segment(self, context, segment): def reserve_provider_segment(self, context, segment):

View File

@ -32,7 +32,7 @@ from neutron.plugins.ml2 import plugin
from tricircle.common import client from tricircle.common import client
import tricircle.common.constants as t_constants import tricircle.common.constants as t_constants
import tricircle.common.context as t_context import tricircle.common.context as t_context
from tricircle.common.i18n import _, _LE from tricircle.common.i18n import _
from tricircle.common import resource_handle from tricircle.common import resource_handle
import tricircle.common.utils as t_utils import tricircle.common.utils as t_utils
@ -286,9 +286,9 @@ class TricirclePlugin(plugin.Ml2Plugin):
located = self._is_network_located_in_region(network, located = self._is_network_located_in_region(network,
region_name) region_name)
if not located: if not located:
LOG.error(_LE('network: %(net_id)s not located in current ' LOG.error('network: %(net_id)s not located in current '
'region: %(region_name)s, ' 'region: %(region_name)s, '
'az_hints: %(az_hints)s'), 'az_hints: %(az_hints)s',
{'net_id': network['id'], {'net_id': network['id'],
'region_name': region_name, 'region_name': region_name,
'az_hints': network[az_ext.AZ_HINTS]}) 'az_hints': network[az_ext.AZ_HINTS]})
@ -566,8 +566,8 @@ class TricirclePlugin(plugin.Ml2Plugin):
profile_dict) profile_dict)
elif cfg.CONF.client.cross_pod_vxlan_mode == t_constants.NM_L2GW: elif cfg.CONF.client.cross_pod_vxlan_mode == t_constants.NM_L2GW:
if not cfg.CONF.tricircle.l2gw_tunnel_ip: if not cfg.CONF.tricircle.l2gw_tunnel_ip:
LOG.error(_LE('Cross-pod VxLAN networking mode is set to l2gw ' LOG.error('Cross-pod VxLAN networking mode is set to l2gw '
'but L2 gateway tunnel ip is not configured')) 'but L2 gateway tunnel ip is not configured')
return return
l2gw_tunnel_ip = cfg.CONF.tricircle.l2gw_tunnel_ip l2gw_tunnel_ip = cfg.CONF.tricircle.l2gw_tunnel_ip
helper.NetworkHelper.fill_agent_data(agent_type, host, agents[0], helper.NetworkHelper.fill_agent_data(agent_type, host, agents[0],

View File

@ -18,9 +18,6 @@ from oslo_log import log
from neutron.plugins.ml2 import managers from neutron.plugins.ml2 import managers
from tricircle.common.i18n import _LE
from tricircle.common.i18n import _LI
LOG = log.getLogger(__name__) LOG = log.getLogger(__name__)
@ -36,7 +33,7 @@ class TricircleTypeManager(managers.TypeManager):
'tricircle.network.type_drivers', 'tricircle.network.type_drivers',
cfg.CONF.tricircle.type_drivers, cfg.CONF.tricircle.type_drivers,
invoke_on_load=True) invoke_on_load=True)
LOG.info(_LI('Loaded type driver names: %s'), self.names()) LOG.info('Loaded type driver names: %s', self.names())
self._register_types() self._register_types()
self._check_tenant_network_types( self._check_tenant_network_types(
@ -48,14 +45,14 @@ class TricircleTypeManager(managers.TypeManager):
if not bridge_network_type: if not bridge_network_type:
return return
if bridge_network_type == 'local': if bridge_network_type == 'local':
LOG.error(_LE("Local is not a valid bridge network type. " LOG.error("Local is not a valid bridge network type. "
"Service terminated!"), bridge_network_type) "Service terminated!", bridge_network_type)
raise SystemExit(1) raise SystemExit(1)
type_set = set(self.tenant_network_types) type_set = set(self.tenant_network_types)
if bridge_network_type not in type_set: if bridge_network_type not in type_set:
LOG.error(_LE("Bridge network type %s is not registered. " LOG.error("Bridge network type %s is not registered. "
"Service terminated!"), bridge_network_type) "Service terminated!", bridge_network_type)
raise SystemExit(1) raise SystemExit(1)
def _register_types(self): def _register_types(self):

View File

@ -31,7 +31,6 @@ import neutronclient.common.exceptions as q_cli_exceptions
from tricircle.common import client from tricircle.common import client
from tricircle.common import constants from tricircle.common import constants
from tricircle.common.i18n import _LE, _LI, _LW
from tricircle.common import xrpcapi from tricircle.common import xrpcapi
import tricircle.db.api as db_api import tricircle.db.api as db_api
import tricircle.network.exceptions as t_network_exc import tricircle.network.exceptions as t_network_exc
@ -96,9 +95,9 @@ def _job_handle(job_type):
# fail and try again to obtain the lock # fail and try again to obtain the lock
db_api.finish_job(ctx, running_job['id'], False, db_api.finish_job(ctx, running_job['id'], False,
time_new) time_new)
LOG.warning(_LW('Job %(job)s of type %(job_type)s for ' LOG.warning('Job %(job)s of type %(job_type)s for '
'resource %(resource)s expires, set ' 'resource %(resource)s expires, set '
'its state to Fail'), 'its state to Fail',
{'job': running_job['id'], {'job': running_job['id'],
'job_type': job_type, 'job_type': job_type,
'resource': resource_id}) 'resource': resource_id})
@ -113,8 +112,8 @@ def _job_handle(job_type):
func(*args, **kwargs) func(*args, **kwargs)
except Exception: except Exception:
db_api.finish_job(ctx, job['id'], False, time_new) db_api.finish_job(ctx, job['id'], False, time_new)
LOG.error(_LE('Job %(job)s of type %(job_type)s for ' LOG.error('Job %(job)s of type %(job_type)s for '
'resource %(resource)s fails'), 'resource %(resource)s fails',
{'job': job['id'], {'job': job['id'],
'job_type': job_type, 'job_type': job_type,
'resource': resource_id}) 'resource': resource_id})
@ -210,7 +209,7 @@ class XManager(PeriodicTasks):
# rpc message endpoint handling # rpc message endpoint handling
def test_rpc(self, ctx, payload): def test_rpc(self, ctx, payload):
LOG.info(_LI("xmanager receive payload: %s"), payload) LOG.info("xmanager receive payload: %s", payload)
info_text = "xmanager receive payload: %s" % payload info_text = "xmanager receive payload: %s" % payload
@ -408,8 +407,8 @@ class XManager(PeriodicTasks):
b_int_port_id = db_api.get_bottom_id_by_top_id_region_name( b_int_port_id = db_api.get_bottom_id_by_top_id_region_name(
ctx, t_int_port_id, b_pod['region_name'], constants.RT_PORT) ctx, t_int_port_id, b_pod['region_name'], constants.RT_PORT)
if not b_int_port_id: if not b_int_port_id:
LOG.warning(_LW('Port %(port_id)s associated with floating ip ' LOG.warning('Port %(port_id)s associated with floating ip '
'%(fip)s is not mapped to bottom pod'), '%(fip)s is not mapped to bottom pod',
{'port_id': t_int_port_id, 'fip': add_fip}) {'port_id': t_int_port_id, 'fip': add_fip})
continue continue
t_int_port = t_client.get_ports(ctx, t_int_port_id) t_int_port = t_client.get_ports(ctx, t_int_port_id)
@ -818,8 +817,8 @@ class XManager(PeriodicTasks):
try: try:
b_client.update_networks(ctx, b_network_id, body) b_client.update_networks(ctx, b_network_id, body)
except q_cli_exceptions.NotFound: except q_cli_exceptions.NotFound:
LOG.error(_LE('network: %(net_id)s not found,' LOG.error('network: %(net_id)s not found,'
'pod name: %(name)s'), 'pod name: %(name)s',
{'net_id': b_network_id, 'name': b_region_name}) {'net_id': b_network_id, 'name': b_region_name})
@_job_handle(constants.JT_SUBNET_UPDATE) @_job_handle(constants.JT_SUBNET_UPDATE)
@ -879,8 +878,8 @@ class XManager(PeriodicTasks):
try: try:
b_client.update_subnets(ctx, b_subnet_id, body) b_client.update_subnets(ctx, b_subnet_id, body)
except q_cli_exceptions.NotFound: except q_cli_exceptions.NotFound:
LOG.error(_LE('subnet: %(subnet_id)s not found, ' LOG.error('subnet: %(subnet_id)s not found, '
'pod name: %(name)s'), 'pod name: %(name)s',
{'subnet_id': b_subnet_id, 'name': b_region_name}) {'subnet_id': b_subnet_id, 'name': b_region_name})
@_job_handle(constants.JT_SHADOW_PORT_SETUP) @_job_handle(constants.JT_SHADOW_PORT_SETUP)
@ -991,10 +990,10 @@ class XManager(PeriodicTasks):
else: else:
agent = db_api.get_agent_by_host_type(ctx, host, agent_type) agent = db_api.get_agent_by_host_type(ctx, host, agent_type)
if not agent: if not agent:
LOG.error(_LE('Agent of type %(agent_type)s in ' LOG.error('Agent of type %(agent_type)s in '
'host %(host)s not found during shadow ' 'host %(host)s not found during shadow '
'ports setup'), {'agent_type': agent_type, 'ports setup',
'host': host}) {'agent_type': agent_type, 'host': host})
continue continue
agent_info_map[key] = agent agent_info_map[key] = agent
port_bodys.append(port_body) port_bodys.append(port_body)

View File

@ -24,7 +24,7 @@ from oslo_log import log as logging
import oslo_messaging as messaging import oslo_messaging as messaging
from oslo_service import service as srv from oslo_service import service as srv
from tricircle.common.i18n import _, _LE, _LI from tricircle.common.i18n import _
from tricircle.common import baserpc from tricircle.common import baserpc
from tricircle.common import context from tricircle.common import context
@ -113,10 +113,9 @@ class XService(srv.Service):
def start(self): def start(self):
ver_str = version.version_info ver_str = version.version_info
LOG.info(_LI('Starting %(topic)s node (version %(version)s)'), LOG.info('Starting %(topic)s node (version %(version)s)',
{'topic': self.topic, 'version': ver_str}) {'topic': self.topic, 'version': ver_str})
self.basic_config_check()
self.manager.init_host() self.manager.init_host()
self.manager.pre_start_hook() self.manager.pre_start_hook()
@ -206,7 +205,7 @@ class XService(srv.Service):
try: try:
self.manager.cleanup_host() self.manager.cleanup_host()
except Exception: except Exception:
LOG.exception(_LE('Service error occurred during cleanup_host')) LOG.exception('Service error occurred during cleanup_host')
pass pass
super(XService, self).stop() super(XService, self).stop()
@ -216,16 +215,6 @@ class XService(srv.Service):
ctxt = context.get_admin_context() ctxt = context.get_admin_context()
return self.manager.periodic_tasks(ctxt, raise_on_error=raise_on_error) return self.manager.periodic_tasks(ctxt, raise_on_error=raise_on_error)
def basic_config_check(self):
"""Perform basic config checks before starting processing."""
# Make sure the tempdir exists and is writable
# try:
# with utils.tempdir():
# pass
# except Exception as e:
# LOG.error(_LE('Temporary directory is invalid: %s'), e)
# sys.exit(1)
def create_service(): def create_service():