Update i18n translation for openvswitch log msg's

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

Partial-Bug: #1320867
Change-Id: I8a80ca6e45a32bd2945ddf4401f6820d99c93c28
This commit is contained in:
Romil Gupta 2014-11-13 05:42:55 -08:00
parent 6d67c14e1a
commit 2f8ec46314
3 changed files with 123 additions and 119 deletions

View File

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

View File

@ -20,7 +20,7 @@ from neutron.api.rpc.handlers import dvr_rpc
from neutron.common import constants as n_const from neutron.common import constants as n_const
from neutron.common import utils as n_utils from neutron.common import utils as n_utils
from neutron.openstack.common import excutils from neutron.openstack.common import excutils
from neutron.openstack.common.gettextutils import _LE, _LW, _LI 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.plugins.openvswitch.common import constants from neutron.plugins.openvswitch.common import constants
@ -326,16 +326,16 @@ class OVSDVRNeutronAgent(dvr_rpc.DVRAgentRpcApiMixin):
ldm = self.local_dvr_map[subnet_uuid] ldm = self.local_dvr_map[subnet_uuid]
csnat_ofport = ldm.get_csnat_ofport() csnat_ofport = ldm.get_csnat_ofport()
if csnat_ofport == constants.OFPORT_INVALID: if csnat_ofport == constants.OFPORT_INVALID:
LOG.error(_("DVR: Duplicate DVR router interface detected " LOG.error(_LE("DVR: Duplicate DVR router interface detected "
"for subnet %s"), subnet_uuid) "for subnet %s"), subnet_uuid)
return return
else: else:
# set up LocalDVRSubnetMapping available for this subnet # set up LocalDVRSubnetMapping available for this subnet
subnet_info = self.plugin_rpc.get_subnet_for_dvr(self.context, subnet_info = self.plugin_rpc.get_subnet_for_dvr(self.context,
subnet_uuid) subnet_uuid)
if not subnet_info: if not subnet_info:
LOG.error(_("DVR: Unable to retrieve subnet information" LOG.error(_LE("DVR: Unable to retrieve subnet information "
" for subnet_id %s"), subnet_uuid) "for subnet_id %s"), subnet_uuid)
return return
LOG.debug("get_subnet_for_dvr for subnet %s returned with %s" % LOG.debug("get_subnet_for_dvr for subnet %s returned with %s" %
(subnet_uuid, subnet_info)) (subnet_uuid, subnet_info))
@ -493,9 +493,9 @@ class OVSDVRNeutronAgent(dvr_rpc.DVRAgentRpcApiMixin):
# dvr routed subnet # dvr routed subnet
ovsport = self.local_ports[port.vif_id] ovsport = self.local_ports[port.vif_id]
subs = list(ovsport.get_subnets()) subs = list(ovsport.get_subnets())
LOG.error(_("Centralized-SNAT port %s already seen on "), LOG.error(_LE("Centralized-SNAT port %s already seen on "),
port.vif_id) port.vif_id)
LOG.error(_("a different subnet %s"), subs[0]) LOG.error(_LE("a different subnet %s"), subs[0])
return return
# since centralized-SNAT (CSNAT) port must have only one fixed # since centralized-SNAT (CSNAT) port must have only one fixed
# IP, directly use fixed_ips[0] # IP, directly use fixed_ips[0]

View File

@ -44,6 +44,7 @@ from neutron.common import utils as q_utils
from neutron import context from neutron import context
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.openstack.common.gettextutils import _LE, _LI, _LW
from neutron.plugins.common import constants as p_const from neutron.plugins.common import constants as p_const
from neutron.plugins.openvswitch.common import constants from neutron.plugins.openvswitch.common import constants
@ -273,7 +274,7 @@ class OVSNeutronAgent(n_rpc.RpcCallback,
self.use_call = False self.use_call = False
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): def setup_rpc(self):
self.agent_id = 'ovs-agent-%s' % cfg.CONF.host self.agent_id = 'ovs-agent-%s' % cfg.CONF.host
@ -304,15 +305,15 @@ class OVSNeutronAgent(n_rpc.RpcCallback,
return network_id return network_id
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')
LOG.debug(_("Delete %s"), network_id) LOG.debug("Delete %s", network_id)
# The network may not be defined on this agent # The network may not be defined on this agent
lvm = self.local_vlan_map.get(network_id) lvm = self.local_vlan_map.get(network_id)
if lvm: if lvm:
self.reclaim_local_vlan(network_id) self.reclaim_local_vlan(network_id)
else: else:
LOG.debug(_("Network %s not used on agent."), network_id) LOG.debug("Network %s not used on agent.", network_id)
def port_update(self, context, **kwargs): def port_update(self, context, **kwargs):
port = kwargs.get('port') port = kwargs.get('port')
@ -321,10 +322,10 @@ class OVSNeutronAgent(n_rpc.RpcCallback,
# they are not used since there is no guarantee the notifications # they are not used since there is no guarantee the notifications
# are processed in the same order as the relevant API requests # are processed in the same order as the relevant API requests
self.updated_ports.add(port['id']) self.updated_ports.add(port['id'])
LOG.debug(_("port_update message processed for port %s"), port['id']) LOG.debug("port_update message processed for port %s", port['id'])
def tunnel_update(self, context, **kwargs): def tunnel_update(self, context, **kwargs):
LOG.debug(_("tunnel_update received")) LOG.debug("tunnel_update received")
if not self.enable_tunneling: if not self.enable_tunneling:
return return
tunnel_ip = kwargs.get('tunnel_ip') tunnel_ip = kwargs.get('tunnel_ip')
@ -333,10 +334,11 @@ class OVSNeutronAgent(n_rpc.RpcCallback,
return return
tunnel_type = kwargs.get('tunnel_type') tunnel_type = kwargs.get('tunnel_type')
if not tunnel_type: if not tunnel_type:
LOG.error(_("No tunnel_type specified, cannot create tunnels")) LOG.error(_LE("No tunnel_type specified, cannot create tunnels"))
return return
if tunnel_type not in self.tunnel_types: if tunnel_type not in self.tunnel_types:
LOG.error(_("tunnel_type %s not supported by agent"), tunnel_type) LOG.error(_LE("tunnel_type %s not supported by agent"),
tunnel_type)
return return
if tunnel_ip == self.local_ip: if tunnel_ip == self.local_ip:
return return
@ -446,7 +448,7 @@ class OVSNeutronAgent(n_rpc.RpcCallback,
dl_vlan=local_vid, dl_vlan=local_vid,
nw_dst='%s' % ip) nw_dst='%s' % ip)
else: else:
LOG.warning(_('Action %s not supported'), action) LOG.warning(_LW('Action %s not supported'), action)
def provision_local_vlan(self, net_uuid, network_type, physical_network, def provision_local_vlan(self, net_uuid, network_type, physical_network,
segmentation_id): segmentation_id):
@ -467,7 +469,8 @@ class OVSNeutronAgent(n_rpc.RpcCallback,
lvid = lvm.vlan lvid = lvm.vlan
else: else:
if not self.available_local_vlans: if not self.available_local_vlans:
LOG.error(_("No local VLAN available for net-id=%s"), net_uuid) LOG.error(_LE("No local VLAN available for net-id=%s"),
net_uuid)
return return
lvid = self.available_local_vlans.pop() lvid = self.available_local_vlans.pop()
self.local_vlan_map[net_uuid] = LocalVLANMapping(lvid, self.local_vlan_map[net_uuid] = LocalVLANMapping(lvid,
@ -475,8 +478,8 @@ class OVSNeutronAgent(n_rpc.RpcCallback,
physical_network, physical_network,
segmentation_id) segmentation_id)
LOG.info(_("Assigning %(vlan_id)s as local vlan for " LOG.info(_LI("Assigning %(vlan_id)s as local vlan for "
"net-id=%(net_uuid)s"), "net-id=%(net_uuid)s"),
{'vlan_id': lvid, 'net_uuid': net_uuid}) {'vlan_id': lvid, 'net_uuid': net_uuid})
if network_type in constants.TUNNEL_NETWORK_TYPES: if network_type in constants.TUNNEL_NETWORK_TYPES:
@ -504,8 +507,8 @@ class OVSNeutronAgent(n_rpc.RpcCallback,
(lvid, constants.LEARN_FROM_TUN)) (lvid, constants.LEARN_FROM_TUN))
else: else:
LOG.error(_("Cannot provision %(network_type)s network for " LOG.error(_LE("Cannot provision %(network_type)s network for "
"net-id=%(net_uuid)s - tunneling disabled"), "net-id=%(net_uuid)s - tunneling disabled"),
{'network_type': network_type, {'network_type': network_type,
'net_uuid': net_uuid}) 'net_uuid': net_uuid})
elif network_type == p_const.TYPE_FLAT: elif network_type == p_const.TYPE_FLAT:
@ -523,9 +526,9 @@ class OVSNeutronAgent(n_rpc.RpcCallback,
dl_vlan=0xffff, dl_vlan=0xffff,
actions="mod_vlan_vid:%s,normal" % lvid) actions="mod_vlan_vid:%s,normal" % lvid)
else: else:
LOG.error(_("Cannot provision flat network for " LOG.error(_LE("Cannot provision flat network for "
"net-id=%(net_uuid)s - no bridge for " "net-id=%(net_uuid)s - no bridge for "
"physical_network %(physical_network)s"), "physical_network %(physical_network)s"),
{'net_uuid': net_uuid, {'net_uuid': net_uuid,
'physical_network': physical_network}) 'physical_network': physical_network})
elif network_type == p_const.TYPE_VLAN: elif network_type == p_const.TYPE_VLAN:
@ -543,17 +546,17 @@ class OVSNeutronAgent(n_rpc.RpcCallback,
dl_vlan=segmentation_id, dl_vlan=segmentation_id,
actions="mod_vlan_vid:%s,normal" % lvid) actions="mod_vlan_vid:%s,normal" % lvid)
else: else:
LOG.error(_("Cannot provision VLAN network for " LOG.error(_LE("Cannot provision VLAN network for "
"net-id=%(net_uuid)s - no bridge for " "net-id=%(net_uuid)s - no bridge for "
"physical_network %(physical_network)s"), "physical_network %(physical_network)s"),
{'net_uuid': net_uuid, {'net_uuid': net_uuid,
'physical_network': physical_network}) 'physical_network': physical_network})
elif network_type == p_const.TYPE_LOCAL: elif network_type == p_const.TYPE_LOCAL:
# no flows needed for local networks # no flows needed for local networks
pass pass
else: else:
LOG.error(_("Cannot provision unknown network type " LOG.error(_LE("Cannot provision unknown network type "
"%(network_type)s for net-id=%(net_uuid)s"), "%(network_type)s for net-id=%(net_uuid)s"),
{'network_type': network_type, {'network_type': network_type,
'net_uuid': net_uuid}) 'net_uuid': net_uuid})
@ -566,12 +569,12 @@ class OVSNeutronAgent(n_rpc.RpcCallback,
''' '''
lvm = self.local_vlan_map.pop(net_uuid, None) lvm = self.local_vlan_map.pop(net_uuid, None)
if lvm is None: if lvm is None:
LOG.debug(_("Network %s not used on agent."), net_uuid) LOG.debug("Network %s not used on agent.", net_uuid)
return return
LOG.info(_("Reclaiming vlan = %(vlan_id)s from net-id = %(net_uuid)s"), LOG.info(_LI("Reclaiming vlan = %(vlan_id)s from "
{'vlan_id': lvm.vlan, "net-id = %(net_uuid)s"),
'net_uuid': net_uuid}) {'vlan_id': lvm.vlan, 'net_uuid': net_uuid})
if lvm.network_type in constants.TUNNEL_NETWORK_TYPES: if lvm.network_type in constants.TUNNEL_NETWORK_TYPES:
if self.enable_tunneling: if self.enable_tunneling:
@ -610,8 +613,8 @@ class OVSNeutronAgent(n_rpc.RpcCallback,
# no flows needed for local networks # no flows needed for local networks
pass pass
else: else:
LOG.error(_("Cannot reclaim unknown network type " LOG.error(_LE("Cannot reclaim unknown network type "
"%(network_type)s for net-id=%(net_uuid)s"), "%(network_type)s for net-id=%(net_uuid)s"),
{'network_type': lvm.network_type, {'network_type': lvm.network_type,
'net_uuid': net_uuid}) 'net_uuid': net_uuid})
@ -664,7 +667,7 @@ class OVSNeutronAgent(n_rpc.RpcCallback,
net_uuid = self.get_net_uuid(vif_id) net_uuid = self.get_net_uuid(vif_id)
if not self.local_vlan_map.get(net_uuid): if not self.local_vlan_map.get(net_uuid):
LOG.info(_('port_unbound(): net_uuid %s not in local_vlan_map'), LOG.info(_LI('port_unbound(): net_uuid %s not in local_vlan_map'),
net_uuid) net_uuid)
return return
@ -737,7 +740,7 @@ class OVSNeutronAgent(n_rpc.RpcCallback,
ancillary_bridges = [] ancillary_bridges = []
for bridge in ovs_bridges: for bridge in ovs_bridges:
br = ovs_lib.OVSBridge(bridge, self.root_helper) br = ovs_lib.OVSBridge(bridge, self.root_helper)
LOG.info(_('Adding %s to list of bridges.'), bridge) LOG.info(_LI('Adding %s to list of bridges.'), bridge)
ancillary_bridges.append(br) ancillary_bridges.append(br)
return ancillary_bridges return ancillary_bridges
@ -758,10 +761,10 @@ class OVSNeutronAgent(n_rpc.RpcCallback,
self.patch_int_ofport = self.tun_br.add_patch_port( self.patch_int_ofport = self.tun_br.add_patch_port(
cfg.CONF.OVS.tun_peer_patch_port, cfg.CONF.OVS.int_peer_patch_port) cfg.CONF.OVS.tun_peer_patch_port, cfg.CONF.OVS.int_peer_patch_port)
if int(self.patch_tun_ofport) < 0 or int(self.patch_int_ofport) < 0: if int(self.patch_tun_ofport) < 0 or int(self.patch_int_ofport) < 0:
LOG.error(_("Failed to create OVS patch port. Cannot have " LOG.error(_LE("Failed to create OVS patch port. Cannot have "
"tunneling enabled on this agent, since this version " "tunneling enabled on this agent, since this "
"of OVS does not support tunnels or patch ports. " "version of OVS does not support tunnels or "
"Agent terminated!")) "patch ports. Agent terminated!"))
exit(1) exit(1)
self.tun_br.remove_all_flows() self.tun_br.remove_all_flows()
@ -857,9 +860,9 @@ class OVSNeutronAgent(n_rpc.RpcCallback,
new_name = ('%(prefix)s%(truncated)s%(hash)s' % new_name = ('%(prefix)s%(truncated)s%(hash)s' %
{'prefix': prefix, 'truncated': name[0:namelen], {'prefix': prefix, 'truncated': name[0:namelen],
'hash': hashlib.sha1(name).hexdigest()[0:hashlen]}) 'hash': hashlib.sha1(name).hexdigest()[0:hashlen]})
LOG.warning(_("Creating an interface named %(name)s exceeds the " LOG.warning(_LW("Creating an interface named %(name)s exceeds the "
"%(limit)d character limitation. It was shortened to " "%(limit)d character limitation. It was shortened to "
"%(new_name)s to fit."), "%(new_name)s to fit."),
{'name': name, 'limit': q_const.DEVICE_NAME_MAX_LEN, {'name': name, 'limit': q_const.DEVICE_NAME_MAX_LEN,
'new_name': new_name}) 'new_name': new_name})
return new_name return new_name
@ -878,15 +881,15 @@ class OVSNeutronAgent(n_rpc.RpcCallback,
ip_wrapper = ip_lib.IPWrapper(self.root_helper) ip_wrapper = ip_lib.IPWrapper(self.root_helper)
ovs_bridges = ovs_lib.get_bridges(self.root_helper) ovs_bridges = ovs_lib.get_bridges(self.root_helper)
for physical_network, bridge in bridge_mappings.iteritems(): for physical_network, bridge in bridge_mappings.iteritems():
LOG.info(_("Mapping physical network %(physical_network)s to " LOG.info(_LI("Mapping physical network %(physical_network)s to "
"bridge %(bridge)s"), "bridge %(bridge)s"),
{'physical_network': physical_network, {'physical_network': physical_network,
'bridge': bridge}) 'bridge': bridge})
# setup physical bridge # setup physical bridge
if bridge not in ovs_bridges: if bridge not in ovs_bridges:
LOG.error(_("Bridge %(bridge)s for physical network " LOG.error(_LE("Bridge %(bridge)s for physical network "
"%(physical_network)s does not exist. Agent " "%(physical_network)s does not exist. Agent "
"terminated!"), "terminated!"),
{'physical_network': physical_network, {'physical_network': physical_network,
'bridge': bridge}) 'bridge': bridge})
sys.exit(1) sys.exit(1)
@ -988,7 +991,7 @@ class OVSNeutronAgent(n_rpc.RpcCallback,
and port_tags[lvm.vif_ports[port].port_name] != lvm.vlan and port_tags[lvm.vif_ports[port].port_name] != lvm.vlan
): ):
LOG.info( LOG.info(
_("Port '%(port_name)s' has lost " _LI("Port '%(port_name)s' has lost "
"its vlan tag '%(vlan_tag)d'!"), "its vlan tag '%(vlan_tag)d'!"),
{'port_name': lvm.vif_ports[port].port_name, {'port_name': lvm.vif_ports[port].port_name,
'vlan_tag': lvm.vlan} 'vlan_tag': lvm.vlan}
@ -1017,8 +1020,8 @@ class OVSNeutronAgent(n_rpc.RpcCallback,
# for being treated. If that does not happen, it is a potential # for being treated. If that does not happen, it is a potential
# error condition of which operators should be aware # error condition of which operators should be aware
if not vif_port.ofport: if not vif_port.ofport:
LOG.warn(_("VIF port: %s has no ofport configured, and might not " LOG.warn(_LW("VIF port: %s has no ofport configured, "
"be able to transmit"), vif_port.vif_id) "and might not be able to transmit"), vif_port.vif_id)
if vif_port: if vif_port:
if admin_state_up: if admin_state_up:
self.port_bound(vif_port, network_id, network_type, self.port_bound(vif_port, network_id, network_type,
@ -1027,7 +1030,7 @@ class OVSNeutronAgent(n_rpc.RpcCallback,
else: else:
self.port_dead(vif_port) self.port_dead(vif_port)
else: else:
LOG.debug(_("No VIF port for port %s defined on agent."), port_id) LOG.debug("No VIF port for port %s defined on agent.", port_id)
def _setup_tunnel_port(self, br, port_name, remote_ip, tunnel_type): def _setup_tunnel_port(self, br, port_name, remote_ip, tunnel_type):
ofport = br.add_tunnel_port(port_name, ofport = br.add_tunnel_port(port_name,
@ -1040,10 +1043,10 @@ class OVSNeutronAgent(n_rpc.RpcCallback,
try: try:
ofport_int = int(ofport) ofport_int = int(ofport)
except (TypeError, ValueError): except (TypeError, ValueError):
LOG.exception(_("ofport should have a value that can be " LOG.exception(_LE("ofport should have a value that can be "
"interpreted as an integer")) "interpreted as an integer"))
if ofport_int < 0: if ofport_int < 0:
LOG.error(_("Failed to set-up %(type)s tunnel port to %(ip)s"), LOG.error(_LE("Failed to set-up %(type)s tunnel port to %(ip)s"),
{'type': tunnel_type, 'ip': remote_ip}) {'type': tunnel_type, 'ip': remote_ip})
return 0 return 0
@ -1108,13 +1111,13 @@ class OVSNeutronAgent(n_rpc.RpcCallback,
port = self.int_br.get_vif_port_by_id(device) port = self.int_br.get_vif_port_by_id(device)
if not port: if not port:
# The port disappeared and cannot be processed # The port disappeared and cannot be processed
LOG.info(_("Port %s was not found on the integration bridge " LOG.info(_LI("Port %s was not found on the integration bridge "
"and will therefore not be processed"), device) "and will therefore not be processed"), device)
skipped_devices.append(device) skipped_devices.append(device)
continue continue
if 'port_id' in details: if 'port_id' in details:
LOG.info(_("Port %(device)s updated. Details: %(details)s"), LOG.info(_LI("Port %(device)s updated. Details: %(details)s"),
{'device': device, 'details': details}) {'device': device, 'details': details})
self.treat_vif_port(port, details['port_id'], self.treat_vif_port(port, details['port_id'],
details['network_id'], details['network_id'],
@ -1131,16 +1134,16 @@ class OVSNeutronAgent(n_rpc.RpcCallback,
# neutron server from sending network-vif-* events to the nova # neutron server from sending network-vif-* events to the nova
# API server, thus possibly preventing instance spawn. # API server, thus possibly preventing instance spawn.
if details.get('admin_state_up'): if details.get('admin_state_up'):
LOG.debug(_("Setting status for %s to UP"), device) LOG.debug("Setting status for %s to UP", device)
self.plugin_rpc.update_device_up( self.plugin_rpc.update_device_up(
self.context, device, self.agent_id, cfg.CONF.host) self.context, device, self.agent_id, cfg.CONF.host)
else: else:
LOG.debug(_("Setting status for %s to DOWN"), device) LOG.debug("Setting status for %s to DOWN", device)
self.plugin_rpc.update_device_down( self.plugin_rpc.update_device_down(
self.context, device, self.agent_id, cfg.CONF.host) self.context, device, self.agent_id, cfg.CONF.host)
LOG.info(_("Configuration for device %s completed."), device) LOG.info(_LI("Configuration for device %s completed."), device)
else: else:
LOG.warn(_("Device %s not defined on plugin"), device) LOG.warn(_LW("Device %s not defined on plugin"), device)
if (port and port.ofport != -1): if (port and port.ofport != -1):
self.port_dead(port) self.port_dead(port)
return skipped_devices return skipped_devices
@ -1157,7 +1160,7 @@ class OVSNeutronAgent(n_rpc.RpcCallback,
for details in devices_details_list: for details in devices_details_list:
device = details['device'] device = details['device']
LOG.info(_("Ancillary Port %s added"), device) LOG.info(_LI("Ancillary Port %s added"), device)
# update plugin about port status # update plugin about port status
self.plugin_rpc.update_device_up(self.context, self.plugin_rpc.update_device_up(self.context,
@ -1169,14 +1172,14 @@ class OVSNeutronAgent(n_rpc.RpcCallback,
resync = False resync = False
self.sg_agent.remove_devices_filter(devices) self.sg_agent.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)
try: try:
self.plugin_rpc.update_device_down(self.context, self.plugin_rpc.update_device_down(self.context,
device, device,
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
continue continue
@ -1186,22 +1189,22 @@ class OVSNeutronAgent(n_rpc.RpcCallback,
def treat_ancillary_devices_removed(self, devices): def treat_ancillary_devices_removed(self, devices):
resync = False resync = False
for device in devices: for device in devices:
LOG.info(_("Attachment %s removed"), device) LOG.info(_LI("Attachment %s removed"), device)
try: try:
details = self.plugin_rpc.update_device_down(self.context, details = self.plugin_rpc.update_device_down(self.context,
device, device,
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
continue continue
if details['exists']: if details['exists']:
LOG.info(_("Port %s updated."), device) LOG.info(_LI("Port %s updated."), device)
# Nothing to do regarding local networking # Nothing to do regarding local networking
else: else:
LOG.debug(_("Device %s not defined on plugin"), device) LOG.debug("Device %s not defined on plugin", device)
return resync return resync
def process_network_ports(self, port_info, ovs_restarted): def process_network_ports(self, port_info, ovs_restarted):
@ -1229,11 +1232,11 @@ class OVSNeutronAgent(n_rpc.RpcCallback,
try: try:
skipped_devices = self.treat_devices_added_or_updated( skipped_devices = self.treat_devices_added_or_updated(
devices_added_updated, ovs_restarted) devices_added_updated, ovs_restarted)
LOG.debug(_("process_network_ports - iteration:%(iter_num)d -" LOG.debug("process_network_ports - iteration:%(iter_num)d -"
"treat_devices_added_or_updated completed. " "treat_devices_added_or_updated completed. "
"Skipped %(num_skipped)d devices of " "Skipped %(num_skipped)d devices of "
"%(num_current)d devices currently available. " "%(num_current)d devices currently available. "
"Time elapsed: %(elapsed).3f"), "Time elapsed: %(elapsed).3f",
{'iter_num': self.iter_num, {'iter_num': self.iter_num,
'num_skipped': len(skipped_devices), 'num_skipped': len(skipped_devices),
'num_current': len(port_info['current']), 'num_current': len(port_info['current']),
@ -1245,15 +1248,15 @@ class OVSNeutronAgent(n_rpc.RpcCallback,
except DeviceListRetrievalError: except DeviceListRetrievalError:
# Need to resync as there was an error with server # Need to resync as there was an error with server
# communication. # communication.
LOG.exception(_("process_network_ports - iteration:%d - " LOG.exception(_LE("process_network_ports - iteration:%d - "
"failure while retrieving port details " "failure while retrieving port details "
"from server"), self.iter_num) "from server"), self.iter_num)
resync_a = True resync_a = True
if 'removed' in port_info: if 'removed' in port_info:
start = time.time() start = time.time()
resync_b = self.treat_devices_removed(port_info['removed']) resync_b = self.treat_devices_removed(port_info['removed'])
LOG.debug(_("process_network_ports - iteration:%(iter_num)d -" LOG.debug("process_network_ports - iteration:%(iter_num)d -"
"treat_devices_removed completed in %(elapsed).3f"), "treat_devices_removed completed in %(elapsed).3f",
{'iter_num': self.iter_num, {'iter_num': self.iter_num,
'elapsed': time.time() - start}) 'elapsed': time.time() - start})
# If one of the above operations fails => resync with plugin # If one of the above operations fails => resync with plugin
@ -1266,25 +1269,25 @@ class OVSNeutronAgent(n_rpc.RpcCallback,
start = time.time() start = time.time()
try: try:
self.treat_ancillary_devices_added(port_info['added']) self.treat_ancillary_devices_added(port_info['added'])
LOG.debug(_("process_ancillary_network_ports - iteration: " LOG.debug("process_ancillary_network_ports - iteration: "
"%(iter_num)d - treat_ancillary_devices_added " "%(iter_num)d - treat_ancillary_devices_added "
"completed in %(elapsed).3f"), "completed in %(elapsed).3f",
{'iter_num': self.iter_num, {'iter_num': self.iter_num,
'elapsed': time.time() - start}) 'elapsed': time.time() - start})
except DeviceListRetrievalError: except DeviceListRetrievalError:
# Need to resync as there was an error with server # Need to resync as there was an error with server
# communication. # communication.
LOG.exception(_("process_ancillary_network_ports - " LOG.exception(_LE("process_ancillary_network_ports - "
"iteration:%d - failure while retrieving " "iteration:%d - failure while retrieving "
"port details from server"), self.iter_num) "port details from server"), self.iter_num)
resync_a = True resync_a = True
if 'removed' in port_info: if 'removed' in port_info:
start = time.time() start = time.time()
resync_b = self.treat_ancillary_devices_removed( resync_b = self.treat_ancillary_devices_removed(
port_info['removed']) port_info['removed'])
LOG.debug(_("process_ancillary_network_ports - iteration: " LOG.debug("process_ancillary_network_ports - iteration: "
"%(iter_num)d - treat_ancillary_devices_removed " "%(iter_num)d - treat_ancillary_devices_removed "
"completed in %(elapsed).3f"), "completed in %(elapsed).3f",
{'iter_num': self.iter_num, {'iter_num': self.iter_num,
'elapsed': time.time() - start}) 'elapsed': time.time() - start})
@ -1295,8 +1298,8 @@ class OVSNeutronAgent(n_rpc.RpcCallback,
try: try:
return '%08x' % netaddr.IPAddress(ip_address, version=4) return '%08x' % netaddr.IPAddress(ip_address, version=4)
except Exception: except Exception:
LOG.warn(_("Unable to create tunnel port. Invalid remote IP: %s"), LOG.warn(_LW("Unable to create tunnel port. "
ip_address) "Invalid remote IP: %s"), ip_address)
return return
def tunnel_sync(self): def tunnel_sync(self):
@ -1324,7 +1327,7 @@ class OVSNeutronAgent(n_rpc.RpcCallback,
tunnel['ip_address'], tunnel['ip_address'],
tunnel_type) tunnel_type)
except Exception as e: except Exception as e:
LOG.debug(_("Unable to sync tunnel IP %(local_ip)s: %(e)s"), LOG.debug("Unable to sync tunnel IP %(local_ip)s: %(e)s",
{'local_ip': self.local_ip, 'e': e}) {'local_ip': self.local_ip, 'e': e})
return True return True
return False return False
@ -1361,10 +1364,10 @@ class OVSNeutronAgent(n_rpc.RpcCallback,
'removed': 0}, 'removed': 0},
'ancillary': {'added': 0, 'ancillary': {'added': 0,
'removed': 0}} 'removed': 0}}
LOG.debug(_("Agent rpc_loop - iteration:%d started"), LOG.debug("Agent rpc_loop - iteration:%d started",
self.iter_num) self.iter_num)
if sync: if sync:
LOG.info(_("Agent out of sync with plugin!")) LOG.info(_LI("Agent out of sync with plugin!"))
ports.clear() ports.clear()
ancillary_ports.clear() ancillary_ports.clear()
sync = False sync = False
@ -1386,16 +1389,16 @@ class OVSNeutronAgent(n_rpc.RpcCallback,
self.dvr_agent.setup_dvr_flows_on_integ_tun_br() self.dvr_agent.setup_dvr_flows_on_integ_tun_br()
# Notify the plugin of tunnel IP # Notify the plugin of tunnel IP
if self.enable_tunneling and tunnel_sync: if self.enable_tunneling and tunnel_sync:
LOG.info(_("Agent tunnel out of sync with plugin!")) LOG.info(_LI("Agent tunnel out of sync with plugin!"))
try: try:
tunnel_sync = self.tunnel_sync() tunnel_sync = self.tunnel_sync()
except Exception: except Exception:
LOG.exception(_("Error while synchronizing tunnels")) LOG.exception(_LE("Error while synchronizing tunnels"))
tunnel_sync = True tunnel_sync = True
if self._agent_has_updates(polling_manager) or ovs_restarted: if self._agent_has_updates(polling_manager) or ovs_restarted:
try: try:
LOG.debug(_("Agent rpc_loop - iteration:%(iter_num)d - " LOG.debug("Agent rpc_loop - iteration:%(iter_num)d - "
"starting polling. Elapsed:%(elapsed).3f"), "starting polling. Elapsed:%(elapsed).3f",
{'iter_num': self.iter_num, {'iter_num': self.iter_num,
'elapsed': time.time() - start}) 'elapsed': time.time() - start})
# Save updated ports dict to perform rollback in # Save updated ports dict to perform rollback in
@ -1406,9 +1409,9 @@ class OVSNeutronAgent(n_rpc.RpcCallback,
self.updated_ports = set() self.updated_ports = set()
reg_ports = (set() if ovs_restarted else ports) reg_ports = (set() if ovs_restarted else ports)
port_info = self.scan_ports(reg_ports, updated_ports_copy) port_info = self.scan_ports(reg_ports, updated_ports_copy)
LOG.debug(_("Agent rpc_loop - iteration:%(iter_num)d - " LOG.debug("Agent rpc_loop - iteration:%(iter_num)d - "
"port information retrieved. " "port information retrieved. "
"Elapsed:%(elapsed).3f"), "Elapsed:%(elapsed).3f",
{'iter_num': self.iter_num, {'iter_num': self.iter_num,
'elapsed': time.time() - start}) 'elapsed': time.time() - start})
# Secure and wire/unwire VIFs and update their status # Secure and wire/unwire VIFs and update their status
@ -1416,13 +1419,13 @@ class OVSNeutronAgent(n_rpc.RpcCallback,
if (self._port_info_has_changes(port_info) or if (self._port_info_has_changes(port_info) or
self.sg_agent.firewall_refresh_needed() or self.sg_agent.firewall_refresh_needed() or
ovs_restarted): ovs_restarted):
LOG.debug(_("Starting to process devices in:%s"), LOG.debug("Starting to process devices in:%s",
port_info) port_info)
# If treat devices fails - must resync with plugin # If treat devices fails - must resync with plugin
sync = self.process_network_ports(port_info, sync = self.process_network_ports(port_info,
ovs_restarted) ovs_restarted)
LOG.debug(_("Agent rpc_loop - iteration:%(iter_num)d -" LOG.debug("Agent rpc_loop - iteration:%(iter_num)d -"
"ports processed. Elapsed:%(elapsed).3f"), "ports processed. Elapsed:%(elapsed).3f",
{'iter_num': self.iter_num, {'iter_num': self.iter_num,
'elapsed': time.time() - start}) 'elapsed': time.time() - start})
port_stats['regular']['added'] = ( port_stats['regular']['added'] = (
@ -1436,18 +1439,18 @@ class OVSNeutronAgent(n_rpc.RpcCallback,
if self.ancillary_brs: if self.ancillary_brs:
port_info = self.update_ancillary_ports( port_info = self.update_ancillary_ports(
ancillary_ports) ancillary_ports)
LOG.debug(_("Agent rpc_loop - iteration:%(iter_num)d -" LOG.debug("Agent rpc_loop - iteration:%(iter_num)d -"
"ancillary port info retrieved. " "ancillary port info retrieved. "
"Elapsed:%(elapsed).3f"), "Elapsed:%(elapsed).3f",
{'iter_num': self.iter_num, {'iter_num': self.iter_num,
'elapsed': time.time() - start}) 'elapsed': time.time() - start})
if port_info: if port_info:
rc = self.process_ancillary_network_ports( rc = self.process_ancillary_network_ports(
port_info) port_info)
LOG.debug(_("Agent rpc_loop - iteration:" LOG.debug("Agent rpc_loop - iteration:"
"%(iter_num)d - ancillary ports " "%(iter_num)d - ancillary ports "
"processed. Elapsed:%(elapsed).3f"), "processed. Elapsed:%(elapsed).3f",
{'iter_num': self.iter_num, {'iter_num': self.iter_num,
'elapsed': time.time() - start}) 'elapsed': time.time() - start})
ancillary_ports = port_info['current'] ancillary_ports = port_info['current']
@ -1459,24 +1462,24 @@ class OVSNeutronAgent(n_rpc.RpcCallback,
polling_manager.polling_completed() polling_manager.polling_completed()
except Exception: except Exception:
LOG.exception(_("Error while processing VIF ports")) LOG.exception(_LE("Error while processing VIF ports"))
# Put the ports back in self.updated_port # Put the ports back in self.updated_port
self.updated_ports |= updated_ports_copy self.updated_ports |= updated_ports_copy
sync = True sync = True
# sleep till end of polling interval # sleep till end of polling interval
elapsed = (time.time() - start) elapsed = (time.time() - start)
LOG.debug(_("Agent rpc_loop - iteration:%(iter_num)d " LOG.debug("Agent rpc_loop - iteration:%(iter_num)d "
"completed. Processed ports statistics: " "completed. Processed ports statistics: "
"%(port_stats)s. Elapsed:%(elapsed).3f"), "%(port_stats)s. Elapsed:%(elapsed).3f",
{'iter_num': self.iter_num, {'iter_num': self.iter_num,
'port_stats': port_stats, 'port_stats': port_stats,
'elapsed': elapsed}) 'elapsed': elapsed})
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})
self.iter_num = self.iter_num + 1 self.iter_num = self.iter_num + 1
@ -1546,7 +1549,7 @@ def main():
try: try:
agent_config = create_agent_config_map(cfg.CONF) agent_config = create_agent_config_map(cfg.CONF)
except ValueError as e: except ValueError as e:
LOG.error(_('%s Agent terminated!'), e) LOG.error(_LE('%s Agent terminated!'), e)
sys.exit(1) sys.exit(1)
is_xen_compute_host = 'rootwrap-xen-dom0' in agent_config['root_helper'] is_xen_compute_host = 'rootwrap-xen-dom0' in agent_config['root_helper']
@ -1559,7 +1562,7 @@ def main():
signal.signal(signal.SIGTERM, agent._handle_sigterm) signal.signal(signal.SIGTERM, agent._handle_sigterm)
# Start everything. # Start everything.
LOG.info(_("Agent initialized successfully, now running... ")) LOG.info(_LI("Agent initialized successfully, now running... "))
agent.daemon_loop() agent.daemon_loop()