From d9ba4c3441e1406b81c3e37a8f7fd60e9766d277 Mon Sep 17 00:00:00 2001 From: Romil Gupta Date: Thu, 13 Nov 2014 10:59:42 -0800 Subject: [PATCH] Update i18n translation for linuxbridge log msg's This patch set covers the linuxbridge directory under neutron/plugins. Partial-Bug: #1320867 Change-Id: I603f9ae8f95bf1b1815edaca49e728fa378cf6ba --- neutron/hacking/checks.py | 3 +- .../agent/linuxbridge_neutron_agent.py | 173 +++++++++--------- 2 files changed, 88 insertions(+), 88 deletions(-) diff --git a/neutron/hacking/checks.py b/neutron/hacking/checks.py index 63d85253d72..7a2d27b8384 100644 --- a/neutron/hacking/checks.py +++ b/neutron/hacking/checks.py @@ -59,7 +59,8 @@ def _directory_to_check_translation(filename): "neutron/server", "neutron/services", "neutron/plugins/ml2", - "neutron/plugins/openvswitch"] + "neutron/plugins/openvswitch", + "neutron/plugins/linuxbridge"] return any([dir in filename for dir in dirs]) diff --git a/neutron/plugins/linuxbridge/agent/linuxbridge_neutron_agent.py b/neutron/plugins/linuxbridge/agent/linuxbridge_neutron_agent.py index d9f7f686f5e..3617d7ecc35 100755 --- a/neutron/plugins/linuxbridge/agent/linuxbridge_neutron_agent.py +++ b/neutron/plugins/linuxbridge/agent/linuxbridge_neutron_agent.py @@ -41,6 +41,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.openstack.common.gettextutils 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 @@ -79,8 +80,8 @@ class LinuxBridgeManager: if self.local_int: self.check_vxlan_support() else: - LOG.warning(_('VXLAN is enabled, a valid local_ip ' - 'must be provided')) + LOG.warning(_LW('VXLAN is enabled, a valid local_ip ' + 'must be provided')) # Store network mapping to segments self.network_map = {} @@ -93,22 +94,22 @@ class LinuxBridgeManager: def get_bridge_name(self, network_id): if not network_id: - LOG.warning(_("Invalid Network ID, will lead to incorrect bridge" - "name")) + LOG.warning(_LW("Invalid Network ID, will lead to incorrect bridge" + "name")) bridge_name = BRIDGE_NAME_PREFIX + network_id[0:11] return bridge_name def get_subinterface_name(self, physical_interface, vlan_id): if not vlan_id: - LOG.warning(_("Invalid VLAN ID, will lead to incorrect " - "subinterface name")) + LOG.warning(_LW("Invalid VLAN ID, will lead to incorrect " + "subinterface name")) subinterface_name = '%s.%s' % (physical_interface, vlan_id) return subinterface_name def get_tap_device_name(self, interface_id): if not interface_id: - LOG.warning(_("Invalid Interface ID, will lead to incorrect " - "tap device name")) + LOG.warning(_LW("Invalid Interface ID, will lead to incorrect " + "tap device name")) tap_device_name = constants.TAP_DEVICE_PREFIX + interface_id[0:11] return tap_device_name @@ -116,8 +117,8 @@ class LinuxBridgeManager: if 0 <= int(segmentation_id) <= constants.MAX_VXLAN_VNI: return VXLAN_INTERFACE_PREFIX + str(segmentation_id) else: - LOG.warning(_("Invalid Segmentation ID: %s, will lead to " - "incorrect vxlan device name"), segmentation_id) + LOG.warning(_LW("Invalid Segmentation ID: %s, will lead to " + "incorrect vxlan device name"), segmentation_id) def get_all_neutron_bridges(self): neutron_bridge_list = [] @@ -179,8 +180,8 @@ class LinuxBridgeManager: """Create a vxlan and bridge unless they already exist.""" interface = self.ensure_vxlan(segmentation_id) if not interface: - LOG.error(_("Failed creating vxlan interface for " - "%(segmentation_id)s"), + LOG.error(_LE("Failed creating vxlan interface for " + "%(segmentation_id)s"), {segmentation_id: segmentation_id}) return bridge_name = self.get_bridge_name(network_id) @@ -211,9 +212,9 @@ class LinuxBridgeManager: """Create a vlan unless it already exists.""" interface = self.get_subinterface_name(physical_interface, vlan_id) if not ip_lib.device_exists(interface): - LOG.debug(_("Creating subinterface %(interface)s for " - "VLAN %(vlan_id)s on interface " - "%(physical_interface)s"), + LOG.debug("Creating subinterface %(interface)s for " + "VLAN %(vlan_id)s on interface " + "%(physical_interface)s", {'interface': interface, 'vlan_id': vlan_id, 'physical_interface': physical_interface}) if utils.execute(['ip', 'link', 'add', 'link', @@ -224,15 +225,15 @@ class LinuxBridgeManager: if utils.execute(['ip', 'link', 'set', interface, 'up'], root_helper=self.root_helper): return - LOG.debug(_("Done creating subinterface %s"), interface) + LOG.debug("Done creating subinterface %s", interface) return interface def ensure_vxlan(self, segmentation_id): """Create a vxlan unless it already exists.""" interface = self.get_vxlan_device_name(segmentation_id) if not ip_lib.device_exists(interface): - LOG.debug(_("Creating vxlan interface %(interface)s for " - "VNI %(segmentation_id)s"), + LOG.debug("Creating vxlan interface %(interface)s for " + "VNI %(segmentation_id)s", {'interface': interface, 'segmentation_id': segmentation_id}) args = {'dev': self.local_int} @@ -246,7 +247,7 @@ class LinuxBridgeManager: args['proxy'] = True int_vxlan = self.ip.add_vxlan(interface, segmentation_id, **args) int_vxlan.link.set_up() - LOG.debug(_("Done creating vxlan interface %s"), interface) + LOG.debug("Done creating vxlan interface %s", interface) return interface def update_interface_ip_details(self, destination, source, ips, @@ -300,8 +301,8 @@ class LinuxBridgeManager: # 2) The Nova VIF driver was running concurrently and had just created # the bridge, but had not yet put it UP if not self._bridge_exists_and_ensure_up(bridge_name): - LOG.debug(_("Starting bridge %(bridge_name)s for subinterface " - "%(interface)s"), + LOG.debug("Starting bridge %(bridge_name)s for subinterface " + "%(interface)s", {'bridge_name': bridge_name, 'interface': interface}) if utils.execute(['brctl', 'addbr', bridge_name], root_helper=self.root_helper): @@ -315,8 +316,8 @@ class LinuxBridgeManager: if utils.execute(['ip', 'link', 'set', bridge_name, 'up'], root_helper=self.root_helper): return - LOG.debug(_("Done starting bridge %(bridge_name)s for " - "subinterface %(interface)s"), + LOG.debug("Done starting bridge %(bridge_name)s for " + "subinterface %(interface)s", {'bridge_name': bridge_name, 'interface': interface}) if not interface: @@ -337,8 +338,8 @@ class LinuxBridgeManager: utils.execute(['brctl', 'addif', bridge_name, interface], root_helper=self.root_helper) except Exception as e: - LOG.error(_("Unable to add %(interface)s to %(bridge_name)s! " - "Exception: %(e)s"), + LOG.error(_LE("Unable to add %(interface)s to %(bridge_name)s" + "! Exception: %(e)s"), {'interface': interface, 'bridge_name': bridge_name, 'e': e}) return @@ -350,14 +351,14 @@ class LinuxBridgeManager: segmentation_id): if network_type == p_const.TYPE_VXLAN: if self.vxlan_mode == lconst.VXLAN_NONE: - LOG.error(_("Unable to add vxlan interface for network %s"), + LOG.error(_LE("Unable to add vxlan interface for network %s"), network_id) return return self.ensure_vxlan_bridge(network_id, segmentation_id) physical_interface = self.interface_mappings.get(physical_network) if not physical_interface: - LOG.error(_("No mapping for physical network %s"), + LOG.error(_LE("No mapping for physical network %s"), physical_network) return if network_type == p_const.TYPE_FLAT: @@ -366,8 +367,8 @@ class LinuxBridgeManager: return self.ensure_vlan_bridge(network_id, physical_interface, segmentation_id) else: - LOG.error(_("Unknown network_type %(network_type)s for network " - "%(network_id)s."), {network_type: network_type, + LOG.error(_LE("Unknown network_type %(network_type)s for network " + "%(network_id)s."), {network_type: network_type, network_id: network_id}) def add_tap_interface(self, network_id, network_type, physical_network, @@ -378,8 +379,8 @@ class LinuxBridgeManager: add the corresponding tap device to the relevant bridge. """ if not ip_lib.device_exists(tap_device_name): - LOG.debug(_("Tap device: %s does not exist on " - "this host, skipped"), tap_device_name) + LOG.debug("Tap device: %s does not exist on " + "this host, skipped", tap_device_name) return False bridge_name = self.get_bridge_name(network_id) @@ -396,18 +397,16 @@ class LinuxBridgeManager: if not tap_device_in_bridge: data = {'tap_device_name': tap_device_name, 'bridge_name': bridge_name} - msg = _("Adding device %(tap_device_name)s to bridge " - "%(bridge_name)s") % data - LOG.debug(msg) + LOG.debug("Adding device %(tap_device_name)s to bridge " + "%(bridge_name)s", data) if utils.execute(['brctl', 'addif', bridge_name, tap_device_name], root_helper=self.root_helper): return False else: data = {'tap_device_name': tap_device_name, 'bridge_name': bridge_name} - msg = _("%(tap_device_name)s already exists on bridge " - "%(bridge_name)s") % data - LOG.debug(msg) + LOG.debug("%(tap_device_name)s already exists on bridge " + "%(bridge_name)s", data) return True def add_interface(self, network_id, network_type, physical_network, @@ -443,17 +442,17 @@ class LinuxBridgeManager: elif physical_interface != interface: self.delete_vlan(interface) - LOG.debug(_("Deleting bridge %s"), bridge_name) + LOG.debug("Deleting bridge %s", bridge_name) if utils.execute(['ip', 'link', 'set', bridge_name, 'down'], root_helper=self.root_helper): return if utils.execute(['brctl', 'delbr', bridge_name], root_helper=self.root_helper): return - LOG.debug(_("Done deleting bridge %s"), bridge_name) + LOG.debug("Done deleting bridge %s", bridge_name) else: - LOG.error(_("Cannot delete bridge %s, does not exist"), + LOG.error(_LE("Cannot delete bridge %s, does not exist"), bridge_name) def remove_empty_bridges(self): @@ -467,44 +466,44 @@ class LinuxBridgeManager: if ip_lib.device_exists(bridge_name): if not self.is_device_on_bridge(interface_name): return True - LOG.debug(_("Removing device %(interface_name)s from bridge " - "%(bridge_name)s"), + LOG.debug("Removing device %(interface_name)s from bridge " + "%(bridge_name)s", {'interface_name': interface_name, 'bridge_name': bridge_name}) if utils.execute(['brctl', 'delif', bridge_name, interface_name], root_helper=self.root_helper): return False - LOG.debug(_("Done removing device %(interface_name)s from bridge " - "%(bridge_name)s"), + LOG.debug("Done removing device %(interface_name)s from bridge " + "%(bridge_name)s", {'interface_name': interface_name, 'bridge_name': bridge_name}) return True else: - LOG.debug(_("Cannot remove device %(interface_name)s bridge " - "%(bridge_name)s does not exist"), + LOG.debug("Cannot remove device %(interface_name)s bridge " + "%(bridge_name)s does not exist", {'interface_name': interface_name, 'bridge_name': bridge_name}) return False def delete_vlan(self, interface): if ip_lib.device_exists(interface): - LOG.debug(_("Deleting subinterface %s for vlan"), interface) + LOG.debug("Deleting subinterface %s for vlan", interface) if utils.execute(['ip', 'link', 'set', interface, 'down'], root_helper=self.root_helper): return if utils.execute(['ip', 'link', 'delete', interface], root_helper=self.root_helper): return - LOG.debug(_("Done deleting subinterface %s"), interface) + LOG.debug("Done deleting subinterface %s", interface) def delete_vxlan(self, interface): if ip_lib.device_exists(interface): - LOG.debug(_("Deleting vxlan interface %s for vlan"), + LOG.debug("Deleting vxlan interface %s for vlan", interface) int_vxlan = self.ip.device(interface) int_vxlan.link.set_down() int_vxlan.link.delete() - LOG.debug(_("Done deleting vxlan interface %s"), interface) + LOG.debug("Done deleting vxlan interface %s", interface) def get_tap_devices(self): devices = set() @@ -518,8 +517,8 @@ class LinuxBridgeManager: return False if not ip_lib.iproute_arg_supported( ['bridge', 'fdb'], 'append', self.root_helper): - LOG.warning(_('Option "%(option)s" must be supported by command ' - '"%(command)s" to enable %(mode)s mode') % + LOG.warning(_LW('Option "%(option)s" must be supported by command ' + '"%(command)s" to enable %(mode)s mode') % {'option': 'append', 'command': 'bridge fdb', 'mode': 'VXLAN UCAST'}) @@ -529,7 +528,7 @@ class LinuxBridgeManager: self.get_vxlan_device_name(segmentation_id)): break else: - LOG.error(_('No valid Segmentation ID to perform UCAST test.')) + LOG.error(_LE('No valid Segmentation ID to perform UCAST test.')) return False test_iface = self.ensure_vxlan(segmentation_id) @@ -546,14 +545,14 @@ class LinuxBridgeManager: def vxlan_mcast_supported(self): if not cfg.CONF.VXLAN.vxlan_group: - LOG.warning(_('VXLAN muticast group must be provided in ' - 'vxlan_group option to enable VXLAN MCAST mode')) + LOG.warning(_LW('VXLAN muticast group must be provided in ' + 'vxlan_group option to enable VXLAN MCAST mode')) return False if not ip_lib.iproute_arg_supported( ['ip', 'link', 'add', 'type', 'vxlan'], 'proxy', self.root_helper): - LOG.warning(_('Option "%(option)s" must be supported by command ' - '"%(command)s" to enable %(mode)s mode') % + LOG.warning(_LW('Option "%(option)s" must be supported by command ' + '"%(command)s" to enable %(mode)s mode') % {'option': 'proxy', 'command': 'ip link add type vxlan', 'mode': 'VXLAN MCAST'}) @@ -571,8 +570,8 @@ class LinuxBridgeManager: def check_vxlan_support(self): self.vxlan_mode = lconst.VXLAN_NONE if not self.vxlan_module_supported(): - LOG.error(_('Linux kernel vxlan module and iproute2 3.8 or above ' - 'are required to enable VXLAN.')) + LOG.error(_LE('Linux kernel vxlan module and iproute2 3.8 or ' + 'above are required to enable VXLAN.')) raise exceptions.VxlanNetworkUnsupported() if self.vxlan_ucast_supported(): @@ -581,7 +580,7 @@ class LinuxBridgeManager: self.vxlan_mode = lconst.VXLAN_MCAST else: raise exceptions.VxlanNetworkUnsupported() - LOG.debug(_('Using %s VXLAN mode'), self.vxlan_mode) + LOG.debug('Using %s VXLAN mode', self.vxlan_mode) def fdb_ip_entry_exists(self, mac, ip, interface): entries = utils.execute(['ip', 'neigh', 'show', 'to', ip, @@ -658,10 +657,10 @@ class LinuxBridgeRpcCallbacks(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') bridge_name = self.agent.br_mgr.get_bridge_name(network_id) - LOG.debug(_("Delete %s"), bridge_name) + LOG.debug("Delete %s", bridge_name) self.agent.br_mgr.delete_vlan_bridge(bridge_name) def port_update(self, context, **kwargs): @@ -672,10 +671,10 @@ class LinuxBridgeRpcCallbacks(n_rpc.RpcCallback, # notifications there is no guarantee the notifications are # processed in the same order as the relevant API requests. self.agent.updated_devices.add(tap_name) - LOG.debug(_("port_update RPC received for port: %s"), port_id) + LOG.debug("port_update RPC received for port: %s", port_id) def fdb_add(self, context, fdb_entries): - LOG.debug(_("fdb_add received")) + LOG.debug("fdb_add received") for network_id, values in fdb_entries.items(): segment = self.agent.br_mgr.network_map.get(network_id) if not segment: @@ -697,7 +696,7 @@ class LinuxBridgeRpcCallbacks(n_rpc.RpcCallback, interface) def fdb_remove(self, context, fdb_entries): - LOG.debug(_("fdb_remove received")) + LOG.debug("fdb_remove received") for network_id, values in fdb_entries.items(): segment = self.agent.br_mgr.network_map.get(network_id) if not segment: @@ -719,7 +718,7 @@ class LinuxBridgeRpcCallbacks(n_rpc.RpcCallback, interface) def _fdb_chg_ip(self, context, fdb_entries): - LOG.debug(_("update chg_ip received")) + LOG.debug("update chg_ip received") for network_id, agent_ports in fdb_entries.items(): segment = self.agent.br_mgr.network_map.get(network_id) if not segment: @@ -744,7 +743,7 @@ class LinuxBridgeRpcCallbacks(n_rpc.RpcCallback, self.agent.br_mgr.remove_fdb_ip_entry(mac, ip, interface) def fdb_update(self, context, fdb_entries): - LOG.debug(_("fdb_update received")) + LOG.debug("fdb_update received") for action, values in fdb_entries.items(): method = '_fdb_' + action if not hasattr(self, method): @@ -791,7 +790,7 @@ class LinuxBridgeNeutronAgentRPC(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, physical_interfaces): if physical_interfaces: @@ -801,11 +800,11 @@ class LinuxBridgeNeutronAgentRPC(sg_rpc.SecurityGroupAgentRpcMixin): if devices: mac = utils.get_interface_mac(devices[0].name) else: - LOG.error(_("Unable to obtain MAC address for unique ID. " - "Agent terminated!")) + LOG.error(_LE("Unable to obtain MAC address for unique ID. " + "Agent terminated!")) exit(1) self.agent_id = '%s%s' % ('lb', (mac.replace(":", ""))) - 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 = LinuxBridgePluginApi(topics.PLUGIN) @@ -876,7 +875,7 @@ class LinuxBridgeNeutronAgentRPC(sg_rpc.SecurityGroupAgentRpcMixin): LOG.debug("Port %s added", device) if 'port_id' in device_details: - LOG.info(_("Port %(device)s updated. Details: %(details)s"), + LOG.info(_LI("Port %(device)s updated. Details: %(details)s"), {'device': device, 'details': device_details}) if device_details['admin_state_up']: # create the networking for the port @@ -909,14 +908,14 @@ class LinuxBridgeNeutronAgentRPC(sg_rpc.SecurityGroupAgentRpcMixin): self.remove_port_binding(device_details['network_id'], device_details['port_id']) else: - LOG.info(_("Device %s not defined on plugin"), device) + LOG.info(_LI("Device %s not defined on plugin"), device) return False def treat_devices_removed(self, devices): resync = False self.remove_devices_filter(devices) for device in devices: - LOG.info(_("Attachment %s removed"), device) + LOG.info(_LI("Attachment %s removed"), device) details = None try: details = self.plugin_rpc.update_device_down(self.context, @@ -924,13 +923,13 @@ class LinuxBridgeNeutronAgentRPC(sg_rpc.SecurityGroupAgentRpcMixin): self.agent_id, cfg.CONF.host) except Exception as e: - LOG.debug(_("port_removed failed for %(device)s: %(e)s"), + LOG.debug("port_removed failed for %(device)s: %(e)s", {'device': device, 'e': e}) resync = True if details and 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.br_mgr.remove_empty_bridges() return resync @@ -981,7 +980,7 @@ class LinuxBridgeNeutronAgentRPC(sg_rpc.SecurityGroupAgentRpcMixin): or device_info.get('removed')) def daemon_loop(self): - LOG.info(_("LinuxBridge Agent RPC Daemon Started!")) + LOG.info(_LI("LinuxBridge Agent RPC Daemon Started!")) device_info = None sync = True @@ -991,15 +990,15 @@ class LinuxBridgeNeutronAgentRPC(sg_rpc.SecurityGroupAgentRpcMixin): device_info = self.scan_devices(previous=device_info, sync=sync) if sync: - LOG.info(_("Agent out of sync with plugin!")) + LOG.info(_LI("Agent out of sync with plugin!")) sync = False if self._device_info_has_changes(device_info): - LOG.debug(_("Agent loop found changes! %s"), device_info) + LOG.debug("Agent loop found changes! %s", device_info) try: sync = self.process_network_devices(device_info) except Exception: - LOG.exception(_("Error in agent loop. Devices info: %s"), + LOG.exception(_LE("Error in agent loop. Devices info: %s"), device_info) sync = True @@ -1008,8 +1007,8 @@ class LinuxBridgeNeutronAgentRPC(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}) @@ -1022,17 +1021,17 @@ def main(): interface_mappings = q_utils.parse_mappings( cfg.CONF.LINUX_BRIDGE.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) polling_interval = cfg.CONF.AGENT.polling_interval root_helper = cfg.CONF.AGENT.root_helper agent = LinuxBridgeNeutronAgentRPC(interface_mappings, polling_interval, root_helper) - LOG.info(_("Agent initialized successfully, now running... ")) + LOG.info(_LI("Agent initialized successfully, now running... ")) agent.daemon_loop() sys.exit(0)