From bbdbae420980395de5bfa05220e669b1657357a9 Mon Sep 17 00:00:00 2001 From: lihaijing Date: Tue, 21 Mar 2017 14:02:25 +0800 Subject: [PATCH] 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 --- tricircle/api/controllers/pod.py | 25 +++++++++---------- tricircle/api/controllers/routing.py | 21 ++++++++-------- tricircle/api/wsgi.py | 3 +-- tricircle/cmd/api.py | 8 +++--- tricircle/cmd/xjob.py | 7 +++--- tricircle/common/client.py | 9 +++---- tricircle/common/config.py | 6 ++--- tricircle/common/exceptions.py | 5 ++-- tricircle/common/httpclient.py | 3 +-- tricircle/common/i18n.py | 10 -------- tricircle/common/policy.py | 3 +-- tricircle/db/api.py | 5 ++-- tricircle/network/central_plugin.py | 24 +++++++++--------- tricircle/network/drivers/type_vlan.py | 7 +++--- tricircle/network/drivers/type_vxlan.py | 5 ++-- tricircle/network/local_plugin.py | 12 ++++----- tricircle/network/managers.py | 13 ++++------ tricircle/xjob/xmanager.py | 33 ++++++++++++------------- tricircle/xjob/xservice.py | 17 +++---------- 19 files changed, 88 insertions(+), 128 deletions(-) diff --git a/tricircle/api/controllers/pod.py b/tricircle/api/controllers/pod.py index 5e780c74..481b9a3d 100644 --- a/tricircle/api/controllers/pod.py +++ b/tricircle/api/controllers/pod.py @@ -25,7 +25,6 @@ from oslo_utils import uuidutils import tricircle.common.context as t_context import tricircle.common.exceptions as t_exc from tricircle.common.i18n import _ -from tricircle.common.i18n import _LE from tricircle.common import policy from tricircle.db import api as db_api @@ -95,17 +94,17 @@ class PodsController(rest.RestController): 'dc_name': dc_name, 'az_name': az_name}) except db_exc.DBDuplicateEntry as e1: - LOG.exception(_LE('Record already exists on %(region_name)s: ' - '%(exception)s'), + LOG.exception('Record already exists on %(region_name)s: ' + '%(exception)s', {'region_name': region_name, - 'exception': e1}) + 'exception': e1}) return Response(_('Record already exists'), 409) except Exception as e2: - LOG.exception(_LE('Failed to create pod: %(region_name)s,' - 'pod_az_name: %(pod_az_name)s,' - 'dc_name: %(dc_name)s,' - 'az_name: %(az_name)s' - '%(exception)s '), + LOG.exception('Failed to create pod: %(region_name)s,' + 'pod_az_name: %(pod_az_name)s,' + 'dc_name: %(dc_name)s,' + 'az_name: %(az_name)s' + '%(exception)s ', {'region_name': region_name, 'pod_az_name': pod_az_name, 'dc_name': dc_name, @@ -140,7 +139,7 @@ class PodsController(rest.RestController): try: return {'pods': db_api.list_pods(context)} 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}) pecan.abort(500, _('Failed to list pods')) @@ -162,8 +161,8 @@ class PodsController(rest.RestController): except t_exc.ResourceNotFound: return Response(_('Pod not found'), 404) except Exception as e: - LOG.exception(_LE('Failed to delete pod: %(pod_id)s,' - '%(exception)s'), + LOG.exception('Failed to delete pod: %(pod_id)s,' + '%(exception)s', {'pod_id': _id, 'exception': e}) @@ -179,7 +178,7 @@ class PodsController(rest.RestController): if pod['az_name'] == '' and pod['region_name'] != '': return pod['region_name'] 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}) return top_region_name diff --git a/tricircle/api/controllers/routing.py b/tricircle/api/controllers/routing.py index bfe07b5e..979bfcb1 100644 --- a/tricircle/api/controllers/routing.py +++ b/tricircle/api/controllers/routing.py @@ -21,7 +21,6 @@ from tricircle.common import constants import tricircle.common.context as t_context import tricircle.common.exceptions as t_exc from tricircle.common.i18n import _ -from tricircle.common.i18n import _LE from tricircle.common import policy from tricircle.common import utils @@ -81,8 +80,8 @@ class RoutingController(rest.RestController): return utils.format_api_error( 409, _('Resource routing already exists')) except Exception as e: - LOG.exception(_LE('Failed to create resource routing: ' - '%(exception)s '), {'exception': e}) + LOG.exception('Failed to create resource routing: ' + '%(exception)s ', {'exception': e}) return utils.format_api_error( 500, _('Failed to create resource routing')) @@ -120,8 +119,8 @@ class RoutingController(rest.RestController): return {'routings': db_api.list_resource_routings(context, filters)} except Exception as e: - LOG.exception(_LE('Failed to show all resource routings: ' - '%(exception)s '), {'exception': e}) + LOG.exception('Failed to show all resource routings: ' + '%(exception)s ', {'exception': e}) return utils.format_api_error( 500, _('Failed to show all resource routings')) @@ -157,8 +156,8 @@ class RoutingController(rest.RestController): pecan.response.status = 200 return pecan.response except Exception as e: - LOG.exception(_LE('Failed to delete the resource routing: ' - '%(exception)s '), {'exception': e}) + LOG.exception('Failed to delete the resource routing: ' + '%(exception)s ', {'exception': e}) return utils.format_api_error( 500, _('Failed to delete the resource routing')) @@ -208,8 +207,8 @@ class RoutingController(rest.RestController): 400, _("The pod %(new_pod_id)s doesn't" " exist") % {'new_pod_id': new_pod_id}) except Exception as e: - LOG.exception(_LE('Failed to update resource routing: ' - '%(exception)s '), {'exception': e}) + LOG.exception('Failed to update resource routing: ' + '%(exception)s ', {'exception': e}) return utils.format_api_error( 500, _('Failed to update resource routing')) @@ -218,7 +217,7 @@ class RoutingController(rest.RestController): context, _id, update_dict) return {'routing': routing_updated} except Exception as e: - LOG.exception(_LE('Failed to update resource routing: ' - '%(exception)s '), {'exception': e}) + LOG.exception('Failed to update resource routing: ' + '%(exception)s ', {'exception': e}) return utils.format_api_error( 500, _('Failed to update resource routing')) diff --git a/tricircle/api/wsgi.py b/tricircle/api/wsgi.py index 21896717..112ff782 100644 --- a/tricircle/api/wsgi.py +++ b/tricircle/api/wsgi.py @@ -28,7 +28,6 @@ from oslo_log import log as logging from tricircle.api import app from tricircle.common import config -from tricircle.common.i18n import _LI CONFIG_FILE = 'api.conf' @@ -50,7 +49,7 @@ def init_application(): conf_file = _get_config_file() config.init(app.common_opts, ['--config-file', conf_file]) - LOG.info(_LI("Configuration:")) + LOG.info("Configuration:") CONF.log_opt_values(LOG, logging.INFO) # return WSGI app diff --git a/tricircle/cmd/api.py b/tricircle/cmd/api.py index 06fbc319..65c4b9c9 100644 --- a/tricircle/cmd/api.py +++ b/tricircle/cmd/api.py @@ -24,8 +24,6 @@ from oslo_service import wsgi from tricircle.api import app from tricircle.common import config -from tricircle.common.i18n import _LI -from tricircle.common.i18n import _LW from tricircle.common import restapp @@ -42,16 +40,16 @@ def main(): workers = CONF.api_workers if workers < 1: - LOG.warning(_LW("Wrong worker number, worker = %(workers)s"), workers) + LOG.warning("Wrong worker number, worker = %(workers)s", workers) 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}) service = wsgi.Server(CONF, 'Tricircle Admin_API', application, host, port) restapp.serve(service, CONF, workers) - LOG.info(_LI("Configuration:")) + LOG.info("Configuration:") CONF.log_opt_values(LOG, logging.INFO) restapp.wait() diff --git a/tricircle/cmd/xjob.py b/tricircle/cmd/xjob.py index 7889e012..851b781c 100644 --- a/tricircle/cmd/xjob.py +++ b/tricircle/cmd/xjob.py @@ -26,7 +26,6 @@ from oslo_config import cfg from oslo_log import log as logging from tricircle.common import config -from tricircle.common.i18n import _LI, _LW from tricircle.xjob import xservice @@ -41,15 +40,15 @@ def main(): workers = CONF.workers if workers < 1: - LOG.warning(_LW("Wrong worker number, worker = %(workers)s"), workers) + LOG.warning("Wrong worker number, worker = %(workers)s", workers) 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}) xservice.serve(xservice.create_service(), workers) - LOG.info(_LI("Configuration:")) + LOG.info("Configuration:") CONF.log_opt_values(LOG, logging.INFO) xservice.wait() diff --git a/tricircle/common/client.py b/tricircle/common/client.py index 50942937..803f6d7d 100644 --- a/tricircle/common/client.py +++ b/tricircle/common/client.py @@ -28,7 +28,6 @@ from oslo_log import log as logging import tricircle.common.context as tricircle_context from tricircle.common import exceptions -from tricircle.common.i18n import _LW from tricircle.common import resource_handle from tricircle.db import api from tricircle.db import models @@ -98,8 +97,8 @@ def _safe_operation(operation_name): if i == retries: raise if cfg.CONF.client.auto_refresh_endpoint: - LOG.warning(_LW('%(exception)s, ' - 'update endpoint and try again'), + LOG.warning('%(exception)s, ' + 'update endpoint and try again', {'exception': e.message}) instance._update_endpoint_from_keystone(context, True) else: @@ -109,8 +108,8 @@ def _safe_operation(operation_name): # for the given pod and service, we add default behaviours # for the handle functions if i < retries and cfg.CONF.client.auto_refresh_endpoint: - LOG.warning(_LW('%(exception)s, ' - 'update endpoint and try again'), + LOG.warning('%(exception)s, ' + 'update endpoint and try again', {'exception': e.message}) instance._update_endpoint_from_keystone(context, True) continue diff --git a/tricircle/common/config.py b/tricircle/common/config.py index 4a64cc5b..a079bc99 100644 --- a/tricircle/common/config.py +++ b/tricircle/common/config.py @@ -22,8 +22,6 @@ from oslo_config import cfg import oslo_log.log as logging from oslo_policy import opts as policy_opts -from tricircle.common.i18n import _LI - from tricircle.common import policy from tricircle.common import rpc from tricircle.common import version @@ -53,8 +51,8 @@ def _setup_logging(): """Sets up the logging options for a log with supplied name.""" product_name = "tricircle" logging.setup(cfg.CONF, product_name) - LOG.info(_LI("Logging enabled!")) - LOG.info(_LI("%(prog)s version %(version)s"), + LOG.info("Logging enabled!") + LOG.info("%(prog)s version %(version)s", {'prog': sys.argv[0], 'version': version.version_info}) LOG.debug("command line: %s", " ".join(sys.argv)) diff --git a/tricircle/common/exceptions.py b/tricircle/common/exceptions.py index ae2172a4..f4a163ee 100644 --- a/tricircle/common/exceptions.py +++ b/tricircle/common/exceptions.py @@ -23,7 +23,6 @@ from neutron_lib import exceptions from oslo_log import log as logging from tricircle.common.i18n import _ -from tricircle.common.i18n import _LE LOG = logging.getLogger(__name__) @@ -91,8 +90,8 @@ class TricircleException(Exception): def _should_format(self): if self.kwargs['message'] is None and '%(message)' in self.message: - LOG.error(_LE('\%(message)s in message ' - 'but init parameter is None')) + LOG.error('\%(message)s in message ' + 'but init parameter is None') return self.kwargs['message'] is None or '%(message)' in self.message diff --git a/tricircle/common/httpclient.py b/tricircle/common/httpclient.py index f693c133..992416f8 100644 --- a/tricircle/common/httpclient.py +++ b/tricircle/common/httpclient.py @@ -21,7 +21,6 @@ from oslo_log import log as logging from tricircle.common import client from tricircle.common import constants as cons -from tricircle.common.i18n import _LE 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) if s_ctx['b_url'] == '': - LOG.error(_LE("bottom pod endpoint incorrect %s") % + LOG.error("bottom pod endpoint incorrect %s" % region_name) return s_ctx diff --git a/tricircle/common/i18n.py b/tricircle/common/i18n.py index bb53d287..ad33230c 100644 --- a/tricircle/common/i18n.py +++ b/tricircle/common/i18n.py @@ -18,13 +18,3 @@ _translators = oslo_i18n.TranslatorFactory(domain='tricircle') # The primary translation function using the well-known name "_" _ = _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 diff --git a/tricircle/common/policy.py b/tricircle/common/policy.py index 35fdcf19..34de2409 100644 --- a/tricircle/common/policy.py +++ b/tricircle/common/policy.py @@ -31,7 +31,6 @@ import oslo_log.log as logging from oslo_policy import policy from tricircle.common import exceptions as t_exec -from tricircle.common.i18n import _LE _ENFORCER = None CONF = cfg.CONF @@ -185,6 +184,6 @@ def enforce(context, rule=None, target=None, *args, **kwargs): except t_exec.PolicyNotAuthorized as e: 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}) return result diff --git a/tricircle/db/api.py b/tricircle/db/api.py index 1649e4bf..b99b521a 100644 --- a/tricircle/db/api.py +++ b/tricircle/db/api.py @@ -29,7 +29,6 @@ from tricircle.common import constants from tricircle.common.context import is_admin_context as _is_admin_context from tricircle.common import exceptions from tricircle.common.i18n import _ -from tricircle.common.i18n import _LW from tricircle.db import core from tricircle.db import models @@ -562,8 +561,8 @@ def _retry_on_deadlock(f): try: return f(*args, **kwargs) except db_exc.DBDeadlock: - LOG.warning(_LW("Deadlock detected when running " - "'%(func_name)s': Retrying..."), + LOG.warning("Deadlock detected when running " + "'%(func_name)s': Retrying...", dict(func_name=f.__name__)) # Retry! time.sleep(0.5) diff --git a/tricircle/network/central_plugin.py b/tricircle/network/central_plugin.py index daedbfbb..f3dc0d85 100644 --- a/tricircle/network/central_plugin.py +++ b/tricircle/network/central_plugin.py @@ -57,7 +57,7 @@ import tricircle.common.client as t_client import tricircle.common.constants as t_constants import tricircle.common.context as t_context 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 import tricircle.db.api as db_api from tricircle.db import core @@ -151,7 +151,7 @@ class TricirclePlugin(db_base_plugin_v2.NeutronDbPluginV2, def __init__(self): super(TricirclePlugin, self).__init__() - LOG.info(_LI("Starting Tricircle Neutron Plugin")) + LOG.info("Starting Tricircle Neutron Plugin") self.clients = {} self.xjob_handler = xrpcapi.XJobAPI() self._setup_rpc() @@ -568,7 +568,7 @@ class TricirclePlugin(db_base_plugin_v2.NeutronDbPluginV2, updated_sens_attrs.append('%s = %s' % (key, request_body[key])) 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}) 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) except q_cli_exceptions.NotFound: LOG.error( - _LE('port: %(port_id)s not found, ' - 'region name: %(name)s'), + ('port: %(port_id)s not found, ' + 'region name: %(name)s'), {'port_id': b_port_id, 'name': b_region_name}) if request_body.get('security_groups', None): @@ -1681,8 +1681,8 @@ class TricirclePlugin(db_base_plugin_v2.NeutronDbPluginV2, floating_ip.update(org_data) except Exception as e: # log the exception and re-raise it - LOG.exception(_LE('Fail to rollback floating ip data, reason: ' - '%(reason)s') % {'reason': e.message}) + LOG.exception('Fail to rollback floating ip data, reason: ' + '%(reason)s' % {'reason': e.message}) raise 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 # to rollback fixed_port_id, fixed_ip_address, router_id LOG.exception( - _LE('Fail to update floating ip, reason: ' - '%(reason)s, rollback floating ip data') % { - 'reason': e.message}) + 'Fail to update floating ip, reason: ' + '%(reason)s, rollback floating ip data' % + {'reason': e.message}) org_data = { 'fixed_port_id': org_floatingip_dict['port_id'], '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, # but since bottom internal port does not exist, no operation # in bottom pod is required - LOG.warning(_LW('Internal port associated with floating ip ' - 'does not exist in bottom pod.')) + LOG.warning('Internal port associated with floating ip ' + 'does not exist in bottom pod.') return b_int_net_pod, b_int_port_id = mappings[0] diff --git a/tricircle/network/drivers/type_vlan.py b/tricircle/network/drivers/type_vlan.py index e7365bba..c04942e1 100644 --- a/tricircle/network/drivers/type_vlan.py +++ b/tricircle/network/drivers/type_vlan.py @@ -23,7 +23,6 @@ from neutron.plugins.ml2 import driver_api from neutron.plugins.ml2.drivers import type_vlan from tricircle.common import constants -from tricircle.common.i18n import _LE, _LI LOG = log.getLogger(__name__) @@ -37,10 +36,10 @@ class VLANTypeDriver(type_vlan.VlanTypeDriver): self.network_vlan_ranges = plugin_utils.parse_network_vlan_ranges( cfg.CONF.tricircle.network_vlan_ranges) except Exception: - LOG.exception(_LE('Failed to parse network_vlan_ranges. ' - 'Service terminated!')) + LOG.exception('Failed to parse network_vlan_ranges. ' + 'Service terminated!') 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): return constants.NT_VLAN diff --git a/tricircle/network/drivers/type_vxlan.py b/tricircle/network/drivers/type_vxlan.py index bd6c63c4..f4c26afc 100644 --- a/tricircle/network/drivers/type_vxlan.py +++ b/tricircle/network/drivers/type_vxlan.py @@ -21,7 +21,6 @@ from neutron.plugins.ml2.drivers import type_vxlan from neutron_lib import exceptions as n_exc from tricircle.common import constants -from tricircle.common.i18n import _LE LOG = log.getLogger(__name__) @@ -37,8 +36,8 @@ class VxLANTypeDriver(type_vxlan.VxlanTypeDriver): try: self._initialize(cfg.CONF.tricircle.vni_ranges) except n_exc.NetworkTunnelRangeError: - LOG.exception(_LE("Failed to parse vni_ranges. " - "Service terminated!")) + LOG.exception("Failed to parse vni_ranges. " + "Service terminated!") raise SystemExit() def reserve_provider_segment(self, context, segment): diff --git a/tricircle/network/local_plugin.py b/tricircle/network/local_plugin.py index bbd9a4e9..18c1bbee 100644 --- a/tricircle/network/local_plugin.py +++ b/tricircle/network/local_plugin.py @@ -32,7 +32,7 @@ from neutron.plugins.ml2 import plugin from tricircle.common import client import tricircle.common.constants as t_constants import tricircle.common.context as t_context -from tricircle.common.i18n import _, _LE +from tricircle.common.i18n import _ from tricircle.common import resource_handle import tricircle.common.utils as t_utils @@ -286,9 +286,9 @@ class TricirclePlugin(plugin.Ml2Plugin): located = self._is_network_located_in_region(network, region_name) if not located: - LOG.error(_LE('network: %(net_id)s not located in current ' - 'region: %(region_name)s, ' - 'az_hints: %(az_hints)s'), + LOG.error('network: %(net_id)s not located in current ' + 'region: %(region_name)s, ' + 'az_hints: %(az_hints)s', {'net_id': network['id'], 'region_name': region_name, 'az_hints': network[az_ext.AZ_HINTS]}) @@ -566,8 +566,8 @@ class TricirclePlugin(plugin.Ml2Plugin): profile_dict) elif cfg.CONF.client.cross_pod_vxlan_mode == t_constants.NM_L2GW: if not cfg.CONF.tricircle.l2gw_tunnel_ip: - LOG.error(_LE('Cross-pod VxLAN networking mode is set to l2gw ' - 'but L2 gateway tunnel ip is not configured')) + LOG.error('Cross-pod VxLAN networking mode is set to l2gw ' + 'but L2 gateway tunnel ip is not configured') return l2gw_tunnel_ip = cfg.CONF.tricircle.l2gw_tunnel_ip helper.NetworkHelper.fill_agent_data(agent_type, host, agents[0], diff --git a/tricircle/network/managers.py b/tricircle/network/managers.py index cda16f5a..cb1cfa1a 100644 --- a/tricircle/network/managers.py +++ b/tricircle/network/managers.py @@ -18,9 +18,6 @@ from oslo_log import log from neutron.plugins.ml2 import managers -from tricircle.common.i18n import _LE -from tricircle.common.i18n import _LI - LOG = log.getLogger(__name__) @@ -36,7 +33,7 @@ class TricircleTypeManager(managers.TypeManager): 'tricircle.network.type_drivers', cfg.CONF.tricircle.type_drivers, 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._check_tenant_network_types( @@ -48,14 +45,14 @@ class TricircleTypeManager(managers.TypeManager): if not bridge_network_type: return if bridge_network_type == 'local': - LOG.error(_LE("Local is not a valid bridge network type. " - "Service terminated!"), bridge_network_type) + LOG.error("Local is not a valid bridge network type. " + "Service terminated!", bridge_network_type) raise SystemExit(1) type_set = set(self.tenant_network_types) if bridge_network_type not in type_set: - LOG.error(_LE("Bridge network type %s is not registered. " - "Service terminated!"), bridge_network_type) + LOG.error("Bridge network type %s is not registered. " + "Service terminated!", bridge_network_type) raise SystemExit(1) def _register_types(self): diff --git a/tricircle/xjob/xmanager.py b/tricircle/xjob/xmanager.py index 58ce4f98..d6ba53ff 100644 --- a/tricircle/xjob/xmanager.py +++ b/tricircle/xjob/xmanager.py @@ -31,7 +31,6 @@ import neutronclient.common.exceptions as q_cli_exceptions from tricircle.common import client from tricircle.common import constants -from tricircle.common.i18n import _LE, _LI, _LW from tricircle.common import xrpcapi import tricircle.db.api as db_api 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 db_api.finish_job(ctx, running_job['id'], False, time_new) - LOG.warning(_LW('Job %(job)s of type %(job_type)s for ' - 'resource %(resource)s expires, set ' - 'its state to Fail'), + LOG.warning('Job %(job)s of type %(job_type)s for ' + 'resource %(resource)s expires, set ' + 'its state to Fail', {'job': running_job['id'], 'job_type': job_type, 'resource': resource_id}) @@ -113,8 +112,8 @@ def _job_handle(job_type): func(*args, **kwargs) except Exception: db_api.finish_job(ctx, job['id'], False, time_new) - LOG.error(_LE('Job %(job)s of type %(job_type)s for ' - 'resource %(resource)s fails'), + LOG.error('Job %(job)s of type %(job_type)s for ' + 'resource %(resource)s fails', {'job': job['id'], 'job_type': job_type, 'resource': resource_id}) @@ -210,7 +209,7 @@ class XManager(PeriodicTasks): # rpc message endpoint handling 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 @@ -408,8 +407,8 @@ class XManager(PeriodicTasks): 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) if not b_int_port_id: - LOG.warning(_LW('Port %(port_id)s associated with floating ip ' - '%(fip)s is not mapped to bottom pod'), + LOG.warning('Port %(port_id)s associated with floating ip ' + '%(fip)s is not mapped to bottom pod', {'port_id': t_int_port_id, 'fip': add_fip}) continue t_int_port = t_client.get_ports(ctx, t_int_port_id) @@ -818,8 +817,8 @@ class XManager(PeriodicTasks): try: b_client.update_networks(ctx, b_network_id, body) except q_cli_exceptions.NotFound: - LOG.error(_LE('network: %(net_id)s not found,' - 'pod name: %(name)s'), + LOG.error('network: %(net_id)s not found,' + 'pod name: %(name)s', {'net_id': b_network_id, 'name': b_region_name}) @_job_handle(constants.JT_SUBNET_UPDATE) @@ -879,8 +878,8 @@ class XManager(PeriodicTasks): try: b_client.update_subnets(ctx, b_subnet_id, body) except q_cli_exceptions.NotFound: - LOG.error(_LE('subnet: %(subnet_id)s not found, ' - 'pod name: %(name)s'), + LOG.error('subnet: %(subnet_id)s not found, ' + 'pod name: %(name)s', {'subnet_id': b_subnet_id, 'name': b_region_name}) @_job_handle(constants.JT_SHADOW_PORT_SETUP) @@ -991,10 +990,10 @@ class XManager(PeriodicTasks): else: agent = db_api.get_agent_by_host_type(ctx, host, agent_type) if not agent: - LOG.error(_LE('Agent of type %(agent_type)s in ' - 'host %(host)s not found during shadow ' - 'ports setup'), {'agent_type': agent_type, - 'host': host}) + LOG.error('Agent of type %(agent_type)s in ' + 'host %(host)s not found during shadow ' + 'ports setup', + {'agent_type': agent_type, 'host': host}) continue agent_info_map[key] = agent port_bodys.append(port_body) diff --git a/tricircle/xjob/xservice.py b/tricircle/xjob/xservice.py index b19b9940..7de5d84d 100644 --- a/tricircle/xjob/xservice.py +++ b/tricircle/xjob/xservice.py @@ -24,7 +24,7 @@ from oslo_log import log as logging import oslo_messaging as messaging 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 context @@ -113,10 +113,9 @@ class XService(srv.Service): def start(self): 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}) - self.basic_config_check() self.manager.init_host() self.manager.pre_start_hook() @@ -206,7 +205,7 @@ class XService(srv.Service): try: self.manager.cleanup_host() except Exception: - LOG.exception(_LE('Service error occurred during cleanup_host')) + LOG.exception('Service error occurred during cleanup_host') pass super(XService, self).stop() @@ -216,16 +215,6 @@ class XService(srv.Service): ctxt = context.get_admin_context() 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():