From: Irena Berezovsky Date: Sun, 23 Nov 2014 13:39:09 +0000 (+0200) Subject: Update i18n translation for Mellanox plugin and agent log msg's X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=9a8934d05c6cb19f1d2f938422c8304b5d296460;p=openstack-build%2Fneutron-build.git Update i18n translation for Mellanox plugin and agent log msg's All the existing LOG.info, LOG.warning, LOG.error and LOG.critical messages should have _LI, _LW, _LE and _LC respectively. Also, debug level log shouldn't be translated. This patch set will cover the mlnx directory under neutron/plugins. Change-Id: Idfdb38360888002b066c8ac2d177a92b2ac173f4 Partial-Bug: #1320867 --- diff --git a/neutron/hacking/checks.py b/neutron/hacking/checks.py index d45acc5be..214930a23 100644 --- a/neutron/hacking/checks.py +++ b/neutron/hacking/checks.py @@ -77,7 +77,8 @@ def _directory_to_check_translation(filename): "neutron/plugins/ml2", "neutron/plugins/openvswitch", "neutron/plugins/linuxbridge", - "neutron/plugins/vmware"] + "neutron/plugins/vmware", + "neutron/plugins/mlnx"] return any([dir in filename for dir in dirs]) diff --git a/neutron/plugins/mlnx/agent/eswitch_neutron_agent.py b/neutron/plugins/mlnx/agent/eswitch_neutron_agent.py index 3595f0401..b54299a92 100644 --- a/neutron/plugins/mlnx/agent/eswitch_neutron_agent.py +++ b/neutron/plugins/mlnx/agent/eswitch_neutron_agent.py @@ -31,7 +31,7 @@ from neutron.common import rpc as n_rpc from neutron.common import topics from neutron.common import utils as q_utils from neutron import context -from neutron.i18n import _LE, _LI +from neutron.i18n import _LE, _LI, _LW from neutron.openstack.common import log as logging from neutron.openstack.common import loopingcall from neutron.plugins.common import constants as p_const @@ -54,10 +54,10 @@ class EswitchManager(object): for port in data['ports']: if port['port_mac'] == port_mac: return port['port_id'] - err_msg = _("Agent cache inconsistency - port id " - "is not stored for %s") % port_mac - LOG.error(err_msg) - raise exceptions.MlnxException(err_msg=err_msg) + LOG.error(_LE("Agent cache inconsistency - port id " + "is not stored for %s"), port_mac) + raise exceptions.MlnxException(err_msg=("Agent cache inconsistency, " + "check logs")) def get_vnics_mac(self): return set(self.utils.get_attached_vnics().keys()) @@ -69,7 +69,7 @@ class EswitchManager(object): if network_id in self.network_map: del self.network_map[network_id] else: - LOG.debug(_("Network %s not defined on Agent."), network_id) + LOG.debug("Network %s not defined on Agent.", network_id) def port_down(self, network_id, physical_network, port_mac): """Sets port to down. @@ -82,7 +82,7 @@ class EswitchManager(object): if port['port_mac'] == port_mac: self.utils.port_down(physical_network, port_mac) return - LOG.info(_('Network %s is not available on this agent'), network_id) + LOG.info(_LI('Network %s is not available on this agent'), network_id) def port_up(self, network_id, network_type, physical_network, seg_id, port_id, port_mac): @@ -93,7 +93,7 @@ class EswitchManager(object): - configure eswitch vport - set port to Up """ - LOG.debug(_("Connecting port %s"), port_id) + LOG.debug("Connecting port %s", port_id) if network_id not in self.network_map: self.provision_network(port_id, port_mac, @@ -103,8 +103,8 @@ class EswitchManager(object): net_map['ports'].append({'port_id': port_id, 'port_mac': port_mac}) if network_type == p_const.TYPE_VLAN: - LOG.info(_('Binding Segmentation ID %(seg_id)s' - 'to eSwitch for vNIC mac_address %(mac)s'), + LOG.info(_LI('Binding Segmentation ID %(seg_id)s ' + 'to eSwitch for vNIC mac_address %(mac)s'), {'seg_id': seg_id, 'mac': port_mac}) self.utils.set_port_vlan_id(physical_network, @@ -112,7 +112,7 @@ class EswitchManager(object): port_mac) self.utils.port_up(physical_network, port_mac) else: - LOG.error(_('Unsupported network type %s'), network_type) + LOG.error(_LE('Unsupported network type %s'), network_type) def port_release(self, port_mac): """Clear port configuration from eSwitch.""" @@ -122,17 +122,17 @@ class EswitchManager(object): self.utils.port_release(net_data['physical_network'], port['port_mac']) return - LOG.info(_('Port_mac %s is not available on this agent'), port_mac) + LOG.info(_LI('Port_mac %s is not available on this agent'), port_mac) def provision_network(self, port_id, port_mac, network_id, network_type, physical_network, segmentation_id): - LOG.info(_("Provisioning network %s"), network_id) + LOG.info(_LI("Provisioning network %s"), network_id) if network_type == p_const.TYPE_VLAN: - LOG.debug(_("Creating VLAN Network")) + LOG.debug("Creating VLAN Network") else: - LOG.error(_("Unknown network type %(network_type)s " - "for network %(network_id)s"), + LOG.error(_LE("Unknown network type %(network_type)s " + "for network %(network_id)s"), {'network_type': network_type, 'network_id': network_id}) return @@ -160,12 +160,12 @@ class MlnxEswitchRpcCallbacks(n_rpc.RpcCallback, self.sg_agent = agent def network_delete(self, context, **kwargs): - LOG.debug(_("network_delete received")) + LOG.debug("network_delete received") network_id = kwargs.get('network_id') if not network_id: - LOG.warning(_("Invalid Network ID, cannot remove Network")) + LOG.warning(_LW("Invalid Network ID, cannot remove Network")) else: - LOG.debug(_("Delete network %s"), network_id) + LOG.debug("Delete network %s", network_id) self.eswitch.remove_network(network_id) def port_update(self, context, **kwargs): @@ -213,11 +213,11 @@ class MlnxEswitchNeutronAgent(sg_rpc.SecurityGroupAgentRpcMixin): self.agent_state) self.agent_state.pop('start_flag', None) except Exception: - LOG.exception(_("Failed reporting state!")) + LOG.exception(_LE("Failed reporting state!")) def _setup_rpc(self): self.agent_id = 'mlnx-agent.%s' % socket.gethostname() - LOG.info(_("RPC agent_id: %s"), self.agent_id) + LOG.info(_LI("RPC agent_id: %s"), self.agent_id) self.topic = topics.AGENT self.plugin_rpc = MlnxEswitchPluginApi(topics.PLUGIN) @@ -291,7 +291,7 @@ class MlnxEswitchNeutronAgent(sg_rpc.SecurityGroupAgentRpcMixin): else: self.eswitch.port_down(network_id, physical_network, port_mac) else: - LOG.debug(_("No port %s defined on agent."), port_id) + LOG.debug("No port %s defined on agent.", port_id) def treat_devices_added_or_updated(self, devices): try: @@ -308,10 +308,10 @@ class MlnxEswitchNeutronAgent(sg_rpc.SecurityGroupAgentRpcMixin): for dev_details in devs_details_list: device = dev_details['device'] - LOG.info(_("Adding or updating port with mac %s"), device) + LOG.info(_LI("Adding or updating port with mac %s"), device) if 'port_id' in dev_details: - LOG.info(_("Port %s updated"), device) + LOG.info(_LI("Port %s updated"), device) LOG.debug("Device details %s", str(dev_details)) self.treat_vif_port(dev_details['port_id'], dev_details['device'], @@ -336,7 +336,7 @@ class MlnxEswitchNeutronAgent(sg_rpc.SecurityGroupAgentRpcMixin): def treat_devices_removed(self, devices): resync = False for device in devices: - LOG.info(_("Removing device with mac_address %s"), device) + LOG.info(_LI("Removing device with mac_address %s"), device) try: port_id = self.eswitch.get_port_id_by_mac(device) dev_details = self.plugin_rpc.update_device_down(self.context, @@ -344,14 +344,14 @@ class MlnxEswitchNeutronAgent(sg_rpc.SecurityGroupAgentRpcMixin): self.agent_id, cfg.CONF.host) except Exception as e: - LOG.debug(_("Removing port failed for device %(device)s " - "due to %(exc)s"), {'device': device, 'exc': e}) + LOG.debug("Removing port failed for device %(device)s " + "due to %(exc)s", {'device': device, 'exc': e}) resync = True continue if dev_details['exists']: - LOG.info(_("Port %s updated."), device) + LOG.info(_LI("Port %s updated."), device) else: - LOG.debug(_("Device %s not defined on plugin"), device) + LOG.debug("Device %s not defined on plugin", device) self.eswitch.port_release(device) return resync @@ -361,7 +361,7 @@ class MlnxEswitchNeutronAgent(sg_rpc.SecurityGroupAgentRpcMixin): port_info['updated']) def daemon_loop(self): - LOG.info(_("eSwitch Agent Started!")) + LOG.info(_LI("eSwitch Agent Started!")) sync = True port_info = {'current': set(), 'added': set(), @@ -372,8 +372,8 @@ class MlnxEswitchNeutronAgent(sg_rpc.SecurityGroupAgentRpcMixin): try: port_info = self.scan_ports(previous=port_info, sync=sync) except exceptions.RequestTimeout: - LOG.exception(_("Request timeout in agent event loop " - "eSwitchD is not responding - exiting...")) + LOG.exception(_LE("Request timeout in agent event loop " + "eSwitchD is not responding - exiting...")) raise SystemExit(1) if sync: LOG.info(_LI("Agent out of sync with plugin!")) @@ -390,8 +390,8 @@ class MlnxEswitchNeutronAgent(sg_rpc.SecurityGroupAgentRpcMixin): if (elapsed < self._polling_interval): time.sleep(self._polling_interval - elapsed) else: - LOG.debug(_("Loop iteration exceeded interval " - "(%(polling_interval)s vs. %(elapsed)s)"), + LOG.debug("Loop iteration exceeded interval " + "(%(polling_interval)s vs. %(elapsed)s)", {'polling_interval': self._polling_interval, 'elapsed': elapsed}) @@ -404,20 +404,20 @@ def main(): interface_mappings = q_utils.parse_mappings( cfg.CONF.ESWITCH.physical_interface_mappings) except ValueError as e: - LOG.error(_("Parsing physical_interface_mappings failed: %s." - " Agent terminated!"), e) + LOG.error(_LE("Parsing physical_interface_mappings failed: %s. " + "Agent terminated!"), e) sys.exit(1) - LOG.info(_("Interface mappings: %s"), interface_mappings) + LOG.info(_LI("Interface mappings: %s"), interface_mappings) try: agent = MlnxEswitchNeutronAgent(interface_mappings) except Exception as e: - LOG.error(_("Failed on Agent initialisation : %s." - " Agent terminated!"), e) + LOG.error(_LE("Failed on Agent initialisation : %s. " + "Agent terminated!"), e) sys.exit(1) # Start everything. - LOG.info(_("Agent initialised successfully, now running... ")) + LOG.info(_LI("Agent initialised successfully, now running... ")) agent.daemon_loop() sys.exit(0) diff --git a/neutron/plugins/mlnx/agent/utils.py b/neutron/plugins/mlnx/agent/utils.py index 5a6bc8977..5cf056eb0 100644 --- a/neutron/plugins/mlnx/agent/utils.py +++ b/neutron/plugins/mlnx/agent/utils.py @@ -16,6 +16,7 @@ from oslo.serialization import jsonutils from oslo.utils import importutils +from neutron.i18n import _LE from neutron.openstack.common import log as logging from neutron.plugins.mlnx.common import comm_utils from neutron.plugins.mlnx.common import exceptions @@ -28,9 +29,8 @@ LOG = logging.getLogger(__name__) class EswitchUtils(object): def __init__(self, daemon_endpoint, timeout): if not zmq: - msg = _("Failed to import eventlet.green.zmq. " - "Won't connect to eSwitchD - exiting...") - LOG.error(msg) + LOG.error(_LE("Failed to import eventlet.green.zmq. " + "Won't connect to eSwitchD - exiting...")) raise SystemExit(1) self.__conn = None self.daemon = daemon_endpoint @@ -72,22 +72,22 @@ class EswitchUtils(object): return elif msg['status'] == 'FAIL': msg_dict = dict(action=msg['action'], reason=msg['reason']) - error_msg = _("Action %(action)s failed: %(reason)s") % msg_dict + error_msg = _LE("Action %(action)s failed: %(reason)s") % msg_dict else: - error_msg = _("Unknown operation status %s") % msg['status'] + error_msg = _LE("Unknown operation status %s") % msg['status'] LOG.error(error_msg) raise exceptions.OperationFailed(err_msg=error_msg) def get_attached_vnics(self): - LOG.debug(_("get_attached_vnics")) + LOG.debug("get_attached_vnics") msg = jsonutils.dumps({'action': 'get_vnics', 'fabric': '*'}) vnics = self.send_msg(msg) return vnics def set_port_vlan_id(self, physical_network, segmentation_id, port_mac): - LOG.debug(_("Set Vlan %(segmentation_id)s on Port %(port_mac)s " - "on Fabric %(physical_network)s"), + LOG.debug("Set Vlan %(segmentation_id)s on Port %(port_mac)s " + "on Fabric %(physical_network)s", {'port_mac': port_mac, 'segmentation_id': segmentation_id, 'physical_network': physical_network}) @@ -99,7 +99,7 @@ class EswitchUtils(object): def define_fabric_mappings(self, interface_mapping): for fabric, phy_interface in interface_mapping.iteritems(): - LOG.debug(_("Define Fabric %(fabric)s on interface %(ifc)s"), + LOG.debug("Define Fabric %(fabric)s on interface %(ifc)s", {'fabric': fabric, 'ifc': phy_interface}) msg = jsonutils.dumps({'action': 'define_fabric_mapping', @@ -108,7 +108,7 @@ class EswitchUtils(object): self.send_msg(msg) def port_up(self, fabric, port_mac): - LOG.debug(_("Port Up for %(port_mac)s on fabric %(fabric)s"), + LOG.debug("Port Up for %(port_mac)s on fabric %(fabric)s", {'port_mac': port_mac, 'fabric': fabric}) msg = jsonutils.dumps({'action': 'port_up', 'fabric': fabric, @@ -117,7 +117,7 @@ class EswitchUtils(object): self.send_msg(msg) def port_down(self, fabric, port_mac): - LOG.debug(_("Port Down for %(port_mac)s on fabric %(fabric)s"), + LOG.debug("Port Down for %(port_mac)s on fabric %(fabric)s", {'port_mac': port_mac, 'fabric': fabric}) msg = jsonutils.dumps({'action': 'port_down', 'fabric': fabric, @@ -126,7 +126,7 @@ class EswitchUtils(object): self.send_msg(msg) def port_release(self, fabric, port_mac): - LOG.debug(_("Port Release for %(port_mac)s on fabric %(fabric)s"), + LOG.debug("Port Release for %(port_mac)s on fabric %(fabric)s", {'port_mac': port_mac, 'fabric': fabric}) msg = jsonutils.dumps({'action': 'port_release', 'fabric': fabric, diff --git a/neutron/plugins/mlnx/agent_notify_api.py b/neutron/plugins/mlnx/agent_notify_api.py index 28cb9b746..79cfe470c 100644 --- a/neutron/plugins/mlnx/agent_notify_api.py +++ b/neutron/plugins/mlnx/agent_notify_api.py @@ -44,14 +44,14 @@ class AgentNotifierApi(sg_rpc.SecurityGroupAgentRpcApiMixin): self.client = n_rpc.get_client(target) def network_delete(self, context, network_id): - LOG.debug(_("Sending delete network message")) + LOG.debug("Sending delete network message") cctxt = self.client.prepare(topic=self.topic_network_delete, fanout=True) cctxt.cast(context, 'network_delete', network_id=network_id) def port_update(self, context, port, physical_network, network_type, vlan_id): - LOG.debug(_("Sending update port message")) + LOG.debug("Sending update port message") kwargs = {'port': port, 'network_type': network_type, 'physical_network': physical_network, diff --git a/neutron/plugins/mlnx/common/comm_utils.py b/neutron/plugins/mlnx/common/comm_utils.py index f426908f2..d0cbb2b12 100644 --- a/neutron/plugins/mlnx/common/comm_utils.py +++ b/neutron/plugins/mlnx/common/comm_utils.py @@ -53,8 +53,8 @@ class RetryDecorator(object): try: return original_func(*args, **kwargs) except self.exc: - LOG.debug(_("Request timeout - call again after " - "%s seconds"), sleep_interval) + LOG.debug("Request timeout - call again after " + "%s seconds", sleep_interval) time.sleep(sleep_interval) num_of_iter -= 1 sleep_interval *= self.backoff_rate diff --git a/neutron/plugins/mlnx/db/mlnx_db_v2.py b/neutron/plugins/mlnx/db/mlnx_db_v2.py index bf400ff7d..4c767df97 100644 --- a/neutron/plugins/mlnx/db/mlnx_db_v2.py +++ b/neutron/plugins/mlnx/db/mlnx_db_v2.py @@ -20,6 +20,7 @@ from neutron.common import exceptions as n_exc import neutron.db.api as db from neutron.db import models_v2 from neutron.db import securitygroups_db as sg_db +from neutron.i18n import _LW from neutron import manager from neutron.openstack.common import log as logging from neutron.plugins.mlnx.common import config # noqa @@ -39,10 +40,10 @@ def _remove_non_allocatable_vlans(session, allocations, # it's not allocatable, so check if its allocated if not entry.allocated: # it's not, so remove it from table - LOG.debug(_( + LOG.debug( "Removing vlan %(seg_id)s on " "physical network " - "%(net)s from pool"), + "%(net)s from pool", {'seg_id': entry.segmentation_id, 'net': physical_network}) session.delete(entry) @@ -60,8 +61,8 @@ def _remove_unconfigured_vlans(session, allocations): for entries in allocations.itervalues(): for entry in entries: if not entry.allocated: - LOG.debug(_("Removing vlan %(seg_id)s on physical " - "network %(net)s from pool"), + LOG.debug("Removing vlan %(seg_id)s on physical " + "network %(net)s from pool", {'seg_id': entry.segmentation_id, 'net': entry.physical_network}) session.delete(entry) @@ -116,8 +117,8 @@ def reserve_network(session): first()) if not entry: raise n_exc.NoNetworkAvailable() - LOG.debug(_("Reserving vlan %(seg_id)s on physical network " - "%(net)s from pool"), + LOG.debug("Reserving vlan %(seg_id)s on physical network " + "%(net)s from pool", {'seg_id': entry.segmentation_id, 'net': entry.physical_network}) entry.allocated = True @@ -135,13 +136,13 @@ def reserve_specific_network(session, physical_network, segmentation_id): if entry.allocated: raise n_exc.VlanIdInUse(vlan_id=segmentation_id, physical_network=physical_network) - LOG.debug(_("Reserving specific vlan %(seg_id)s " - "on physical network %(phy_net)s from pool"), + LOG.debug("Reserving specific vlan %(seg_id)s " + "on physical network %(phy_net)s from pool", log_args) entry.allocated = True except exc.NoResultFound: - LOG.debug(_("Reserving specific vlan %(seg_id)s on " - "physical network %(phy_net)s outside pool"), + LOG.debug("Reserving specific vlan %(seg_id)s on " + "physical network %(phy_net)s outside pool", log_args) entry = mlnx_models_v2.SegmentationIdAllocation(physical_network, segmentation_id) @@ -167,19 +168,19 @@ def release_network(session, physical_network, inside = True break if inside: - LOG.debug(_("Releasing vlan %(seg_id)s " - "on physical network " - "%(phy_net)s to pool"), + LOG.debug("Releasing vlan %(seg_id)s " + "on physical network " + "%(phy_net)s to pool", log_args) else: - LOG.debug(_("Releasing vlan %(seg_id)s " - "on physical network " - "%(phy_net)s outside pool"), + LOG.debug("Releasing vlan %(seg_id)s " + "on physical network " + "%(phy_net)s outside pool", log_args) session.delete(state) except exc.NoResultFound: - LOG.warning(_("vlan_id %(seg_id)s on physical network " - "%(phy_net)s not found"), + LOG.warning(_LW("vlan_id %(seg_id)s on physical network " + "%(phy_net)s not found"), log_args) @@ -209,7 +210,7 @@ def get_port_profile_binding(session, port_id): def get_port_from_device(device): """Get port from database.""" - LOG.debug(_("get_port_from_device() called")) + LOG.debug("get_port_from_device() called") session = db.get_session() sg_binding_port = sg_db.SecurityGroupPortBinding.port_id @@ -236,7 +237,7 @@ def get_port_from_device(device): def get_port_from_device_mac(device_mac): """Get port from database.""" - LOG.debug(_("Get_port_from_device_mac() called")) + LOG.debug("Get_port_from_device_mac() called") session = db.get_session() qry = session.query(models_v2.Port).filter_by(mac_address=device_mac) return qry.first() @@ -244,7 +245,7 @@ def get_port_from_device_mac(device_mac): def set_port_status(port_id, status): """Set the port status.""" - LOG.debug(_("Set_port_status as %s called"), status) + LOG.debug("Set_port_status as %s called", status) session = db.get_session() try: port = session.query(models_v2.Port).filter_by(id=port_id).one() diff --git a/neutron/plugins/mlnx/mlnx_plugin.py b/neutron/plugins/mlnx/mlnx_plugin.py index 4e0d71865..32513bb05 100644 --- a/neutron/plugins/mlnx/mlnx_plugin.py +++ b/neutron/plugins/mlnx/mlnx_plugin.py @@ -43,6 +43,7 @@ from neutron.db import quota_db # noqa from neutron.db import securitygroups_rpc_base as sg_db_rpc from neutron.extensions import portbindings from neutron.extensions import providernet as provider +from neutron.i18n import _LE, _LI from neutron.openstack.common import log as logging from neutron.plugins.common import constants as svc_constants from neutron.plugins.common import utils as plugin_utils @@ -116,7 +117,7 @@ class MellanoxEswitchPlugin(db_base_plugin_v2.NeutronDbPluginV2, self.router_scheduler = importutils.import_object( cfg.CONF.router_scheduler_driver ) - LOG.debug(_("Mellanox Embedded Switch Plugin initialisation complete")) + LOG.debug("Mellanox Embedded Switch Plugin initialisation complete") def _setup_rpc(self): # RPC support @@ -157,23 +158,24 @@ class MellanoxEswitchPlugin(db_base_plugin_v2.NeutronDbPluginV2, self.physical_net_type = cfg.CONF.MLNX.physical_network_type if self.physical_net_type not in (constants.TYPE_ETH, constants.TYPE_IB): - LOG.error(_("Invalid physical network type %(type)s." - "Server terminated!"), {'type': self.physical_net_type}) + LOG.error(_LE("Invalid physical network type %(type)s. " + "Server terminated!"), + {'type': self.physical_net_type}) raise SystemExit(1) try: self.phys_network_type_maps = utils.parse_mappings( cfg.CONF.MLNX.physical_network_type_mappings) except ValueError as e: - LOG.error(_("Parsing physical_network_type failed: %s." - " Server terminated!"), e) + LOG.error(_LE("Parsing physical_network_type failed: %s. " + "Server terminated!"), e) raise SystemExit(1) for network, type in self.phys_network_type_maps.iteritems(): if type not in (constants.TYPE_ETH, constants.TYPE_IB): - LOG.error(_("Invalid physical network type %(type)s " - " for network %(net)s. Server terminated!"), + LOG.error(_LE("Invalid physical network type %(type)s " + "for network %(net)s. Server terminated!"), {'net': network, 'type': type}) raise SystemExit(1) - LOG.info(_("Physical Network type mappings: %s"), + LOG.info(_LI("Physical Network type mappings: %s"), self.phys_network_type_maps) def _parse_network_vlan_ranges(self): @@ -181,9 +183,9 @@ class MellanoxEswitchPlugin(db_base_plugin_v2.NeutronDbPluginV2, self.network_vlan_ranges = plugin_utils.parse_network_vlan_ranges( cfg.CONF.MLNX.network_vlan_ranges) except Exception as ex: - LOG.error(_("%s. Server terminated!"), ex) + LOG.error(_LE("%s. Server terminated!"), ex) sys.exit(1) - LOG.info(_("Network VLAN ranges: %s"), self.network_vlan_ranges) + LOG.info(_LI("Network VLAN ranges: %s"), self.network_vlan_ranges) def _extend_network_dict_provider(self, context, network): binding = db.get_network_binding(context.session, network['id']) @@ -203,8 +205,8 @@ class MellanoxEswitchPlugin(db_base_plugin_v2.NeutronDbPluginV2, if self.tenant_network_type not in [svc_constants.TYPE_VLAN, svc_constants.TYPE_LOCAL, svc_constants.TYPE_NONE]: - LOG.error(_("Invalid tenant_network_type: %s. " - "Service terminated!"), + LOG.error(_LE("Invalid tenant_network_type: %s. " + "Service terminated!"), self.tenant_network_type) sys.exit(1) @@ -238,7 +240,7 @@ class MellanoxEswitchPlugin(db_base_plugin_v2.NeutronDbPluginV2, physical_network = None else: - msg = _("provider:network_type %s not supported") % network_type + msg = _LE("provider:network_type %s not supported") % network_type raise n_exc.InvalidInput(error_message=msg) physical_network = self._process_net_type(network_type, physical_network, @@ -247,28 +249,28 @@ class MellanoxEswitchPlugin(db_base_plugin_v2.NeutronDbPluginV2, def _process_flat_net(self, segmentation_id_set): if segmentation_id_set: - msg = _("provider:segmentation_id specified for flat network") + msg = _LE("provider:segmentation_id specified for flat network") raise n_exc.InvalidInput(error_message=msg) def _process_vlan_net(self, segmentation_id, segmentation_id_set): if not segmentation_id_set: - msg = _("provider:segmentation_id required") + msg = _LE("provider:segmentation_id required") raise n_exc.InvalidInput(error_message=msg) if not utils.is_valid_vlan_tag(segmentation_id): - msg = (_("provider:segmentation_id out of range " - "(%(min_id)s through %(max_id)s)") % + msg = (_LE("provider:segmentation_id out of range " + "(%(min_id)s through %(max_id)s)") % {'min_id': q_const.MIN_VLAN_TAG, 'max_id': q_const.MAX_VLAN_TAG}) raise n_exc.InvalidInput(error_message=msg) def _process_local_net(self, physical_network_set, segmentation_id_set): if physical_network_set: - msg = _("provider:physical_network specified for local " - "network") + msg = _LE("provider:physical_network specified for local " + "network") raise n_exc.InvalidInput(error_message=msg) if segmentation_id_set: - msg = _("provider:segmentation_id specified for local " - "network") + msg = _LE("provider:segmentation_id specified for local " + "network") raise n_exc.InvalidInput(error_message=msg) def _process_net_type(self, network_type, @@ -278,13 +280,13 @@ class MellanoxEswitchPlugin(db_base_plugin_v2.NeutronDbPluginV2, svc_constants.TYPE_FLAT]: if physical_network_set: if physical_network not in self.network_vlan_ranges: - msg = _("Unknown provider:physical_network " - "%s") % physical_network + msg = _LE("Unknown provider:physical_network " + "%s") % physical_network raise n_exc.InvalidInput(error_message=msg) elif 'default' in self.network_vlan_ranges: physical_network = 'default' else: - msg = _("provider:physical_network required") + msg = _LE("provider:physical_network required") raise n_exc.InvalidInput(error_message=msg) return physical_network @@ -319,13 +321,13 @@ class MellanoxEswitchPlugin(db_base_plugin_v2.NeutronDbPluginV2, self.base_binding_dict[portbindings.VIF_TYPE] = vnic_type return vnic_type else: - msg = (_("Unsupported vnic type %(vnic_type)s " - "for physical network type %(net_type)s") % + msg = (_LE("Unsupported vnic type %(vnic_type)s " + "for physical network type %(net_type)s") % {'vnic_type': vnic_type, 'net_type': phy_net_type}) else: - msg = _("Invalid vnic_type on port_create") + msg = _LE("Invalid vnic_type on port_create") else: - msg = _("vnic_type is not defined in port profile") + msg = _LE("vnic_type is not defined in port profile") raise n_exc.InvalidInput(error_message=msg) def create_network(self, context, network): @@ -365,11 +367,11 @@ class MellanoxEswitchPlugin(db_base_plugin_v2.NeutronDbPluginV2, self._process_l3_create(context, net, network['network']) self._extend_network_dict_provider(context, net) # note - exception will rollback entire transaction - LOG.debug(_("Created network: %s"), net['id']) + LOG.debug("Created network: %s", net['id']) return net def update_network(self, context, net_id, network): - LOG.debug(_("Update network")) + LOG.debug("Update network") provider._raise_if_updates_provider_attributes(network['network']) session = context.session @@ -382,7 +384,7 @@ class MellanoxEswitchPlugin(db_base_plugin_v2.NeutronDbPluginV2, return net def delete_network(self, context, net_id): - LOG.debug(_("Delete network")) + LOG.debug("Delete network") session = context.session with session.begin(subtransactions=True): binding = db.get_network_binding(session, net_id) @@ -430,7 +432,7 @@ class MellanoxEswitchPlugin(db_base_plugin_v2.NeutronDbPluginV2, return port def create_port(self, context, port): - LOG.debug(_("create_port with %s"), port) + LOG.debug("create_port with %s", port) session = context.session port_data = port['port'] with session.begin(subtransactions=True): diff --git a/neutron/plugins/mlnx/rpc_callbacks.py b/neutron/plugins/mlnx/rpc_callbacks.py index 2acfb4350..09641cf42 100644 --- a/neutron/plugins/mlnx/rpc_callbacks.py +++ b/neutron/plugins/mlnx/rpc_callbacks.py @@ -34,7 +34,7 @@ class MlnxRpcCallbacks(n_rpc.RpcCallback): """Agent requests device details.""" agent_id = kwargs.get('agent_id') device = kwargs.get('device') - LOG.debug(_("Device %(device)s details requested from %(agent_id)s"), + LOG.debug("Device %(device)s details requested from %(agent_id)s", {'device': device, 'agent_id': agent_id}) plugin = manager.NeutronManager.get_plugin() port = plugin.get_port_from_device(device) @@ -57,7 +57,7 @@ class MlnxRpcCallbacks(n_rpc.RpcCallback): db.set_port_status(port['id'], new_status) else: entry = {'device': device} - LOG.debug(_("%s can not be found in database"), device) + LOG.debug("%s can not be found in database", device) return entry def get_devices_details_list(self, rpc_context, **kwargs): @@ -74,7 +74,7 @@ class MlnxRpcCallbacks(n_rpc.RpcCallback): """Device no longer exists on agent.""" agent_id = kwargs.get('agent_id') device = kwargs.get('device') - LOG.debug(_("Device %(device)s no longer exists on %(agent_id)s"), + LOG.debug("Device %(device)s no longer exists on %(agent_id)s", {'device': device, 'agent_id': agent_id}) plugin = manager.NeutronManager.get_plugin() port = plugin.get_port_from_device(device) @@ -87,14 +87,14 @@ class MlnxRpcCallbacks(n_rpc.RpcCallback): else: entry = {'device': device, 'exists': False} - LOG.debug(_("%s can not be found in database"), device) + LOG.debug("%s can not be found in database", device) return entry def update_device_up(self, rpc_context, **kwargs): """Device is up on agent.""" agent_id = kwargs.get('agent_id') device = kwargs.get('device') - LOG.debug(_("Device %(device)s up %(agent_id)s"), + LOG.debug("Device %(device)s up %(agent_id)s", {'device': device, 'agent_id': agent_id}) plugin = manager.NeutronManager.get_plugin() port = plugin.get_port_from_device(device) @@ -103,4 +103,4 @@ class MlnxRpcCallbacks(n_rpc.RpcCallback): # Set port status to ACTIVE db.set_port_status(port['id'], q_const.PORT_STATUS_ACTIVE) else: - LOG.debug(_("%s can not be found in database"), device) + LOG.debug("%s can not be found in database", device)