Update i18n translation for linuxbridge log msg's

This patch set covers the linuxbridge directory under neutron/plugins.

Partial-Bug: #1320867
Change-Id: I603f9ae8f95bf1b1815edaca49e728fa378cf6ba
This commit is contained in:
Romil Gupta 2014-11-13 10:59:42 -08:00
parent 0578085268
commit 1fc3c69409
2 changed files with 88 additions and 88 deletions

View File

@ -59,7 +59,8 @@ def _directory_to_check_translation(filename):
"neutron/server", "neutron/server",
"neutron/services", "neutron/services",
"neutron/plugins/ml2", "neutron/plugins/ml2",
"neutron/plugins/openvswitch"] "neutron/plugins/openvswitch",
"neutron/plugins/linuxbridge"]
return any([dir in filename for dir in dirs]) return any([dir in filename for dir in dirs])

View File

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