Update i18n translation for ML2 plugin 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 ml2 directory under neutron/plugins.

Partial-Bug: #1320867
Change-Id: I9d78d23bbc14e7c536c6ddf2dc4f52c67faeb667
This commit is contained in:
Romil Gupta 2014-10-26 06:18:53 -07:00
parent d42055cf21
commit 6d67c14e1a
30 changed files with 304 additions and 292 deletions

View File

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

View File

@ -26,6 +26,7 @@ from neutron.db import models_v2
from neutron.db import securitygroups_db as sg_db from neutron.db import securitygroups_db as sg_db
from neutron.extensions import portbindings from neutron.extensions import portbindings
from neutron import manager from neutron import manager
from neutron.openstack.common.gettextutils import _LE, _LI
from neutron.openstack.common import log from neutron.openstack.common import log
from neutron.openstack.common import uuidutils from neutron.openstack.common import uuidutils
from neutron.plugins.ml2 import driver_api as api from neutron.plugins.ml2 import driver_api as api
@ -59,8 +60,8 @@ def add_network_segment(session, network_id, segment, segment_index=0,
) )
session.add(record) session.add(record)
segment[api.ID] = record.id segment[api.ID] = record.id
LOG.info(_("Added segment %(id)s of type %(network_type)s for network" LOG.info(_LI("Added segment %(id)s of type %(network_type)s for network"
" %(network_id)s"), " %(network_id)s"),
{'id': record.id, {'id': record.id,
'network_type': record.network_type, 'network_type': record.network_type,
'network_id': record.network_id}) 'network_id': record.network_id})
@ -203,13 +204,13 @@ def get_port(session, port_id):
except exc.NoResultFound: except exc.NoResultFound:
return return
except exc.MultipleResultsFound: except exc.MultipleResultsFound:
LOG.error(_("Multiple ports have port_id starting with %s"), LOG.error(_LE("Multiple ports have port_id starting with %s"),
port_id) port_id)
return return
def get_port_from_device_mac(device_mac): def get_port_from_device_mac(device_mac):
LOG.debug(_("get_port_from_device_mac() called for mac %s"), device_mac) LOG.debug("get_port_from_device_mac() called for mac %s", device_mac)
session = db_api.get_session() session = db_api.get_session()
qry = session.query(models_v2.Port).filter_by(mac_address=device_mac) qry = session.query(models_v2.Port).filter_by(mac_address=device_mac)
return qry.first() return qry.first()
@ -283,11 +284,11 @@ def get_port_binding_host(port_id):
filter(models.PortBinding.port_id.startswith(port_id)). filter(models.PortBinding.port_id.startswith(port_id)).
one()) one())
except exc.NoResultFound: except exc.NoResultFound:
LOG.debug(_("No binding found for port %(port_id)s"), LOG.debug("No binding found for port %(port_id)s",
{'port_id': port_id}) {'port_id': port_id})
return return
except exc.MultipleResultsFound: except exc.MultipleResultsFound:
LOG.error(_("Multiple ports have port_id starting with %s"), LOG.error(_LE("Multiple ports have port_id starting with %s"),
port_id) port_id)
return return
return query.host return query.host

View File

@ -21,6 +21,7 @@ from oslo.config import cfg
from neutron import context as nctx from neutron import context as nctx
from neutron.db import db_base_plugin_v2 from neutron.db import db_base_plugin_v2
from neutron.openstack.common.gettextutils import _LI
from neutron.openstack.common import log as logging from neutron.openstack.common import log as logging
from neutron.plugins.ml2.drivers.arista import exceptions as arista_exc from neutron.plugins.ml2.drivers.arista import exceptions as arista_exc
@ -369,13 +370,13 @@ class AristaL3Driver(object):
command_end = ['exit'] command_end = ['exit']
full_command = command_start + commands + command_end full_command = command_start + commands + command_end
LOG.info(_('Executing command on Arista EOS: %s'), full_command) LOG.info(_LI('Executing command on Arista EOS: %s'), full_command)
try: try:
# this returns array of return values for every command in # this returns array of return values for every command in
# full_command list # full_command list
ret = server.runCmds(version=1, cmds=full_command) ret = server.runCmds(version=1, cmds=full_command)
LOG.info(_('Results of execution on Arista EOS: %s'), ret) LOG.info(_LI('Results of execution on Arista EOS: %s'), ret)
except Exception: except Exception:
msg = (_('Error occured while trying to execute ' msg = (_('Error occured while trying to execute '

View File

@ -20,6 +20,7 @@ import jsonrpclib
from oslo.config import cfg from oslo.config import cfg
from neutron.common import constants as n_const from neutron.common import constants as n_const
from neutron.openstack.common.gettextutils import _LI, _LW
from neutron.openstack.common import log as logging from neutron.openstack.common import log as logging
from neutron.plugins.ml2.common import exceptions as ml2_exc from neutron.plugins.ml2.common import exceptions as ml2_exc
from neutron.plugins.ml2 import driver_api from neutron.plugins.ml2 import driver_api
@ -73,8 +74,8 @@ class AristaRPCWrapper(object):
self.cli_commands['timestamp'] = cmd self.cli_commands['timestamp'] = cmd
except arista_exc.AristaRpcError: except arista_exc.AristaRpcError:
self.cli_commands['timestamp'] = [] self.cli_commands['timestamp'] = []
msg = _("'timestamp' command '%s' is not available on EOS") % cmd LOG.warn(_LW("'timestamp' command '%s' is not available on EOS"),
LOG.warn(msg) cmd)
def _keystone_url(self): def _keystone_url(self):
keystone_auth_url = ('%s://%s:%s/v2.0/' % keystone_auth_url = ('%s://%s:%s/v2.0/' %
@ -327,10 +328,8 @@ class AristaRPCWrapper(object):
try: try:
vm = vms[port['device_id']] vm = vms[port['device_id']]
except KeyError: except KeyError:
msg = _("VM id %(vmid)s not found for port %(portid)s") % { LOG.warn(_LW("VM id %(vmid)s not found for port %(portid)s"),
'vmid': port['device_id'], {'vmid': port['device_id'], 'portid': port['id']})
'portid': port['id']}
LOG.warn(msg)
continue continue
port_name = '' if 'name' not in port else 'name "%s"' % ( port_name = '' if 'name' not in port else 'name "%s"' % (
@ -346,8 +345,7 @@ class AristaRPCWrapper(object):
append_cmd('port id %s %s network-id %s' % append_cmd('port id %s %s network-id %s' %
(port['id'], port_name, port['network_id'])) (port['id'], port_name, port['network_id']))
else: else:
msg = _("Unknown device owner: %s") % port['device_owner'] LOG.warn(_LW("Unknown device owner: %s"), port['device_owner'])
LOG.warn(msg)
continue continue
append_cmd('exit') append_cmd('exit')
@ -450,7 +448,7 @@ class AristaRPCWrapper(object):
if commands_to_log: if commands_to_log:
log_cmds = commands_to_log log_cmds = commands_to_log
LOG.info(_('Executing command on Arista EOS: %s'), log_cmds) LOG.info(_LI('Executing command on Arista EOS: %s'), log_cmds)
try: try:
# this returns array of return values for every command in # this returns array of return values for every command in
@ -562,7 +560,7 @@ class SyncService(object):
try: try:
# Send trigger to EOS that the ML2->EOS sync has started. # Send trigger to EOS that the ML2->EOS sync has started.
self._rpc.sync_start() self._rpc.sync_start()
LOG.info(_('Sync start trigger sent to EOS')) LOG.info(_LI('Sync start trigger sent to EOS'))
except arista_exc.AristaRpcError: except arista_exc.AristaRpcError:
LOG.warning(EOS_UNREACHABLE_MSG) LOG.warning(EOS_UNREACHABLE_MSG)
return return
@ -579,13 +577,13 @@ class SyncService(object):
def synchronize(self): def synchronize(self):
"""Sends data to EOS which differs from neutron DB.""" """Sends data to EOS which differs from neutron DB."""
LOG.info(_('Syncing Neutron <-> EOS')) LOG.info(_LI('Syncing Neutron <-> EOS'))
try: try:
# Get the time at which entities in the region were updated. # Get the time at which entities in the region were updated.
# If the times match, then ML2 is in sync with EOS. Otherwise # If the times match, then ML2 is in sync with EOS. Otherwise
# perform a complete sync. # perform a complete sync.
if not self._force_sync and self._rpc.region_in_sync(): if not self._force_sync and self._rpc.region_in_sync():
LOG.info(_('OpenStack and EOS are in sync!')) LOG.info(_LI('OpenStack and EOS are in sync!'))
return return
except arista_exc.AristaRpcError: except arista_exc.AristaRpcError:
LOG.warning(EOS_UNREACHABLE_MSG) LOG.warning(EOS_UNREACHABLE_MSG)
@ -607,10 +605,10 @@ class SyncService(object):
# No tenants configured in Neutron. Clear all EOS state # No tenants configured in Neutron. Clear all EOS state
try: try:
self._rpc.delete_this_region() self._rpc.delete_this_region()
msg = _('No Tenants configured in Neutron DB. But %d ' LOG.info(_LI('No Tenants configured in Neutron DB. But %d '
'tenants discovered in EOS during synchronization.' 'tenants discovered in EOS during '
'Entire EOS region is cleared') % len(eos_tenants) 'synchronization. Entire EOS region is cleared'),
LOG.info(msg) len(eos_tenants))
# Re-register with EOS so that the timestamp is updated. # Re-register with EOS so that the timestamp is updated.
self._rpc.register_with_eos() self._rpc.register_with_eos()
# Region has been completely cleaned. So there is nothing to # Region has been completely cleaned. So there is nothing to
@ -772,9 +770,8 @@ class AristaDriver(driver_api.MechanismDriver):
LOG.info(EOS_UNREACHABLE_MSG) LOG.info(EOS_UNREACHABLE_MSG)
raise ml2_exc.MechanismDriverError() raise ml2_exc.MechanismDriverError()
else: else:
msg = _('Network %s is not created as it is not found in' LOG.info(_LI('Network %s is not created as it is not found in '
'Arista DB') % network_id 'Arista DB'), network_id)
LOG.info(msg)
def update_network_precommit(self, context): def update_network_precommit(self, context):
"""At the moment we only support network name change """At the moment we only support network name change
@ -786,8 +783,7 @@ class AristaDriver(driver_api.MechanismDriver):
new_network = context.current new_network = context.current
orig_network = context.original orig_network = context.original
if new_network['name'] != orig_network['name']: if new_network['name'] != orig_network['name']:
msg = _('Network name changed to %s') % new_network['name'] LOG.info(_LI('Network name changed to %s'), new_network['name'])
LOG.info(msg)
def update_network_postcommit(self, context): def update_network_postcommit(self, context):
"""At the moment we only support network name change """At the moment we only support network name change
@ -814,9 +810,8 @@ class AristaDriver(driver_api.MechanismDriver):
LOG.info(EOS_UNREACHABLE_MSG) LOG.info(EOS_UNREACHABLE_MSG)
raise ml2_exc.MechanismDriverError() raise ml2_exc.MechanismDriverError()
else: else:
msg = _('Network %s is not updated as it is not found in' LOG.info(_LI('Network %s is not updated as it is not found'
'Arista DB') % network_id ' in Arista DB'), network_id)
LOG.info(msg)
def delete_network_precommit(self, context): def delete_network_precommit(self, context):
"""Delete the network infromation from the DB.""" """Delete the network infromation from the DB."""
@ -906,9 +901,8 @@ class AristaDriver(driver_api.MechanismDriver):
LOG.info(EOS_UNREACHABLE_MSG) LOG.info(EOS_UNREACHABLE_MSG)
raise ml2_exc.MechanismDriverError() raise ml2_exc.MechanismDriverError()
else: else:
msg = _('VM %s is not created as it is not found in ' LOG.info(_LI('VM %s is not created as it is not found in '
'Arista DB') % device_id 'Arista DB'), device_id)
LOG.info(msg)
def update_port_precommit(self, context): def update_port_precommit(self, context):
"""Update the name of a given port. """Update the name of a given port.
@ -921,8 +915,7 @@ class AristaDriver(driver_api.MechanismDriver):
new_port = context.current new_port = context.current
orig_port = context.original orig_port = context.original
if new_port['name'] != orig_port['name']: if new_port['name'] != orig_port['name']:
msg = _('Port name changed to %s') % new_port['name'] LOG.info(_LI('Port name changed to %s'), new_port['name'])
LOG.info(msg)
def update_port_postcommit(self, context): def update_port_postcommit(self, context):
"""Update the name of a given port in EOS. """Update the name of a given port in EOS.
@ -971,9 +964,8 @@ class AristaDriver(driver_api.MechanismDriver):
LOG.info(EOS_UNREACHABLE_MSG) LOG.info(EOS_UNREACHABLE_MSG)
raise ml2_exc.MechanismDriverError() raise ml2_exc.MechanismDriverError()
else: else:
msg = _('VM %s is not updated as it is not found in ' LOG.info(_LI('VM %s is not updated as it is not found in '
'Arista DB') % device_id 'Arista DB'), device_id)
LOG.info(msg)
def delete_port_precommit(self, context): def delete_port_precommit(self, context):
"""Delete information about a VM and host from the DB.""" """Delete information about a VM and host from the DB."""

View File

@ -18,6 +18,7 @@
from oslo.config import cfg from oslo.config import cfg
from neutron.openstack.common.gettextutils import _LE, _LI
from neutron.openstack.common import importutils from neutron.openstack.common import importutils
from neutron.openstack.common import log as logging from neutron.openstack.common import log as logging
from neutron.plugins.ml2 import driver_api from neutron.plugins.ml2 import driver_api
@ -89,9 +90,9 @@ class BrocadeMechanism(driver_api.MechanismDriver):
self._switch['password']) self._switch['password'])
if virtual_fabric_enabled: if virtual_fabric_enabled:
LOG.debug(_("Virtual Fabric: enabled")) LOG.debug("Virtual Fabric: enabled")
else: else:
LOG.debug(_("Virtual Fabric: not enabled")) LOG.debug("Virtual Fabric: not enabled")
self.set_features_enabled(osversion, virtual_fabric_enabled) self.set_features_enabled(osversion, virtual_fabric_enabled)
@ -143,14 +144,14 @@ class BrocadeMechanism(driver_api.MechanismDriver):
segment_id, network_type, tenant_id) segment_id, network_type, tenant_id)
except Exception: except Exception:
LOG.exception( LOG.exception(
_("Brocade Mechanism: failed to create network in db")) _LE("Brocade Mechanism: failed to create network in db"))
raise Exception( raise Exception(
_("Brocade Mechanism: create_network_precommit failed")) _("Brocade Mechanism: create_network_precommit failed"))
LOG.info(_("create network (precommit): %(network_id)s " LOG.info(_LI("create network (precommit): %(network_id)s "
"of network type = %(network_type)s " "of network type = %(network_type)s "
"with vlan = %(vlan_id)s " "with vlan = %(vlan_id)s "
"for tenant %(tenant_id)s"), "for tenant %(tenant_id)s"),
{'network_id': network_id, {'network_id': network_id,
'network_type': network_type, 'network_type': network_type,
'vlan_id': vlan_id, 'vlan_id': vlan_id,
@ -159,7 +160,7 @@ class BrocadeMechanism(driver_api.MechanismDriver):
def create_network_postcommit(self, mech_context): def create_network_postcommit(self, mech_context):
"""Create Network as a portprofile on the switch.""" """Create Network as a portprofile on the switch."""
LOG.debug(_("create_network_postcommit: called")) LOG.debug("create_network_postcommit: called")
network = mech_context.current network = mech_context.current
# use network_id to get the network attributes # use network_id to get the network attributes
@ -179,24 +180,24 @@ class BrocadeMechanism(driver_api.MechanismDriver):
self._switch['password'], self._switch['password'],
vlan_id) vlan_id)
except Exception: except Exception:
LOG.exception(_("Brocade NOS driver: failed in create network")) LOG.exception(_LE("Brocade NOS driver: failed in create network"))
brocade_db.delete_network(context, network_id) brocade_db.delete_network(context, network_id)
raise Exception( raise Exception(
_("Brocade Mechanism: create_network_postcommmit failed")) _("Brocade Mechanism: create_network_postcommmit failed"))
LOG.info(_("created network (postcommit): %(network_id)s" LOG.info(_LI("created network (postcommit): %(network_id)s"
" of network type = %(network_type)s" " of network type = %(network_type)s"
" with vlan = %(vlan_id)s" " with vlan = %(vlan_id)s"
" for tenant %(tenant_id)s"), " for tenant %(tenant_id)s"),
{'network_id': network_id, {'network_id': network_id,
'network_type': network_type, 'network_type': network_type,
'vlan_id': vlan_id, 'vlan_id': vlan_id,
'tenant_id': tenant_id}) 'tenant_id': tenant_id})
def delete_network_precommit(self, mech_context): def delete_network_precommit(self, mech_context):
"""Delete Network from the plugin specific database table.""" """Delete Network from the plugin specific database table."""
LOG.debug(_("delete_network_precommit: called")) LOG.debug("delete_network_precommit: called")
network = mech_context.current network = mech_context.current
network_id = network['id'] network_id = network['id']
@ -209,23 +210,23 @@ class BrocadeMechanism(driver_api.MechanismDriver):
brocade_db.delete_network(context, network_id) brocade_db.delete_network(context, network_id)
except Exception: except Exception:
LOG.exception( LOG.exception(
_("Brocade Mechanism: failed to delete network in db")) _LE("Brocade Mechanism: failed to delete network in db"))
raise Exception( raise Exception(
_("Brocade Mechanism: delete_network_precommit failed")) _("Brocade Mechanism: delete_network_precommit failed"))
LOG.info(_("delete network (precommit): %(network_id)s" LOG.info(_LI("delete network (precommit): %(network_id)s"
" with vlan = %(vlan_id)s" " with vlan = %(vlan_id)s"
" for tenant %(tenant_id)s"), " for tenant %(tenant_id)s"),
{'network_id': network_id, {'network_id': network_id,
'vlan_id': vlan_id, 'vlan_id': vlan_id,
'tenant_id': tenant_id}) 'tenant_id': tenant_id})
def delete_network_postcommit(self, mech_context): def delete_network_postcommit(self, mech_context):
"""Delete network which translates to removng portprofile """Delete network which translates to removng portprofile
from the switch. from the switch.
""" """
LOG.debug(_("delete_network_postcommit: called")) LOG.debug("delete_network_postcommit: called")
network = mech_context.current network = mech_context.current
network_id = network['id'] network_id = network['id']
vlan_id = network['provider:segmentation_id'] vlan_id = network['provider:segmentation_id']
@ -237,17 +238,17 @@ class BrocadeMechanism(driver_api.MechanismDriver):
self._switch['password'], self._switch['password'],
vlan_id) vlan_id)
except Exception: except Exception:
LOG.exception(_("Brocade NOS driver: failed to delete network")) LOG.exception(_LE("Brocade NOS driver: failed to delete network"))
raise Exception( raise Exception(
_("Brocade switch exception, " _("Brocade switch exception, "
"delete_network_postcommit failed")) "delete_network_postcommit failed"))
LOG.info(_("delete network (postcommit): %(network_id)s" LOG.info(_LI("delete network (postcommit): %(network_id)s"
" with vlan = %(vlan_id)s" " with vlan = %(vlan_id)s"
" for tenant %(tenant_id)s"), " for tenant %(tenant_id)s"),
{'network_id': network_id, {'network_id': network_id,
'vlan_id': vlan_id, 'vlan_id': vlan_id,
'tenant_id': tenant_id}) 'tenant_id': tenant_id})
def update_network_precommit(self, mech_context): def update_network_precommit(self, mech_context):
"""Noop now, it is left here for future.""" """Noop now, it is left here for future."""
@ -260,7 +261,7 @@ class BrocadeMechanism(driver_api.MechanismDriver):
def create_port_precommit(self, mech_context): def create_port_precommit(self, mech_context):
"""Create logical port on the switch (db update).""" """Create logical port on the switch (db update)."""
LOG.debug(_("create_port_precommit: called")) LOG.debug("create_port_precommit: called")
port = mech_context.current port = mech_context.current
port_id = port['id'] port_id = port['id']
@ -278,14 +279,15 @@ class BrocadeMechanism(driver_api.MechanismDriver):
None, None,
vlan_id, tenant_id, admin_state_up) vlan_id, tenant_id, admin_state_up)
except Exception: except Exception:
LOG.exception(_("Brocade Mechanism: failed to create port in db")) LOG.exception(_LE("Brocade Mechanism: failed to create port"
" in db"))
raise Exception( raise Exception(
_("Brocade Mechanism: create_port_precommit failed")) _("Brocade Mechanism: create_port_precommit failed"))
def create_port_postcommit(self, mech_context): def create_port_postcommit(self, mech_context):
"""Associate the assigned MAC address to the portprofile.""" """Associate the assigned MAC address to the portprofile."""
LOG.debug(_("create_port_postcommit: called")) LOG.debug("create_port_postcommit: called")
port = mech_context.current port = mech_context.current
port_id = port['id'] port_id = port['id']
@ -309,21 +311,21 @@ class BrocadeMechanism(driver_api.MechanismDriver):
mac) mac)
except Exception: except Exception:
LOG.exception( LOG.exception(
_("Brocade NOS driver: failed to associate mac %s") _LE("Brocade NOS driver: failed to associate mac %s"),
% interface_mac) interface_mac)
raise Exception( raise Exception(
_("Brocade switch exception: create_port_postcommit failed")) _("Brocade switch exception: create_port_postcommit failed"))
LOG.info( LOG.info(
_("created port (postcommit): port_id=%(port_id)s" _LI("created port (postcommit): port_id=%(port_id)s"
" network_id=%(network_id)s tenant_id=%(tenant_id)s"), " network_id=%(network_id)s tenant_id=%(tenant_id)s"),
{'port_id': port_id, {'port_id': port_id,
'network_id': network_id, 'tenant_id': tenant_id}) 'network_id': network_id, 'tenant_id': tenant_id})
def delete_port_precommit(self, mech_context): def delete_port_precommit(self, mech_context):
"""Delete logical port on the switch (db update).""" """Delete logical port on the switch (db update)."""
LOG.debug(_("delete_port_precommit: called")) LOG.debug("delete_port_precommit: called")
port = mech_context.current port = mech_context.current
port_id = port['id'] port_id = port['id']
@ -332,14 +334,15 @@ class BrocadeMechanism(driver_api.MechanismDriver):
try: try:
brocade_db.delete_port(context, port_id) brocade_db.delete_port(context, port_id)
except Exception: except Exception:
LOG.exception(_("Brocade Mechanism: failed to delete port in db")) LOG.exception(_LE("Brocade Mechanism: failed to delete port"
" in db"))
raise Exception( raise Exception(
_("Brocade Mechanism: delete_port_precommit failed")) _("Brocade Mechanism: delete_port_precommit failed"))
def delete_port_postcommit(self, mech_context): def delete_port_postcommit(self, mech_context):
"""Dissociate MAC address from the portprofile.""" """Dissociate MAC address from the portprofile."""
LOG.debug(_("delete_port_postcommit: called")) LOG.debug("delete_port_postcommit: called")
port = mech_context.current port = mech_context.current
port_id = port['id'] port_id = port['id']
network_id = port['network_id'] network_id = port['network_id']
@ -363,48 +366,48 @@ class BrocadeMechanism(driver_api.MechanismDriver):
mac) mac)
except Exception: except Exception:
LOG.exception( LOG.exception(
_("Brocade NOS driver: failed to dissociate MAC %s") % _LE("Brocade NOS driver: failed to dissociate MAC %s"),
interface_mac) interface_mac)
raise Exception( raise Exception(
_("Brocade switch exception, delete_port_postcommit failed")) _("Brocade switch exception, delete_port_postcommit failed"))
LOG.info( LOG.info(
_("delete port (postcommit): port_id=%(port_id)s" _LI("delete port (postcommit): port_id=%(port_id)s"
" network_id=%(network_id)s tenant_id=%(tenant_id)s"), " network_id=%(network_id)s tenant_id=%(tenant_id)s"),
{'port_id': port_id, {'port_id': port_id,
'network_id': network_id, 'tenant_id': tenant_id}) 'network_id': network_id, 'tenant_id': tenant_id})
def update_port_precommit(self, mech_context): def update_port_precommit(self, mech_context):
"""Noop now, it is left here for future.""" """Noop now, it is left here for future."""
LOG.debug(_("update_port_precommit(self: called")) LOG.debug("update_port_precommit(self: called")
def update_port_postcommit(self, mech_context): def update_port_postcommit(self, mech_context):
"""Noop now, it is left here for future.""" """Noop now, it is left here for future."""
LOG.debug(_("update_port_postcommit: called")) LOG.debug("update_port_postcommit: called")
def create_subnet_precommit(self, mech_context): def create_subnet_precommit(self, mech_context):
"""Noop now, it is left here for future.""" """Noop now, it is left here for future."""
LOG.debug(_("create_subnetwork_precommit: called")) LOG.debug("create_subnetwork_precommit: called")
def create_subnet_postcommit(self, mech_context): def create_subnet_postcommit(self, mech_context):
"""Noop now, it is left here for future.""" """Noop now, it is left here for future."""
LOG.debug(_("create_subnetwork_postcommit: called")) LOG.debug("create_subnetwork_postcommit: called")
def delete_subnet_precommit(self, mech_context): def delete_subnet_precommit(self, mech_context):
"""Noop now, it is left here for future.""" """Noop now, it is left here for future."""
LOG.debug(_("delete_subnetwork_precommit: called")) LOG.debug("delete_subnetwork_precommit: called")
def delete_subnet_postcommit(self, mech_context): def delete_subnet_postcommit(self, mech_context):
"""Noop now, it is left here for future.""" """Noop now, it is left here for future."""
LOG.debug(_("delete_subnetwork_postcommit: called")) LOG.debug("delete_subnetwork_postcommit: called")
def update_subnet_precommit(self, mech_context): def update_subnet_precommit(self, mech_context):
"""Noop now, it is left here for future.""" """Noop now, it is left here for future."""
LOG.debug(_("update_subnet_precommit(self: called")) LOG.debug("update_subnet_precommit(self: called")
def update_subnet_postcommit(self, mech_context): def update_subnet_postcommit(self, mech_context):
"""Noop now, it is left here for future.""" """Noop now, it is left here for future."""
LOG.debug(_("update_subnet_postcommit: called")) LOG.debug("update_subnet_postcommit: called")
@staticmethod @staticmethod
def mac_reformat_62to34(interface_mac): def mac_reformat_62to34(interface_mac):

View File

@ -22,6 +22,7 @@ from ncclient import manager
from xml.etree import ElementTree from xml.etree import ElementTree
from neutron.openstack.common import excutils from neutron.openstack.common import excutils
from neutron.openstack.common.gettextutils import _LE
from neutron.openstack.common import log as logging from neutron.openstack.common import log as logging
from neutron.plugins.ml2.drivers.brocade.nos import nctemplates as template from neutron.plugins.ml2.drivers.brocade.nos import nctemplates as template
@ -81,9 +82,9 @@ class NOSdriver():
except Exception: except Exception:
with excutils.save_and_reraise_exception(): with excutils.save_and_reraise_exception():
LOG.exception(_("Connect failed to switch")) LOG.exception(_LE("Connect failed to switch"))
LOG.debug(_("Connect success to host %(host)s:%(ssh_port)d"), LOG.debug("Connect success to host %(host)s:%(ssh_port)d",
dict(host=host, ssh_port=SSH_PORT)) dict(host=host, ssh_port=SSH_PORT))
return self.mgr return self.mgr
@ -100,7 +101,7 @@ class NOSdriver():
return self.nos_version_request(mgr) return self.nos_version_request(mgr)
except Exception: except Exception:
with excutils.save_and_reraise_exception(): with excutils.save_and_reraise_exception():
LOG.exception(_("NETCONF error")) LOG.exception(_LE("NETCONF error"))
self.close_session() self.close_session()
def is_virtual_fabric_enabled(self, host, username, password): def is_virtual_fabric_enabled(self, host, username, password):
@ -110,7 +111,7 @@ class NOSdriver():
return (self.virtual_fabric_info(mgr) == "enabled") return (self.virtual_fabric_info(mgr) == "enabled")
except Exception: except Exception:
with excutils.save_and_reraise_exception(): with excutils.save_and_reraise_exception():
LOG.exception(_("NETCONF error")) LOG.exception(_LE("NETCONF error"))
self.close_session() self.close_session()
def create_network(self, host, username, password, net_id): def create_network(self, host, username, password, net_id):
@ -138,7 +139,7 @@ class NOSdriver():
self.activate_port_profile(mgr, name) self.activate_port_profile(mgr, name)
except Exception: except Exception:
with excutils.save_and_reraise_exception(): with excutils.save_and_reraise_exception():
LOG.exception(_("NETCONF error")) LOG.exception(_LE("NETCONF error"))
self.close_session() self.close_session()
def delete_network(self, host, username, password, net_id): def delete_network(self, host, username, password, net_id):
@ -155,7 +156,7 @@ class NOSdriver():
self.delete_vlan_interface(mgr, net_id) self.delete_vlan_interface(mgr, net_id)
except Exception: except Exception:
with excutils.save_and_reraise_exception(): with excutils.save_and_reraise_exception():
LOG.exception(_("NETCONF error")) LOG.exception(_LE("NETCONF error"))
self.close_session() self.close_session()
def associate_mac_to_network(self, host, username, password, def associate_mac_to_network(self, host, username, password,
@ -168,7 +169,7 @@ class NOSdriver():
self.associate_mac_to_port_profile(mgr, name, mac) self.associate_mac_to_port_profile(mgr, name, mac)
except Exception: except Exception:
with excutils.save_and_reraise_exception(): with excutils.save_and_reraise_exception():
LOG.exception(_("NETCONF error")) LOG.exception(_LE("NETCONF error"))
self.close_session() self.close_session()
def dissociate_mac_from_network(self, host, username, password, def dissociate_mac_from_network(self, host, username, password,
@ -181,7 +182,7 @@ class NOSdriver():
self.dissociate_mac_from_port_profile(mgr, name, mac) self.dissociate_mac_from_port_profile(mgr, name, mac)
except Exception: except Exception:
with excutils.save_and_reraise_exception(): with excutils.save_and_reraise_exception():
LOG.exception(_("NETCONF error")) LOG.exception(_LE("NETCONF error"))
self.close_session() self.close_session()
def create_vlan_interface(self, mgr, vlan_id): def create_vlan_interface(self, mgr, vlan_id):
@ -324,7 +325,7 @@ class NOSdriver():
self.activate_svi(mgr, rbridge_id, vlan_id) self.activate_svi(mgr, rbridge_id, vlan_id)
except Exception as ex: except Exception as ex:
with excutils.save_and_reraise_exception(): with excutils.save_and_reraise_exception():
LOG.exception(_("NETCONF error: %s"), ex) LOG.exception(_LE("NETCONF error: %s"), ex)
self.close_session() self.close_session()
def delete_svi(self, host, username, password, def delete_svi(self, host, username, password,
@ -335,7 +336,7 @@ class NOSdriver():
self.remove_svi(mgr, rbridge_id, vlan_id) self.remove_svi(mgr, rbridge_id, vlan_id)
except Exception as ex: except Exception as ex:
with excutils.save_and_reraise_exception(): with excutils.save_and_reraise_exception():
LOG.exception(_("NETCONF error: %s"), ex) LOG.exception(_LE("NETCONF error: %s"), ex)
self.close_session() self.close_session()
def create_router(self, host, username, password, rbridge_id, router_id): def create_router(self, host, username, password, rbridge_id, router_id):
@ -348,7 +349,7 @@ class NOSdriver():
self.create_vrf(mgr, rbridge_id, vrf_name) self.create_vrf(mgr, rbridge_id, vrf_name)
except Exception: except Exception:
with excutils.save_and_reraise_exception(): with excutils.save_and_reraise_exception():
LOG.exception(_("NETCONF error")) LOG.exception(_LE("NETCONF error"))
self.close_session() self.close_session()
try: try:
# For Nos5.0.0 # For Nos5.0.0
@ -367,7 +368,7 @@ class NOSdriver():
vrf_name) vrf_name)
except Exception: except Exception:
with excutils.save_and_reraise_exception(): with excutils.save_and_reraise_exception():
LOG.exception(_("NETCONF error")) LOG.exception(_LE("NETCONF error"))
self.close_session() self.close_session()
ctxt.reraise = False ctxt.reraise = False
@ -381,7 +382,7 @@ class NOSdriver():
self.delete_vrf(mgr, rbridge_id, vrf_name) self.delete_vrf(mgr, rbridge_id, vrf_name)
except Exception: except Exception:
with excutils.save_and_reraise_exception(): with excutils.save_and_reraise_exception():
LOG.exception(_("NETCONF error")) LOG.exception(_LE("NETCONF error"))
self.close_session() self.close_session()
def bind_vrf_to_svi(self, host, username, password, rbridge_id, def bind_vrf_to_svi(self, host, username, password, rbridge_id,
@ -394,7 +395,7 @@ class NOSdriver():
self.add_vrf_to_svi(mgr, rbridge_id, vlan_id, vrf_name) self.add_vrf_to_svi(mgr, rbridge_id, vlan_id, vrf_name)
except Exception: except Exception:
with excutils.save_and_reraise_exception(): with excutils.save_and_reraise_exception():
LOG.exception(_("NETCONF error")) LOG.exception(_LE("NETCONF error"))
self.close_session() self.close_session()
def unbind_vrf_to_svi(self, host, username, password, rbridge_id, def unbind_vrf_to_svi(self, host, username, password, rbridge_id,
@ -407,7 +408,7 @@ class NOSdriver():
self.delete_vrf_from_svi(mgr, rbridge_id, vlan_id, vrf_name) self.delete_vrf_from_svi(mgr, rbridge_id, vlan_id, vrf_name)
except Exception: except Exception:
with excutils.save_and_reraise_exception(): with excutils.save_and_reraise_exception():
LOG.exception(_("NETCONF error")) LOG.exception(_LE("NETCONF error"))
self.close_session() self.close_session()
def create_vrf(self, mgr, rbridge_id, vrf_name): def create_vrf(self, mgr, rbridge_id, vrf_name):

View File

@ -42,7 +42,7 @@ class CiscoNexusMechanismDriver(api.MechanismDriver):
# Extract configuration parameters from the configuration file. # Extract configuration parameters from the configuration file.
self._nexus_switches = conf.ML2MechCiscoConfig.nexus_dict self._nexus_switches = conf.ML2MechCiscoConfig.nexus_dict
LOG.debug(_("nexus_switches found = %s"), self._nexus_switches) LOG.debug("nexus_switches found = %s", self._nexus_switches)
self.driver = nexus_network_driver.CiscoNexusDriver() self.driver = nexus_network_driver.CiscoNexusDriver()
@ -117,12 +117,12 @@ class CiscoNexusMechanismDriver(api.MechanismDriver):
previous_bindings = [row for row in all_bindings previous_bindings = [row for row in all_bindings
if row.instance_id != device_id] if row.instance_id != device_id]
if previous_bindings or (switch_ip in vlan_already_created): if previous_bindings or (switch_ip in vlan_already_created):
LOG.debug("Nexus: trunk vlan %s"), vlan_name LOG.debug("Nexus: trunk vlan %s", vlan_name)
self.driver.enable_vlan_on_trunk_int(switch_ip, vlan_id, self.driver.enable_vlan_on_trunk_int(switch_ip, vlan_id,
intf_type, nexus_port) intf_type, nexus_port)
else: else:
vlan_already_created.append(switch_ip) vlan_already_created.append(switch_ip)
LOG.debug("Nexus: create & trunk vlan %s"), vlan_name LOG.debug("Nexus: create & trunk vlan %s", vlan_name)
self.driver.create_and_trunk_vlan( self.driver.create_and_trunk_vlan(
switch_ip, vlan_id, vlan_name, intf_type, nexus_port) switch_ip, vlan_id, vlan_name, intf_type, nexus_port)

View File

@ -17,6 +17,7 @@
import sqlalchemy.orm.exc as sa_exc import sqlalchemy.orm.exc as sa_exc
import neutron.db.api as db import neutron.db.api as db
from neutron.openstack.common.gettextutils import _LW
from neutron.openstack.common import log as logging from neutron.openstack.common import log as logging
from neutron.plugins.ml2.drivers.cisco.nexus import exceptions as c_exc from neutron.plugins.ml2.drivers.cisco.nexus import exceptions as c_exc
from neutron.plugins.ml2.drivers.cisco.nexus import nexus_models_v2 from neutron.plugins.ml2.drivers.cisco.nexus import nexus_models_v2
@ -27,7 +28,7 @@ LOG = logging.getLogger(__name__)
def get_nexusport_binding(port_id, vlan_id, switch_ip, instance_id): def get_nexusport_binding(port_id, vlan_id, switch_ip, instance_id):
"""Lists a nexusport binding.""" """Lists a nexusport binding."""
LOG.debug(_("get_nexusport_binding() called")) LOG.debug("get_nexusport_binding() called")
return _lookup_all_nexus_bindings(port_id=port_id, return _lookup_all_nexus_bindings(port_id=port_id,
vlan_id=vlan_id, vlan_id=vlan_id,
switch_ip=switch_ip, switch_ip=switch_ip,
@ -36,13 +37,13 @@ def get_nexusport_binding(port_id, vlan_id, switch_ip, instance_id):
def get_nexusvlan_binding(vlan_id, switch_ip): def get_nexusvlan_binding(vlan_id, switch_ip):
"""Lists a vlan and switch binding.""" """Lists a vlan and switch binding."""
LOG.debug(_("get_nexusvlan_binding() called")) LOG.debug("get_nexusvlan_binding() called")
return _lookup_all_nexus_bindings(vlan_id=vlan_id, switch_ip=switch_ip) return _lookup_all_nexus_bindings(vlan_id=vlan_id, switch_ip=switch_ip)
def add_nexusport_binding(port_id, vlan_id, switch_ip, instance_id): def add_nexusport_binding(port_id, vlan_id, switch_ip, instance_id):
"""Adds a nexusport binding.""" """Adds a nexusport binding."""
LOG.debug(_("add_nexusport_binding() called")) LOG.debug("add_nexusport_binding() called")
session = db.get_session() session = db.get_session()
binding = nexus_models_v2.NexusPortBinding(port_id=port_id, binding = nexus_models_v2.NexusPortBinding(port_id=port_id,
vlan_id=vlan_id, vlan_id=vlan_id,
@ -55,7 +56,7 @@ def add_nexusport_binding(port_id, vlan_id, switch_ip, instance_id):
def remove_nexusport_binding(port_id, vlan_id, switch_ip, instance_id): def remove_nexusport_binding(port_id, vlan_id, switch_ip, instance_id):
"""Removes a nexusport binding.""" """Removes a nexusport binding."""
LOG.debug(_("remove_nexusport_binding() called")) LOG.debug("remove_nexusport_binding() called")
session = db.get_session() session = db.get_session()
binding = _lookup_all_nexus_bindings(session=session, binding = _lookup_all_nexus_bindings(session=session,
vlan_id=vlan_id, vlan_id=vlan_id,
@ -71,9 +72,9 @@ def remove_nexusport_binding(port_id, vlan_id, switch_ip, instance_id):
def update_nexusport_binding(port_id, new_vlan_id): def update_nexusport_binding(port_id, new_vlan_id):
"""Updates nexusport binding.""" """Updates nexusport binding."""
if not new_vlan_id: if not new_vlan_id:
LOG.warning(_("update_nexusport_binding called with no vlan")) LOG.warning(_LW("update_nexusport_binding called with no vlan"))
return return
LOG.debug(_("update_nexusport_binding called")) LOG.debug("update_nexusport_binding called")
session = db.get_session() session = db.get_session()
binding = _lookup_one_nexus_binding(session=session, port_id=port_id) binding = _lookup_one_nexus_binding(session=session, port_id=port_id)
binding.vlan_id = new_vlan_id binding.vlan_id = new_vlan_id
@ -84,14 +85,14 @@ def update_nexusport_binding(port_id, new_vlan_id):
def get_nexusvm_bindings(vlan_id, instance_id): def get_nexusvm_bindings(vlan_id, instance_id):
"""Lists nexusvm bindings.""" """Lists nexusvm bindings."""
LOG.debug(_("get_nexusvm_bindings() called")) LOG.debug("get_nexusvm_bindings() called")
return _lookup_all_nexus_bindings(instance_id=instance_id, return _lookup_all_nexus_bindings(instance_id=instance_id,
vlan_id=vlan_id) vlan_id=vlan_id)
def get_port_vlan_switch_binding(port_id, vlan_id, switch_ip): def get_port_vlan_switch_binding(port_id, vlan_id, switch_ip):
"""Lists nexusvm bindings.""" """Lists nexusvm bindings."""
LOG.debug(_("get_port_vlan_switch_binding() called")) LOG.debug("get_port_vlan_switch_binding() called")
return _lookup_all_nexus_bindings(port_id=port_id, return _lookup_all_nexus_bindings(port_id=port_id,
switch_ip=switch_ip, switch_ip=switch_ip,
vlan_id=vlan_id) vlan_id=vlan_id)
@ -99,8 +100,8 @@ def get_port_vlan_switch_binding(port_id, vlan_id, switch_ip):
def get_port_switch_bindings(port_id, switch_ip): def get_port_switch_bindings(port_id, switch_ip):
"""List all vm/vlan bindings on a Nexus switch port.""" """List all vm/vlan bindings on a Nexus switch port."""
LOG.debug(_("get_port_switch_bindings() called, " LOG.debug("get_port_switch_bindings() called, "
"port:'%(port_id)s', switch:'%(switch_ip)s'"), "port:'%(port_id)s', switch:'%(switch_ip)s'",
{'port_id': port_id, 'switch_ip': switch_ip}) {'port_id': port_id, 'switch_ip': switch_ip})
try: try:
return _lookup_all_nexus_bindings(port_id=port_id, return _lookup_all_nexus_bindings(port_id=port_id,

View File

@ -154,7 +154,7 @@ class CiscoNexusDriver(object):
"""Build the VLAN config string xml snippet to be used.""" """Build the VLAN config string xml snippet to be used."""
confstr = snippet % (intf_type, interface, vlanid, intf_type) confstr = snippet % (intf_type, interface, vlanid, intf_type)
confstr = self.create_xml_snippet(confstr) confstr = self.create_xml_snippet(confstr)
LOG.debug(_("NexusDriver: %s"), confstr) LOG.debug("NexusDriver: %s", confstr)
return confstr return confstr
def enable_vlan_on_trunk_int(self, nexus_host, vlanid, intf_type, def enable_vlan_on_trunk_int(self, nexus_host, vlanid, intf_type,
@ -196,7 +196,7 @@ class CiscoNexusDriver(object):
intf_type, nexus_port): intf_type, nexus_port):
"""Create VLAN and trunk it on the specified ports.""" """Create VLAN and trunk it on the specified ports."""
self.create_vlan(nexus_host, vlan_id, vlan_name) self.create_vlan(nexus_host, vlan_id, vlan_name)
LOG.debug(_("NexusDriver created VLAN: %s"), vlan_id) LOG.debug("NexusDriver created VLAN: %s", vlan_id)
if nexus_port: if nexus_port:
self.enable_vlan_on_trunk_int(nexus_host, vlan_id, intf_type, self.enable_vlan_on_trunk_int(nexus_host, vlan_id, intf_type,
nexus_port) nexus_port)

View File

@ -16,6 +16,7 @@
from neutron.common import constants as n_const from neutron.common import constants as n_const
from neutron.common import log from neutron.common import log
from neutron.extensions import portbindings from neutron.extensions import portbindings
from neutron.openstack.common.gettextutils import _LI
from neutron.openstack.common import log as logging from neutron.openstack.common import log as logging
from neutron.plugins.common import constants from neutron.plugins.common import constants
from neutron.plugins.ml2 import driver_api as api from neutron.plugins.ml2 import driver_api as api
@ -35,7 +36,7 @@ class FslsdnMechanismDriver(api.MechanismDriver):
self.vif_type = portbindings.VIF_TYPE_OVS self.vif_type = portbindings.VIF_TYPE_OVS
self.vif_details = {portbindings.CAP_PORT_FILTER: True} self.vif_details = {portbindings.CAP_PORT_FILTER: True}
LOG.info(_("Initializing CRD client... ")) LOG.info(_LI("Initializing CRD client... "))
self._crdclient = config.get_crdclient() self._crdclient = config.get_crdclient()
# Network Management # Network Management

View File

@ -16,6 +16,7 @@
from oslo.db import exception as db_exc from oslo.db import exception as db_exc
from neutron.common import exceptions as exc from neutron.common import exceptions as exc
from neutron.openstack.common.gettextutils import _LW
from neutron.openstack.common import log from neutron.openstack.common import log
from neutron.plugins.ml2 import driver_api as api from neutron.plugins.ml2 import driver_api as api
@ -137,7 +138,7 @@ class TypeDriverHelper(api.TypeDriver):
{"type": network_type, "attempt": attempt, {"type": network_type, "attempt": attempt,
"segment": raw_segment}) "segment": raw_segment})
LOG.warning(_("Allocate %(type)s segment from pool failed " LOG.warning(_LW("Allocate %(type)s segment from pool failed "
"after %(number)s failed attempts"), "after %(number)s failed attempts"),
{"type": network_type, "number": DB_MAX_ATTEMPTS}) {"type": network_type, "number": DB_MAX_ATTEMPTS})
raise exc.NoNetworkFoundInMaximumAllowedAttempts() raise exc.NoNetworkFoundInMaximumAllowedAttempts()

View File

@ -18,6 +18,7 @@ from oslo.config import cfg
from neutron.common import constants as const from neutron.common import constants as const
from neutron import context as n_context from neutron import context as n_context
from neutron.db import api as db_api from neutron.db import api as db_api
from neutron.openstack.common.gettextutils import _LW
from neutron.openstack.common import log as logging from neutron.openstack.common import log as logging
from neutron.plugins.ml2 import driver_api as api from neutron.plugins.ml2 import driver_api as api
from neutron.plugins.ml2.drivers.l2pop import config # noqa from neutron.plugins.ml2.drivers.l2pop import config # noqa
@ -35,7 +36,7 @@ class L2populationMechanismDriver(api.MechanismDriver,
self.L2populationAgentNotify = l2pop_rpc.L2populationAgentNotifyAPI() self.L2populationAgentNotify = l2pop_rpc.L2populationAgentNotifyAPI()
def initialize(self): def initialize(self):
LOG.debug(_("Experimental L2 population driver")) LOG.debug("Experimental L2 population driver")
self.rpc_ctx = n_context.get_admin_context_without_session() self.rpc_ctx = n_context.get_admin_context_without_session()
self.migrated_ports = {} self.migrated_ports = {}
@ -151,14 +152,14 @@ class L2populationMechanismDriver(api.MechanismDriver,
agent_ip = self.get_agent_ip(agent) agent_ip = self.get_agent_ip(agent)
if not agent_ip: if not agent_ip:
LOG.warning(_("Unable to retrieve the agent ip, check the agent " LOG.warning(_LW("Unable to retrieve the agent ip, check the agent "
"configuration.")) "configuration."))
return return
segment = context.bound_segment segment = context.bound_segment
if not segment: if not segment:
LOG.warning(_("Port %(port)s updated by agent %(agent)s " LOG.warning(_LW("Port %(port)s updated by agent %(agent)s "
"isn't bound to any segment"), "isn't bound to any segment"),
{'port': port['id'], 'agent': agent}) {'port': port['id'], 'agent': agent})
return return
@ -210,8 +211,8 @@ class L2populationMechanismDriver(api.MechanismDriver,
ip = self.get_agent_ip(agent) ip = self.get_agent_ip(agent)
if not ip: if not ip:
LOG.debug(_("Unable to retrieve the agent ip, check " LOG.debug("Unable to retrieve the agent ip, check "
"the agent %(agent_host)s configuration."), "the agent %(agent_host)s configuration.",
{'agent_host': agent.host}) {'agent_host': agent.host})
continue continue

View File

@ -39,8 +39,8 @@ class L2populationAgentNotifyAPI(n_rpc.RpcProxy):
topics.UPDATE) topics.UPDATE)
def _notification_fanout(self, context, method, fdb_entries): def _notification_fanout(self, context, method, fdb_entries):
LOG.debug(_('Fanout notify l2population agents at %(topic)s ' LOG.debug('Fanout notify l2population agents at %(topic)s '
'the message %(method)s with %(fdb_entries)s'), 'the message %(method)s with %(fdb_entries)s',
{'topic': self.topic, {'topic': self.topic,
'method': method, 'method': method,
'fdb_entries': fdb_entries}) 'fdb_entries': fdb_entries})
@ -52,8 +52,8 @@ class L2populationAgentNotifyAPI(n_rpc.RpcProxy):
topic=self.topic_l2pop_update) topic=self.topic_l2pop_update)
def _notification_host(self, context, method, fdb_entries, host): def _notification_host(self, context, method, fdb_entries, host):
LOG.debug(_('Notify l2population agent %(host)s at %(topic)s the ' LOG.debug('Notify l2population agent %(host)s at %(topic)s the '
'message %(method)s with %(fdb_entries)s'), 'message %(method)s with %(fdb_entries)s',
{'host': host, {'host': host,
'topic': self.topic, 'topic': self.topic,
'method': method, 'method': method,

View File

@ -17,6 +17,7 @@ import abc
import six import six
from neutron.extensions import portbindings from neutron.extensions import portbindings
from neutron.openstack.common.gettextutils import _LW
from neutron.openstack.common import log from neutron.openstack.common import log
from neutron.plugins.ml2 import driver_api as api from neutron.plugins.ml2 import driver_api as api
@ -51,26 +52,26 @@ class AgentMechanismDriverBase(api.MechanismDriver):
pass pass
def bind_port(self, context): def bind_port(self, context):
LOG.debug(_("Attempting to bind port %(port)s on " LOG.debug("Attempting to bind port %(port)s on "
"network %(network)s"), "network %(network)s",
{'port': context.current['id'], {'port': context.current['id'],
'network': context.network.current['id']}) 'network': context.network.current['id']})
vnic_type = context.current.get(portbindings.VNIC_TYPE, vnic_type = context.current.get(portbindings.VNIC_TYPE,
portbindings.VNIC_NORMAL) portbindings.VNIC_NORMAL)
if vnic_type not in self.supported_vnic_types: if vnic_type not in self.supported_vnic_types:
LOG.debug(_("Refusing to bind due to unsupported vnic_type: %s"), LOG.debug("Refusing to bind due to unsupported vnic_type: %s",
vnic_type) vnic_type)
return return
for agent in context.host_agents(self.agent_type): for agent in context.host_agents(self.agent_type):
LOG.debug(_("Checking agent: %s"), agent) LOG.debug("Checking agent: %s", agent)
if agent['alive']: if agent['alive']:
for segment in context.network.network_segments: for segment in context.network.network_segments:
if self.try_to_bind_segment_for_agent(context, segment, if self.try_to_bind_segment_for_agent(context, segment,
agent): agent):
LOG.debug(_("Bound using segment: %s"), segment) LOG.debug("Bound using segment: %s", segment)
return return
else: else:
LOG.warning(_("Attempting to bind with dead agent: %s"), LOG.warning(_LW("Attempting to bind with dead agent: %s"),
agent) agent)
@abc.abstractmethod @abc.abstractmethod

View File

@ -22,6 +22,7 @@ from oslo.config import cfg
from neutron import context as ctx from neutron import context as ctx
from neutron.extensions import portbindings from neutron.extensions import portbindings
from neutron.openstack.common import excutils from neutron.openstack.common import excutils
from neutron.openstack.common.gettextutils import _LE, _LW
from neutron.openstack.common import log from neutron.openstack.common import log
from neutron.openstack.common import timeutils from neutron.openstack.common import timeutils
from neutron.plugins.bigswitch import config as pl_config from neutron.plugins.bigswitch import config as pl_config
@ -49,7 +50,7 @@ class BigSwitchMechanismDriver(plugin.NeutronRestProxyV2Base,
""" """
def initialize(self): def initialize(self):
LOG.debug(_('Initializing driver')) LOG.debug('Initializing driver')
# register plugin config opts # register plugin config opts
pl_config.register_config() pl_config.register_config()
@ -67,7 +68,7 @@ class BigSwitchMechanismDriver(plugin.NeutronRestProxyV2Base,
# Track hosts running IVS to avoid excessive calls to the backend # Track hosts running IVS to avoid excessive calls to the backend
self.ivs_host_cache = {} self.ivs_host_cache = {}
LOG.debug(_("Initialization done")) LOG.debug("Initialization done")
@put_context_in_serverpool @put_context_in_serverpool
def create_network_postcommit(self, context): def create_network_postcommit(self, context):
@ -106,8 +107,8 @@ class BigSwitchMechanismDriver(plugin.NeutronRestProxyV2Base,
e.status == httplib.NOT_FOUND and e.status == httplib.NOT_FOUND and
servermanager.NXNETWORK in e.reason): servermanager.NXNETWORK in e.reason):
ctxt.reraise = False ctxt.reraise = False
LOG.error(_("Iconsistency with backend controller " LOG.error(_LE("Inconsistency with backend controller "
"triggering full synchronization.")) "triggering full synchronization."))
topoargs = self.servers.get_topo_function_args topoargs = self.servers.get_topo_function_args
self._send_all_data( self._send_all_data(
send_ports=topoargs['get_ports'], send_ports=topoargs['get_ports'],
@ -134,8 +135,8 @@ class BigSwitchMechanismDriver(plugin.NeutronRestProxyV2Base,
prepped_port = self._map_state_and_status(prepped_port) prepped_port = self._map_state_and_status(prepped_port)
if (portbindings.HOST_ID not in prepped_port or if (portbindings.HOST_ID not in prepped_port or
prepped_port[portbindings.HOST_ID] == ''): prepped_port[portbindings.HOST_ID] == ''):
LOG.warning(_("Ignoring port notification to controller because " LOG.warning(_LW("Ignoring port notification to controller because "
"of missing host ID.")) "of missing host ID."))
# in ML2, controller doesn't care about ports without # in ML2, controller doesn't care about ports without
# the host_id set # the host_id set
return False return False

View File

@ -41,8 +41,8 @@ class HypervMechanismDriver(mech_agent.SimpleAgentMechanismDriverBase):
def check_segment_for_agent(self, segment, agent): def check_segment_for_agent(self, segment, agent):
mappings = agent['configurations'].get('vswitch_mappings', {}) mappings = agent['configurations'].get('vswitch_mappings', {})
LOG.debug(_("Checking segment: %(segment)s " LOG.debug("Checking segment: %(segment)s "
"for mappings: %(mappings)s"), "for mappings: %(mappings)s",
{'segment': segment, 'mappings': mappings}) {'segment': segment, 'mappings': mappings})
network_type = segment[api.NETWORK_TYPE] network_type = segment[api.NETWORK_TYPE]
if network_type == 'local': if network_type == 'local':

View File

@ -41,9 +41,9 @@ class LinuxbridgeMechanismDriver(mech_agent.SimpleAgentMechanismDriverBase):
def check_segment_for_agent(self, segment, agent): def check_segment_for_agent(self, segment, agent):
mappings = agent['configurations'].get('interface_mappings', {}) mappings = agent['configurations'].get('interface_mappings', {})
tunnel_types = agent['configurations'].get('tunnel_types', []) tunnel_types = agent['configurations'].get('tunnel_types', [])
LOG.debug(_("Checking segment: %(segment)s " LOG.debug("Checking segment: %(segment)s "
"for mappings: %(mappings)s " "for mappings: %(mappings)s "
"with tunnel_types: %(tunnel_types)s"), "with tunnel_types: %(tunnel_types)s",
{'segment': segment, 'mappings': mappings, {'segment': segment, 'mappings': mappings,
'tunnel_types': tunnel_types}) 'tunnel_types': tunnel_types})
network_type = segment[api.NETWORK_TYPE] network_type = segment[api.NETWORK_TYPE]

View File

@ -17,6 +17,7 @@ from oslo.config import cfg
from neutron.common import constants as n_consts from neutron.common import constants as n_consts
from neutron.extensions import portbindings from neutron.extensions import portbindings
from neutron.openstack.common.gettextutils import _LE
from neutron.openstack.common import log from neutron.openstack.common import log
from neutron.plugins.common import constants from neutron.plugins.common import constants
from neutron.plugins.ml2 import driver_api as api from neutron.plugins.ml2 import driver_api as api
@ -88,9 +89,9 @@ class NuageMechanismDriver(plugin.NuagePlugin,
LOG.debug("Bound using segment: %s", segment) LOG.debug("Bound using segment: %s", segment)
return return
else: else:
LOG.error(_("Refusing to bind port for segment ID %(id)s, " LOG.error(_LE("Refusing to bind port for segment ID %(id)s, "
"segment %(seg)s, phys net %(physnet)s, and " "segment %(seg)s, phys net %(physnet)s, and "
"network type %(nettype)s"), "network type %(nettype)s"),
{'id': segment[api.ID], {'id': segment[api.ID],
'seg': segment[api.SEGMENTATION_ID], 'seg': segment[api.SEGMENTATION_ID],
'physnet': segment[api.PHYSICAL_NETWORK], 'physnet': segment[api.PHYSICAL_NETWORK],

View File

@ -45,9 +45,9 @@ class OpenvswitchMechanismDriver(mech_agent.SimpleAgentMechanismDriverBase):
def check_segment_for_agent(self, segment, agent): def check_segment_for_agent(self, segment, agent):
mappings = agent['configurations'].get('bridge_mappings', {}) mappings = agent['configurations'].get('bridge_mappings', {})
tunnel_types = agent['configurations'].get('tunnel_types', []) tunnel_types = agent['configurations'].get('tunnel_types', [])
LOG.debug(_("Checking segment: %(segment)s " LOG.debug("Checking segment: %(segment)s "
"for mappings: %(mappings)s " "for mappings: %(mappings)s "
"with tunnel_types: %(tunnel_types)s"), "with tunnel_types: %(tunnel_types)s",
{'segment': segment, 'mappings': mappings, {'segment': segment, 'mappings': mappings,
'tunnel_types': tunnel_types}) 'tunnel_types': tunnel_types})
network_type = segment[api.NETWORK_TYPE] network_type = segment[api.NETWORK_TYPE]

View File

@ -18,6 +18,7 @@ from oslo.config import cfg
from neutron.common import constants from neutron.common import constants
from neutron.extensions import portbindings from neutron.extensions import portbindings
from neutron.openstack.common.gettextutils import _LE, _LW
from neutron.openstack.common import log from neutron.openstack.common import log
from neutron.plugins.common import constants as p_const from neutron.plugins.common import constants as p_const
from neutron.plugins.ml2 import driver_api as api from neutron.plugins.ml2 import driver_api as api
@ -83,7 +84,7 @@ class SriovNicSwitchMechanismDriver(api.MechanismDriver):
cfg.CONF.ml2_sriov.supported_pci_vendor_devs) cfg.CONF.ml2_sriov.supported_pci_vendor_devs)
self.agent_required = cfg.CONF.ml2_sriov.agent_required self.agent_required = cfg.CONF.ml2_sriov.agent_required
except ValueError: except ValueError:
LOG.exception(_("Failed to parse supported PCI vendor devices")) LOG.exception(_LE("Failed to parse supported PCI vendor devices"))
raise cfg.Error(_("Parsing supported pci_vendor_devs failed")) raise cfg.Error(_("Parsing supported pci_vendor_devs failed"))
def bind_port(self, context): def bind_port(self, context):
@ -109,7 +110,7 @@ class SriovNicSwitchMechanismDriver(api.MechanismDriver):
if self.try_to_bind(context, agent): if self.try_to_bind(context, agent):
return return
else: else:
LOG.warning(_("Attempting to bind with dead agent: %s"), LOG.warning(_LW("Attempting to bind with dead agent: %s"),
agent) agent)
else: else:
self.try_to_bind(context) self.try_to_bind(context)

View File

@ -51,8 +51,8 @@ class MlnxMechanismDriver(mech_agent.SimpleAgentMechanismDriverBase):
def check_segment_for_agent(self, segment, agent): def check_segment_for_agent(self, segment, agent):
mappings = agent['configurations'].get('interface_mappings', {}) mappings = agent['configurations'].get('interface_mappings', {})
LOG.debug(_("Checking segment: %(segment)s " LOG.debug("Checking segment: %(segment)s "
"for mappings: %(mappings)s "), "for mappings: %(mappings)s ",
{'segment': segment, 'mappings': mappings}) {'segment': segment, 'mappings': mappings})
network_type = segment[api.NETWORK_TYPE] network_type = segment[api.NETWORK_TYPE]

View File

@ -19,6 +19,7 @@ import sqlalchemy as sa
from neutron.common import exceptions as exc from neutron.common import exceptions as exc
from neutron.db import model_base from neutron.db import model_base
from neutron.openstack.common.gettextutils import _LI, _LW
from neutron.openstack.common import log from neutron.openstack.common import log
from neutron.plugins.common import constants as p_const from neutron.plugins.common import constants as p_const
from neutron.plugins.ml2 import driver_api as api from neutron.plugins.ml2 import driver_api as api
@ -66,20 +67,20 @@ class FlatTypeDriver(api.TypeDriver):
def _parse_networks(self, entries): def _parse_networks(self, entries):
self.flat_networks = entries self.flat_networks = entries
if '*' in self.flat_networks: if '*' in self.flat_networks:
LOG.info(_("Arbitrary flat physical_network names allowed")) LOG.info(_LI("Arbitrary flat physical_network names allowed"))
self.flat_networks = None self.flat_networks = None
elif not all(self.flat_networks): elif not all(self.flat_networks):
msg = _("physical network name is empty") msg = _("physical network name is empty")
raise exc.InvalidInput(error_message=msg) raise exc.InvalidInput(error_message=msg)
else: else:
LOG.info(_("Allowable flat physical_network names: %s"), LOG.info(_LI("Allowable flat physical_network names: %s"),
self.flat_networks) self.flat_networks)
def get_type(self): def get_type(self):
return p_const.TYPE_FLAT return p_const.TYPE_FLAT
def initialize(self): def initialize(self):
LOG.info(_("ML2 FlatTypeDriver initialization complete")) LOG.info(_LI("ML2 FlatTypeDriver initialization complete"))
def is_partial_segment(self, segment): def is_partial_segment(self, segment):
return False return False
@ -104,8 +105,8 @@ class FlatTypeDriver(api.TypeDriver):
physical_network = segment[api.PHYSICAL_NETWORK] physical_network = segment[api.PHYSICAL_NETWORK]
with session.begin(subtransactions=True): with session.begin(subtransactions=True):
try: try:
LOG.debug(_("Reserving flat network on physical " LOG.debug("Reserving flat network on physical "
"network %s"), physical_network) "network %s", physical_network)
alloc = FlatAllocation(physical_network=physical_network) alloc = FlatAllocation(physical_network=physical_network)
alloc.save(session) alloc.save(session)
except db_exc.DBDuplicateEntry: except db_exc.DBDuplicateEntry:
@ -127,5 +128,5 @@ class FlatTypeDriver(api.TypeDriver):
LOG.debug("Releasing flat network on physical network %s", LOG.debug("Releasing flat network on physical network %s",
physical_network) physical_network)
else: else:
LOG.warning(_("No flat network found on physical network %s"), LOG.warning(_LW("No flat network found on physical network %s"),
physical_network) physical_network)

View File

@ -22,7 +22,7 @@ from sqlalchemy import sql
from neutron.common import exceptions as exc from neutron.common import exceptions as exc
from neutron.db import api as db_api from neutron.db import api as db_api
from neutron.db import model_base from neutron.db import model_base
from neutron.openstack.common.gettextutils import _LE from neutron.openstack.common.gettextutils import _LE, _LW
from neutron.openstack.common import log from neutron.openstack.common import log
from neutron.plugins.common import constants as p_const from neutron.plugins.common import constants as p_const
from neutron.plugins.ml2.drivers import type_tunnel from neutron.plugins.ml2.drivers import type_tunnel
@ -72,8 +72,8 @@ class GreTypeDriver(type_tunnel.TunnelTypeDriver):
try: try:
self._initialize(cfg.CONF.ml2_type_gre.tunnel_id_ranges) self._initialize(cfg.CONF.ml2_type_gre.tunnel_id_ranges)
except exc.NetworkTunnelRangeError: except exc.NetworkTunnelRangeError:
LOG.exception(_("Failed to parse tunnel_id_ranges. " LOG.exception(_LE("Failed to parse tunnel_id_ranges. "
"Service terminated!")) "Service terminated!"))
raise SystemExit() raise SystemExit()
def sync_allocations(self): def sync_allocations(self):
@ -84,7 +84,7 @@ class GreTypeDriver(type_tunnel.TunnelTypeDriver):
tun_min, tun_max = gre_id_range tun_min, tun_max = gre_id_range
if tun_max + 1 - tun_min > 1000000: if tun_max + 1 - tun_min > 1000000:
LOG.error(_LE("Skipping unreasonable gre ID range " LOG.error(_LE("Skipping unreasonable gre ID range "
"%(tun_min)s:%(tun_max)s"), "%(tun_min)s:%(tun_max)s"),
{'tun_min': tun_min, 'tun_max': tun_max}) {'tun_min': tun_min, 'tun_max': tun_max})
else: else:
gre_ids |= set(moves.xrange(tun_min, tun_max + 1)) gre_ids |= set(moves.xrange(tun_min, tun_max + 1))
@ -129,5 +129,5 @@ class GreTypeDriver(type_tunnel.TunnelTypeDriver):
except db_exc.DBDuplicateEntry: except db_exc.DBDuplicateEntry:
gre_endpoint = (session.query(GreEndpoints). gre_endpoint = (session.query(GreEndpoints).
filter_by(ip_address=ip).one()) filter_by(ip_address=ip).one())
LOG.warning(_("Gre endpoint with ip %s already exists"), ip) LOG.warning(_LW("Gre endpoint with ip %s already exists"), ip)
return gre_endpoint return gre_endpoint

View File

@ -14,6 +14,7 @@
# under the License. # under the License.
from neutron.common import exceptions as exc from neutron.common import exceptions as exc
from neutron.openstack.common.gettextutils import _LI
from neutron.openstack.common import log from neutron.openstack.common import log
from neutron.plugins.common import constants as p_const from neutron.plugins.common import constants as p_const
from neutron.plugins.ml2 import driver_api as api from neutron.plugins.ml2 import driver_api as api
@ -32,7 +33,7 @@ class LocalTypeDriver(api.TypeDriver):
""" """
def __init__(self): def __init__(self):
LOG.info(_("ML2 LocalTypeDriver initialization complete")) LOG.info(_LI("ML2 LocalTypeDriver initialization complete"))
def get_type(self): def get_type(self):
return p_const.TYPE_LOCAL return p_const.TYPE_LOCAL

View File

@ -16,8 +16,7 @@ import abc
from neutron.common import exceptions as exc from neutron.common import exceptions as exc
from neutron.common import topics from neutron.common import topics
from neutron.openstack.common.gettextutils import _LI from neutron.openstack.common.gettextutils import _LI, _LW
from neutron.openstack.common.gettextutils import _LW
from neutron.openstack.common import log from neutron.openstack.common import log
from neutron.plugins.common import utils as plugin_utils from neutron.plugins.common import utils as plugin_utils
from neutron.plugins.ml2 import driver_api as api from neutron.plugins.ml2 import driver_api as api

View File

@ -24,6 +24,7 @@ from neutron.common import exceptions as exc
from neutron.common import utils from neutron.common import utils
from neutron.db import api as db_api from neutron.db import api as db_api
from neutron.db import model_base from neutron.db import model_base
from neutron.openstack.common.gettextutils import _LE, _LI, _LW
from neutron.openstack.common import log from neutron.openstack.common import log
from neutron.plugins.common import constants as p_const from neutron.plugins.common import constants as p_const
from neutron.plugins.common import utils as plugin_utils from neutron.plugins.common import utils as plugin_utils
@ -88,10 +89,10 @@ class VlanTypeDriver(helpers.TypeDriverHelper):
self.network_vlan_ranges = plugin_utils.parse_network_vlan_ranges( self.network_vlan_ranges = plugin_utils.parse_network_vlan_ranges(
cfg.CONF.ml2_type_vlan.network_vlan_ranges) cfg.CONF.ml2_type_vlan.network_vlan_ranges)
except Exception: except Exception:
LOG.exception(_("Failed to parse network_vlan_ranges. " LOG.exception(_LE("Failed to parse network_vlan_ranges. "
"Service terminated!")) "Service terminated!"))
sys.exit(1) 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 _sync_vlan_allocations(self): def _sync_vlan_allocations(self):
session = db_api.get_session() session = db_api.get_session()
@ -125,9 +126,9 @@ class VlanTypeDriver(helpers.TypeDriverHelper):
# it's not allocatable, so check if its allocated # it's not allocatable, so check if its allocated
if not alloc.allocated: if not alloc.allocated:
# it's not, so remove it from table # it's not, so remove it from table
LOG.debug(_("Removing vlan %(vlan_id)s on " LOG.debug("Removing vlan %(vlan_id)s on "
"physical network " "physical network "
"%(physical_network)s from pool"), "%(physical_network)s from pool",
{'vlan_id': alloc.vlan_id, {'vlan_id': alloc.vlan_id,
'physical_network': 'physical_network':
physical_network}) physical_network})
@ -146,8 +147,8 @@ class VlanTypeDriver(helpers.TypeDriverHelper):
for allocs in allocations.itervalues(): for allocs in allocations.itervalues():
for alloc in allocs: for alloc in allocs:
if not alloc.allocated: if not alloc.allocated:
LOG.debug(_("Removing vlan %(vlan_id)s on physical " LOG.debug("Removing vlan %(vlan_id)s on physical "
"network %(physical_network)s from pool"), "network %(physical_network)s from pool",
{'vlan_id': alloc.vlan_id, {'vlan_id': alloc.vlan_id,
'physical_network': 'physical_network':
alloc.physical_network}) alloc.physical_network})
@ -158,7 +159,7 @@ class VlanTypeDriver(helpers.TypeDriverHelper):
def initialize(self): def initialize(self):
self._sync_vlan_allocations() self._sync_vlan_allocations()
LOG.info(_("VlanTypeDriver initialization complete")) LOG.info(_LI("VlanTypeDriver initialization complete"))
def is_partial_segment(self, segment): def is_partial_segment(self, segment):
return segment.get(api.SEGMENTATION_ID) is None return segment.get(api.SEGMENTATION_ID) is None
@ -249,7 +250,7 @@ class VlanTypeDriver(helpers.TypeDriverHelper):
'physical_network': physical_network}) 'physical_network': physical_network})
if not count: if not count:
LOG.warning(_("No vlan_id %(vlan_id)s found on physical " LOG.warning(_LW("No vlan_id %(vlan_id)s found on physical "
"network %(physical_network)s"), "network %(physical_network)s"),
{'vlan_id': vlan_id, {'vlan_id': vlan_id,
'physical_network': physical_network}) 'physical_network': physical_network})

View File

@ -22,7 +22,7 @@ from sqlalchemy import sql
from neutron.common import exceptions as exc from neutron.common import exceptions as exc
from neutron.db import api as db_api from neutron.db import api as db_api
from neutron.db import model_base from neutron.db import model_base
from neutron.openstack.common.gettextutils import _LE from neutron.openstack.common.gettextutils import _LE, _LW
from neutron.openstack.common import log from neutron.openstack.common import log
from neutron.plugins.common import constants as p_const from neutron.plugins.common import constants as p_const
from neutron.plugins.ml2.drivers import type_tunnel from neutron.plugins.ml2.drivers import type_tunnel
@ -79,8 +79,8 @@ class VxlanTypeDriver(type_tunnel.TunnelTypeDriver):
try: try:
self._initialize(cfg.CONF.ml2_type_vxlan.vni_ranges) self._initialize(cfg.CONF.ml2_type_vxlan.vni_ranges)
except exc.NetworkTunnelRangeError: except exc.NetworkTunnelRangeError:
LOG.exception(_("Failed to parse vni_ranges. " LOG.exception(_LE("Failed to parse vni_ranges. "
"Service terminated!")) "Service terminated!"))
raise SystemExit() raise SystemExit()
def sync_allocations(self): def sync_allocations(self):
@ -129,7 +129,7 @@ class VxlanTypeDriver(type_tunnel.TunnelTypeDriver):
def get_endpoints(self): def get_endpoints(self):
"""Get every vxlan endpoints from database.""" """Get every vxlan endpoints from database."""
LOG.debug(_("get_vxlan_endpoints() called")) LOG.debug("get_vxlan_endpoints() called")
session = db_api.get_session() session = db_api.get_session()
with session.begin(subtransactions=True): with session.begin(subtransactions=True):
@ -139,7 +139,7 @@ class VxlanTypeDriver(type_tunnel.TunnelTypeDriver):
for vxlan_endpoint in vxlan_endpoints] for vxlan_endpoint in vxlan_endpoints]
def add_endpoint(self, ip, udp_port=VXLAN_UDP_PORT): def add_endpoint(self, ip, udp_port=VXLAN_UDP_PORT):
LOG.debug(_("add_vxlan_endpoint() called for ip %s"), ip) LOG.debug("add_vxlan_endpoint() called for ip %s", ip)
session = db_api.get_session() session = db_api.get_session()
try: try:
vxlan_endpoint = VxlanEndpoints(ip_address=ip, vxlan_endpoint = VxlanEndpoints(ip_address=ip,
@ -148,5 +148,5 @@ class VxlanTypeDriver(type_tunnel.TunnelTypeDriver):
except db_exc.DBDuplicateEntry: except db_exc.DBDuplicateEntry:
vxlan_endpoint = (session.query(VxlanEndpoints). vxlan_endpoint = (session.query(VxlanEndpoints).
filter_by(ip_address=ip).one()) filter_by(ip_address=ip).one())
LOG.warning(_("Vxlan endpoint with ip %s already exists"), ip) LOG.warning(_LW("Vxlan endpoint with ip %s already exists"), ip)
return vxlan_endpoint return vxlan_endpoint

View File

@ -21,6 +21,7 @@ from neutron.common import exceptions as exc
from neutron.extensions import multiprovidernet as mpnet from neutron.extensions import multiprovidernet as mpnet
from neutron.extensions import portbindings from neutron.extensions import portbindings
from neutron.extensions import providernet as provider from neutron.extensions import providernet as provider
from neutron.openstack.common.gettextutils import _LE, _LI, _LW
from neutron.openstack.common import log from neutron.openstack.common import log
from neutron.plugins.ml2.common import exceptions as ml2_exc from neutron.plugins.ml2.common import exceptions as ml2_exc
from neutron.plugins.ml2 import db from neutron.plugins.ml2 import db
@ -36,12 +37,12 @@ class TypeManager(stevedore.named.NamedExtensionManager):
# Mapping from type name to DriverManager # Mapping from type name to DriverManager
self.drivers = {} self.drivers = {}
LOG.info(_("Configured type driver names: %s"), LOG.info(_LI("Configured type driver names: %s"),
cfg.CONF.ml2.type_drivers) cfg.CONF.ml2.type_drivers)
super(TypeManager, self).__init__('neutron.ml2.type_drivers', super(TypeManager, self).__init__('neutron.ml2.type_drivers',
cfg.CONF.ml2.type_drivers, cfg.CONF.ml2.type_drivers,
invoke_on_load=True) invoke_on_load=True)
LOG.info(_("Loaded type driver names: %s"), self.names()) LOG.info(_LI("Loaded type driver names: %s"), self.names())
self._register_types() self._register_types()
self._check_tenant_network_types(cfg.CONF.ml2.tenant_network_types) self._check_tenant_network_types(cfg.CONF.ml2.tenant_network_types)
@ -49,15 +50,15 @@ class TypeManager(stevedore.named.NamedExtensionManager):
for ext in self: for ext in self:
network_type = ext.obj.get_type() network_type = ext.obj.get_type()
if network_type in self.drivers: if network_type in self.drivers:
LOG.error(_("Type driver '%(new_driver)s' ignored because type" LOG.error(_LE("Type driver '%(new_driver)s' ignored because"
" driver '%(old_driver)s' is already registered" " type driver '%(old_driver)s' is already"
" for type '%(type)s'"), " registered for type '%(type)s'"),
{'new_driver': ext.name, {'new_driver': ext.name,
'old_driver': self.drivers[network_type].name, 'old_driver': self.drivers[network_type].name,
'type': network_type}) 'type': network_type})
else: else:
self.drivers[network_type] = ext self.drivers[network_type] = ext
LOG.info(_("Registered types: %s"), self.drivers.keys()) LOG.info(_LI("Registered types: %s"), self.drivers.keys())
def _check_tenant_network_types(self, types): def _check_tenant_network_types(self, types):
self.tenant_network_types = [] self.tenant_network_types = []
@ -65,11 +66,10 @@ class TypeManager(stevedore.named.NamedExtensionManager):
if network_type in self.drivers: if network_type in self.drivers:
self.tenant_network_types.append(network_type) self.tenant_network_types.append(network_type)
else: else:
msg = _("No type driver for tenant network_type: %s. " LOG.error(_LE("No type driver for tenant network_type: %s. "
"Service terminated!") % network_type "Service terminated!"), network_type)
LOG.error(msg)
raise SystemExit(1) raise SystemExit(1)
LOG.info(_("Tenant network_types: %s"), self.tenant_network_types) LOG.info(_LI("Tenant network_types: %s"), self.tenant_network_types)
def _process_provider_segment(self, segment): def _process_provider_segment(self, segment):
network_type = self._get_attribute(segment, provider.NETWORK_TYPE) network_type = self._get_attribute(segment, provider.NETWORK_TYPE)
@ -124,7 +124,7 @@ class TypeManager(stevedore.named.NamedExtensionManager):
id = network['id'] id = network['id']
segments = db.get_network_segments(context.session, id) segments = db.get_network_segments(context.session, id)
if not segments: if not segments:
LOG.error(_("Network %s has no segments"), id) LOG.error(_LE("Network %s has no segments"), id)
network[provider.NETWORK_TYPE] = None network[provider.NETWORK_TYPE] = None
network[provider.PHYSICAL_NETWORK] = None network[provider.PHYSICAL_NETWORK] = None
network[provider.SEGMENTATION_ID] = None network[provider.SEGMENTATION_ID] = None
@ -142,7 +142,7 @@ class TypeManager(stevedore.named.NamedExtensionManager):
def initialize(self): def initialize(self):
for network_type, driver in self.drivers.iteritems(): for network_type, driver in self.drivers.iteritems():
LOG.info(_("Initializing driver for type '%s'"), network_type) LOG.info(_LI("Initializing driver for type '%s'"), network_type)
driver.obj.initialize() driver.obj.initialize()
def create_network_segments(self, context, network, tenant_id): def create_network_segments(self, context, network, tenant_id):
@ -202,8 +202,8 @@ class TypeManager(stevedore.named.NamedExtensionManager):
if driver: if driver:
driver.obj.release_segment(session, segment) driver.obj.release_segment(session, segment)
else: else:
LOG.error(_("Failed to release segment '%s' because " LOG.error(_LE("Failed to release segment '%s' because "
"network type is not supported."), segment) "network type is not supported."), segment)
def allocate_dynamic_segment(self, session, network_id, segment): def allocate_dynamic_segment(self, session, network_id, segment):
"""Allocate a dynamic segment using a partial or full segment dict.""" """Allocate a dynamic segment using a partial or full segment dict."""
@ -229,8 +229,8 @@ class TypeManager(stevedore.named.NamedExtensionManager):
driver.obj.release_segment(session, segment) driver.obj.release_segment(session, segment)
db.delete_network_segment(session, segment_id) db.delete_network_segment(session, segment_id)
else: else:
LOG.error(_("Failed to release segment '%s' because " LOG.error(_LE("Failed to release segment '%s' because "
"network type is not supported."), segment) "network type is not supported."), segment)
else: else:
LOG.debug("No segment found with id %(segment_id)s", segment_id) LOG.debug("No segment found with id %(segment_id)s", segment_id)
@ -245,13 +245,13 @@ class MechanismManager(stevedore.named.NamedExtensionManager):
# the order in which the drivers are called. # the order in which the drivers are called.
self.ordered_mech_drivers = [] self.ordered_mech_drivers = []
LOG.info(_("Configured mechanism driver names: %s"), LOG.info(_LI("Configured mechanism driver names: %s"),
cfg.CONF.ml2.mechanism_drivers) cfg.CONF.ml2.mechanism_drivers)
super(MechanismManager, self).__init__('neutron.ml2.mechanism_drivers', super(MechanismManager, self).__init__('neutron.ml2.mechanism_drivers',
cfg.CONF.ml2.mechanism_drivers, cfg.CONF.ml2.mechanism_drivers,
invoke_on_load=True, invoke_on_load=True,
name_order=True) name_order=True)
LOG.info(_("Loaded mechanism driver names: %s"), self.names()) LOG.info(_LI("Loaded mechanism driver names: %s"), self.names())
self._register_mechanisms() self._register_mechanisms()
def _register_mechanisms(self): def _register_mechanisms(self):
@ -263,14 +263,14 @@ class MechanismManager(stevedore.named.NamedExtensionManager):
for ext in self: for ext in self:
self.mech_drivers[ext.name] = ext self.mech_drivers[ext.name] = ext
self.ordered_mech_drivers.append(ext) self.ordered_mech_drivers.append(ext)
LOG.info(_("Registered mechanism drivers: %s"), LOG.info(_LI("Registered mechanism drivers: %s"),
[driver.name for driver in self.ordered_mech_drivers]) [driver.name for driver in self.ordered_mech_drivers])
def initialize(self): def initialize(self):
# For ML2 to support bulk operations, each driver must support them # For ML2 to support bulk operations, each driver must support them
self.native_bulk_support = True self.native_bulk_support = True
for driver in self.ordered_mech_drivers: for driver in self.ordered_mech_drivers:
LOG.info(_("Initializing mechanism driver '%s'"), driver.name) LOG.info(_LI("Initializing mechanism driver '%s'"), driver.name)
driver.obj.initialize() driver.obj.initialize()
self.native_bulk_support &= getattr(driver.obj, self.native_bulk_support &= getattr(driver.obj,
'native_bulk_support', True) 'native_bulk_support', True)
@ -292,7 +292,7 @@ class MechanismManager(stevedore.named.NamedExtensionManager):
getattr(driver.obj, method_name)(context) getattr(driver.obj, method_name)(context)
except Exception: except Exception:
LOG.exception( LOG.exception(
_("Mechanism driver '%(name)s' failed in %(method)s"), _LE("Mechanism driver '%(name)s' failed in %(method)s"),
{'name': driver.name, 'method': method_name} {'name': driver.name, 'method': method_name}
) )
error = True error = True
@ -594,11 +594,11 @@ class MechanismManager(stevedore.named.NamedExtensionManager):
'segment': binding.segment}) 'segment': binding.segment})
return return
except Exception: except Exception:
LOG.exception(_("Mechanism driver %s failed in " LOG.exception(_LE("Mechanism driver %s failed in "
"bind_port"), "bind_port"),
driver.name) driver.name)
binding.vif_type = portbindings.VIF_TYPE_BINDING_FAILED binding.vif_type = portbindings.VIF_TYPE_BINDING_FAILED
LOG.warning(_("Failed to bind port %(port)s on host %(host)s"), LOG.warning(_LW("Failed to bind port %(port)s on host %(host)s"),
{'port': context._port['id'], {'port': context._port['id'],
'host': binding.host}) 'host': binding.host})
@ -611,13 +611,13 @@ class ExtensionManager(stevedore.named.NamedExtensionManager):
# the order in which the drivers are called. # the order in which the drivers are called.
self.ordered_ext_drivers = [] self.ordered_ext_drivers = []
LOG.info(_("Configured extension driver names: %s"), LOG.info(_LI("Configured extension driver names: %s"),
cfg.CONF.ml2.extension_drivers) cfg.CONF.ml2.extension_drivers)
super(ExtensionManager, self).__init__('neutron.ml2.extension_drivers', super(ExtensionManager, self).__init__('neutron.ml2.extension_drivers',
cfg.CONF.ml2.extension_drivers, cfg.CONF.ml2.extension_drivers,
invoke_on_load=True, invoke_on_load=True,
name_order=True) name_order=True)
LOG.info(_("Loaded extension driver names: %s"), self.names()) LOG.info(_LI("Loaded extension driver names: %s"), self.names())
self._register_drivers() self._register_drivers()
def _register_drivers(self): def _register_drivers(self):
@ -628,13 +628,13 @@ class ExtensionManager(stevedore.named.NamedExtensionManager):
""" """
for ext in self: for ext in self:
self.ordered_ext_drivers.append(ext) self.ordered_ext_drivers.append(ext)
LOG.info(_("Registered extension drivers: %s"), LOG.info(_LI("Registered extension drivers: %s"),
[driver.name for driver in self.ordered_ext_drivers]) [driver.name for driver in self.ordered_ext_drivers])
def initialize(self): def initialize(self):
# Initialize each driver in the list. # Initialize each driver in the list.
for driver in self.ordered_ext_drivers: for driver in self.ordered_ext_drivers:
LOG.info(_("Initializing extension driver '%s'"), driver.name) LOG.info(_LI("Initializing extension driver '%s'"), driver.name)
driver.obj.initialize() driver.obj.initialize()
def extension_aliases(self): def extension_aliases(self):
@ -642,7 +642,7 @@ class ExtensionManager(stevedore.named.NamedExtensionManager):
for driver in self.ordered_ext_drivers: for driver in self.ordered_ext_drivers:
alias = driver.obj.extension_alias alias = driver.obj.extension_alias
exts.append(alias) exts.append(alias)
LOG.info(_("Got %(alias)s extension from driver '%(drv)s'"), LOG.info(_LI("Got %(alias)s extension from driver '%(drv)s'"),
{'alias': alias, 'drv': driver.name}) {'alias': alias, 'drv': driver.name})
return exts return exts
@ -653,7 +653,7 @@ class ExtensionManager(stevedore.named.NamedExtensionManager):
getattr(driver.obj, method_name)(session, data, result) getattr(driver.obj, method_name)(session, data, result)
except Exception: except Exception:
LOG.exception( LOG.exception(
_("Extension driver '%(name)s' failed in %(method)s"), _LE("Extension driver '%(name)s' failed in %(method)s"),
{'name': driver.name, 'method': method_name} {'name': driver.name, 'method': method_name}
) )
@ -689,19 +689,19 @@ class ExtensionManager(stevedore.named.NamedExtensionManager):
"""Notify all extension drivers to extend network dictionary.""" """Notify all extension drivers to extend network dictionary."""
for driver in self.ordered_ext_drivers: for driver in self.ordered_ext_drivers:
driver.obj.extend_network_dict(session, result) driver.obj.extend_network_dict(session, result)
LOG.info(_("Extended network dict for driver '%(drv)s'"), LOG.info(_LI("Extended network dict for driver '%(drv)s'"),
{'drv': driver.name}) {'drv': driver.name})
def extend_subnet_dict(self, session, result): def extend_subnet_dict(self, session, result):
"""Notify all extension drivers to extend subnet dictionary.""" """Notify all extension drivers to extend subnet dictionary."""
for driver in self.ordered_ext_drivers: for driver in self.ordered_ext_drivers:
driver.obj.extend_subnet_dict(session, result) driver.obj.extend_subnet_dict(session, result)
LOG.info(_("Extended subnet dict for driver '%(drv)s'"), LOG.info(_LI("Extended subnet dict for driver '%(drv)s'"),
{'drv': driver.name}) {'drv': driver.name})
def extend_port_dict(self, session, result): def extend_port_dict(self, session, result):
"""Notify all extension drivers to extend port dictionary.""" """Notify all extension drivers to extend port dictionary."""
for driver in self.ordered_ext_drivers: for driver in self.ordered_ext_drivers:
driver.obj.extend_port_dict(session, result) driver.obj.extend_port_dict(session, result)
LOG.info(_("Extended port dict for driver '%(drv)s'"), LOG.info(_LI("Extended port dict for driver '%(drv)s'"),
{'drv': driver.name}) {'drv': driver.name})

View File

@ -53,7 +53,7 @@ from neutron.extensions import portbindings
from neutron.extensions import providernet as provider from neutron.extensions import providernet as provider
from neutron import manager from neutron import manager
from neutron.openstack.common import excutils from neutron.openstack.common import excutils
from neutron.openstack.common.gettextutils import _LI from neutron.openstack.common.gettextutils import _LE, _LI, _LW
from neutron.openstack.common import importutils from neutron.openstack.common import importutils
from neutron.openstack.common import lockutils from neutron.openstack.common import lockutils
from neutron.openstack.common import log from neutron.openstack.common import log
@ -136,7 +136,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
cfg.CONF.network_scheduler_driver cfg.CONF.network_scheduler_driver
) )
LOG.info(_("Modular L2 Plugin initialization complete")) LOG.info(_LI("Modular L2 Plugin initialization complete"))
def _setup_rpc(self): def _setup_rpc(self):
self.notifier = rpc.AgentNotifierApi(topics.AGENT) self.notifier = rpc.AgentNotifierApi(topics.AGENT)
@ -263,13 +263,13 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
# normal operation. Log at info level if not 1st attempt. # normal operation. Log at info level if not 1st attempt.
count += 1 count += 1
if count > MAX_BIND_TRIES: if count > MAX_BIND_TRIES:
LOG.error(_("Failed to commit binding results for %(port)s " LOG.error(_LE("Failed to commit binding results for %(port)s "
"after %(max)s tries"), "after %(max)s tries"),
{'port': port_id, 'max': MAX_BIND_TRIES}) {'port': port_id, 'max': MAX_BIND_TRIES})
return context return context
if count > 1: if count > 1:
greenthread.sleep(0) # yield greenthread.sleep(0) # yield
LOG.info(_("Attempt %(count)s to bind port %(port)s"), LOG.info(_LI("Attempt %(count)s to bind port %(port)s"),
{'count': count, 'port': port_id}) {'count': count, 'port': port_id})
# The port isn't already bound and the necessary # The port isn't already bound and the necessary
@ -395,8 +395,8 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
try: try:
return jsonutils.loads(binding.vif_details) return jsonutils.loads(binding.vif_details)
except Exception: except Exception:
LOG.error(_("Serialized vif_details DB value '%(value)s' " LOG.error(_LE("Serialized vif_details DB value '%(value)s' "
"for port %(port)s is invalid"), "for port %(port)s is invalid"),
{'value': binding.vif_details, {'value': binding.vif_details,
'port': binding.port_id}) 'port': binding.port_id})
return {} return {}
@ -406,8 +406,8 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
try: try:
return jsonutils.loads(binding.profile) return jsonutils.loads(binding.profile)
except Exception: except Exception:
LOG.error(_("Serialized profile DB value '%(value)s' for " LOG.error(_LE("Serialized profile DB value '%(value)s' for "
"port %(port)s is invalid"), "port %(port)s is invalid"),
{'value': binding.profile, {'value': binding.profile,
'port': binding.port_id}) 'port': binding.port_id})
return {} return {}
@ -475,8 +475,8 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
if not segment: if not segment:
# REVISIT(rkukura): This should notify agent to unplug port # REVISIT(rkukura): This should notify agent to unplug port
network = mech_context.network.current network = mech_context.network.current
LOG.warning(_("In _notify_port_updated(), no bound segment for " LOG.warning(_LW("In _notify_port_updated(), no bound segment for "
"port %(port_id)s on network %(network_id)s"), "port %(port_id)s on network %(network_id)s"),
{'port_id': port['id'], {'port_id': port['id'],
'network_id': network['id']}) 'network_id': network['id']})
return return
@ -509,8 +509,8 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
self.mechanism_manager.create_network_postcommit(mech_context) self.mechanism_manager.create_network_postcommit(mech_context)
except ml2_exc.MechanismDriverError: except ml2_exc.MechanismDriverError:
with excutils.save_and_reraise_exception(): with excutils.save_and_reraise_exception():
LOG.error(_("mechanism_manager.create_network_postcommit " LOG.error(_LE("mechanism_manager.create_network_postcommit "
"failed, deleting network '%s'"), result['id']) "failed, deleting network '%s'"), result['id'])
self.delete_network(context, result['id']) self.delete_network(context, result['id'])
return result return result
@ -572,7 +572,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
# drivers from being called. This approach should be revisited # drivers from being called. This approach should be revisited
# when the API layer is reworked during icehouse. # when the API layer is reworked during icehouse.
LOG.debug(_("Deleting network %s"), id) LOG.debug("Deleting network %s", id)
session = context.session session = context.session
while True: while True:
try: try:
@ -599,13 +599,13 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
enable_eagerloads(False). enable_eagerloads(False).
filter_by(network_id=id). filter_by(network_id=id).
with_lockmode('update').all()) with_lockmode('update').all())
LOG.debug(_("Ports to auto-delete: %s"), ports) LOG.debug("Ports to auto-delete: %s", ports)
only_auto_del = all(p.device_owner only_auto_del = all(p.device_owner
in db_base_plugin_v2. in db_base_plugin_v2.
AUTO_DELETE_PORT_OWNERS AUTO_DELETE_PORT_OWNERS
for p in ports) for p in ports)
if not only_auto_del: if not only_auto_del:
LOG.debug(_("Tenant-owned ports exist")) LOG.debug("Tenant-owned ports exist")
raise exc.NetworkInUse(net_id=id) raise exc.NetworkInUse(net_id=id)
# Get subnets to auto-delete. # Get subnets to auto-delete.
@ -613,7 +613,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
enable_eagerloads(False). enable_eagerloads(False).
filter_by(network_id=id). filter_by(network_id=id).
with_lockmode('update').all()) with_lockmode('update').all())
LOG.debug(_("Subnets to auto-delete: %s"), subnets) LOG.debug("Subnets to auto-delete: %s", subnets)
if not (ports or subnets): if not (ports or subnets):
network = self.get_network(context, id) network = self.get_network(context, id)
@ -625,19 +625,19 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
self.type_manager.release_network_segments(session, id) self.type_manager.release_network_segments(session, id)
record = self._get_network(context, id) record = self._get_network(context, id)
LOG.debug(_("Deleting network record %s"), record) LOG.debug("Deleting network record %s", record)
session.delete(record) session.delete(record)
# The segment records are deleted via cascade from the # The segment records are deleted via cascade from the
# network record, so explicit removal is not necessary. # network record, so explicit removal is not necessary.
LOG.debug(_("Committing transaction")) LOG.debug("Committing transaction")
break break
except os_db_exception.DBError as e: except os_db_exception.DBError as e:
with excutils.save_and_reraise_exception() as ctxt: with excutils.save_and_reraise_exception() as ctxt:
if isinstance(e.inner_exception, sql_exc.IntegrityError): if isinstance(e.inner_exception, sql_exc.IntegrityError):
ctxt.reraise = False ctxt.reraise = False
msg = _("A concurrent port creation has occurred") LOG.warning(_LW("A concurrent port creation has "
LOG.warning(msg) "occurred"))
continue continue
for port in ports: for port in ports:
@ -645,7 +645,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
self.delete_port(context, port.id) self.delete_port(context, port.id)
except Exception: except Exception:
with excutils.save_and_reraise_exception(): with excutils.save_and_reraise_exception():
LOG.exception(_("Exception auto-deleting port %s"), LOG.exception(_LE("Exception auto-deleting port %s"),
port.id) port.id)
for subnet in subnets: for subnet in subnets:
@ -653,7 +653,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
self.delete_subnet(context, subnet.id) self.delete_subnet(context, subnet.id)
except Exception: except Exception:
with excutils.save_and_reraise_exception(): with excutils.save_and_reraise_exception():
LOG.exception(_("Exception auto-deleting subnet %s"), LOG.exception(_LE("Exception auto-deleting subnet %s"),
subnet.id) subnet.id)
try: try:
@ -662,7 +662,8 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
# TODO(apech) - One or more mechanism driver failed to # TODO(apech) - One or more mechanism driver failed to
# delete the network. Ideally we'd notify the caller of # delete the network. Ideally we'd notify the caller of
# the fact that an error occurred. # the fact that an error occurred.
LOG.error(_("mechanism_manager.delete_network_postcommit failed")) LOG.error(_LE("mechanism_manager.delete_network_postcommit"
" failed"))
self.notifier.network_delete(context, id) self.notifier.network_delete(context, id)
def create_subnet(self, context, subnet): def create_subnet(self, context, subnet):
@ -678,8 +679,8 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
self.mechanism_manager.create_subnet_postcommit(mech_context) self.mechanism_manager.create_subnet_postcommit(mech_context)
except ml2_exc.MechanismDriverError: except ml2_exc.MechanismDriverError:
with excutils.save_and_reraise_exception(): with excutils.save_and_reraise_exception():
LOG.error(_("mechanism_manager.create_subnet_postcommit " LOG.error(_LE("mechanism_manager.create_subnet_postcommit "
"failed, deleting subnet '%s'"), result['id']) "failed, deleting subnet '%s'"), result['id'])
self.delete_subnet(context, result['id']) self.delete_subnet(context, result['id'])
return result return result
@ -710,7 +711,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
# This approach should be revisited when the API layer is reworked # This approach should be revisited when the API layer is reworked
# during icehouse. # during icehouse.
LOG.debug(_("Deleting subnet %s"), id) LOG.debug("Deleting subnet %s", id)
session = context.session session = context.session
while True: while True:
# REVISIT: Serialize this operation with a semaphore to # REVISIT: Serialize this operation with a semaphore to
@ -727,12 +728,12 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
join(models_v2.Port). join(models_v2.Port).
filter_by(network_id=subnet['network_id']). filter_by(network_id=subnet['network_id']).
with_lockmode('update').all()) with_lockmode('update').all())
LOG.debug(_("Ports to auto-deallocate: %s"), allocated) LOG.debug("Ports to auto-deallocate: %s", allocated)
only_auto_del = ipv6_utils.is_slaac_subnet(subnet) or all( only_auto_del = ipv6_utils.is_slaac_subnet(subnet) or all(
not a.port_id or a.ports.device_owner in db_base_plugin_v2. not a.port_id or a.ports.device_owner in db_base_plugin_v2.
AUTO_DELETE_PORT_OWNERS for a in allocated) AUTO_DELETE_PORT_OWNERS for a in allocated)
if not only_auto_del: if not only_auto_del:
LOG.debug(_("Tenant-owned ports exist")) LOG.debug("Tenant-owned ports exist")
raise exc.SubnetInUse(subnet_id=id) raise exc.SubnetInUse(subnet_id=id)
if not allocated: if not allocated:
@ -741,10 +742,10 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
self.mechanism_manager.delete_subnet_precommit( self.mechanism_manager.delete_subnet_precommit(
mech_context) mech_context)
LOG.debug(_("Deleting subnet record")) LOG.debug("Deleting subnet record")
session.delete(record) session.delete(record)
LOG.debug(_("Committing transaction")) LOG.debug("Committing transaction")
break break
for a in allocated: for a in allocated:
@ -760,8 +761,8 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
self.update_port(context, a.port_id, data) self.update_port(context, a.port_id, data)
except Exception: except Exception:
with excutils.save_and_reraise_exception(): with excutils.save_and_reraise_exception():
LOG.exception(_("Exception deleting fixed_ip from " LOG.exception(_LE("Exception deleting fixed_ip "
"port %s"), a.port_id) "from port %s"), a.port_id)
session.delete(a) session.delete(a)
try: try:
@ -770,7 +771,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
# TODO(apech) - One or more mechanism driver failed to # TODO(apech) - One or more mechanism driver failed to
# delete the subnet. Ideally we'd notify the caller of # delete the subnet. Ideally we'd notify the caller of
# the fact that an error occurred. # the fact that an error occurred.
LOG.error(_("mechanism_manager.delete_subnet_postcommit failed")) LOG.error(_LE("mechanism_manager.delete_subnet_postcommit failed"))
def create_port(self, context, port): def create_port(self, context, port):
attrs = port['port'] attrs = port['port']
@ -806,8 +807,8 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
self.mechanism_manager.create_port_postcommit(mech_context) self.mechanism_manager.create_port_postcommit(mech_context)
except ml2_exc.MechanismDriverError: except ml2_exc.MechanismDriverError:
with excutils.save_and_reraise_exception(): with excutils.save_and_reraise_exception():
LOG.error(_("mechanism_manager.create_port_postcommit " LOG.error(_LE("mechanism_manager.create_port_postcommit "
"failed, deleting port '%s'"), result['id']) "failed, deleting port '%s'"), result['id'])
self.delete_port(context, result['id']) self.delete_port(context, result['id'])
# REVISIT(rkukura): Is there any point in calling this before # REVISIT(rkukura): Is there any point in calling this before
@ -818,8 +819,8 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
bound_context = self._bind_port_if_needed(mech_context) bound_context = self._bind_port_if_needed(mech_context)
except ml2_exc.MechanismDriverError: except ml2_exc.MechanismDriverError:
with excutils.save_and_reraise_exception(): with excutils.save_and_reraise_exception():
LOG.error(_("_bind_port_if_needed " LOG.error(_LE("_bind_port_if_needed "
"failed, deleting port '%s'"), result['id']) "failed, deleting port '%s'"), result['id'])
self.delete_port(context, result['id']) self.delete_port(context, result['id'])
return bound_context._port return bound_context._port
@ -904,7 +905,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
host_set = attributes.is_attr_set(host) host_set = attributes.is_attr_set(host)
if not host_set: if not host_set:
LOG.error(_("No Host supplied to bind DVR Port %s"), id) LOG.error(_LE("No Host supplied to bind DVR Port %s"), id)
return return
session = context.session session = context.session
@ -973,7 +974,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
cur_binding.segment = new_binding.segment cur_binding.segment = new_binding.segment
def delete_port(self, context, id, l3_port_check=True): def delete_port(self, context, id, l3_port_check=True):
LOG.debug(_("Deleting port %s"), id) LOG.debug("Deleting port %s", id)
removed_routers = [] removed_routers = []
l3plugin = manager.NeutronManager.get_service_plugins().get( l3plugin = manager.NeutronManager.get_service_plugins().get(
service_constants.L3_ROUTER_NAT) service_constants.L3_ROUTER_NAT)
@ -993,7 +994,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
if not port_db: if not port_db:
# the port existed when l3plugin.prevent_l3_port_deletion # the port existed when l3plugin.prevent_l3_port_deletion
# was called but now is already gone # was called but now is already gone
LOG.debug(_("The port '%s' was deleted"), id) LOG.debug("The port '%s' was deleted", id)
return return
port = self._make_port_dict(port_db) port = self._make_port_dict(port_db)
@ -1020,8 +1021,8 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
router_ids = l3plugin.disassociate_floatingips( router_ids = l3plugin.disassociate_floatingips(
context, id, do_notify=False) context, id, do_notify=False)
LOG.debug("Calling delete_port for %(port_id)s owned by %(owner)s" LOG.debug("Calling delete_port for %(port_id)s owned by %(owner)s",
% {"port_id": id, "owner": device_owner}) {"port_id": id, "owner": device_owner})
super(Ml2Plugin, self).delete_port(context, id) super(Ml2Plugin, self).delete_port(context, id)
# now that we've left db transaction, we are safe to notify # now that we've left db transaction, we are safe to notify
@ -1048,8 +1049,8 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
# TODO(apech) - One or more mechanism driver failed to # TODO(apech) - One or more mechanism driver failed to
# delete the port. Ideally we'd notify the caller of the # delete the port. Ideally we'd notify the caller of the
# fact that an error occurred. # fact that an error occurred.
LOG.error(_("mechanism_manager.delete_port_postcommit failed for " LOG.error(_LE("mechanism_manager.delete_port_postcommit failed for"
"port %s"), id) " port %s"), id)
self.notify_security_groups_member_updated(context, port) self.notify_security_groups_member_updated(context, port)
def get_bound_port_context(self, plugin_context, port_id, host=None): def get_bound_port_context(self, plugin_context, port_id, host=None):
@ -1065,7 +1066,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
port_id) port_id)
return return
except exc.MultipleResultsFound: except exc.MultipleResultsFound:
LOG.error(_("Multiple ports have port_id starting with %s"), LOG.error(_LE("Multiple ports have port_id starting with %s"),
port_id) port_id)
return return
port = self._make_port_dict(port_db) port = self._make_port_dict(port_db)
@ -1074,7 +1075,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
binding = db.get_dvr_port_binding_by_host( binding = db.get_dvr_port_binding_by_host(
session, port['id'], host) session, port['id'], host)
if not binding: if not binding:
LOG.error(_("Binding info for DVR port %s not found"), LOG.error(_LE("Binding info for DVR port %s not found"),
port_id) port_id)
return None return None
port_context = driver_context.DvrPortContext( port_context = driver_context.DvrPortContext(
@ -1110,7 +1111,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
session.begin(subtransactions=True)): session.begin(subtransactions=True)):
port = db.get_port(session, port_id) port = db.get_port(session, port_id)
if not port: if not port:
LOG.warning(_("Port %(port)s updated up by agent not found"), LOG.warning(_LW("Port %(port)s updated up by agent not found"),
{'port': port_id}) {'port': port_id})
return None return None
if (port.status != status and if (port.status != status and
@ -1140,7 +1141,8 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
session.begin(subtransactions=True)): session.begin(subtransactions=True)):
port = db.get_port(session, port_id) port = db.get_port(session, port_id)
if not port: if not port:
LOG.warning(_("Port %s not found during update"), port_id) LOG.warning(_LW("Port %s not found during update"),
port_id)
return return
original_port = self._make_port_dict(port) original_port = self._make_port_dict(port)
network = self.get_network(context, network = self.get_network(context,

View File

@ -22,6 +22,7 @@ from neutron.common import topics
from neutron.common import utils from neutron.common import utils
from neutron.extensions import portbindings from neutron.extensions import portbindings
from neutron import manager from neutron import manager
from neutron.openstack.common.gettextutils import _LW
from neutron.openstack.common import log from neutron.openstack.common import log
from neutron.plugins.common import constants as service_constants from neutron.plugins.common import constants as service_constants
from neutron.plugins.ml2 import driver_api as api from neutron.plugins.ml2 import driver_api as api
@ -63,8 +64,8 @@ class RpcCallbacks(n_rpc.RpcCallback,
port_id, port_id,
host) host)
if not port_context: if not port_context:
LOG.warning(_("Device %(device)s requested by agent " LOG.warning(_LW("Device %(device)s requested by agent "
"%(agent_id)s not found in database"), "%(agent_id)s not found in database"),
{'device': device, 'agent_id': agent_id}) {'device': device, 'agent_id': agent_id})
return {'device': device} return {'device': device}
@ -72,9 +73,9 @@ class RpcCallbacks(n_rpc.RpcCallback,
port = port_context.current port = port_context.current
if not segment: if not segment:
LOG.warning(_("Device %(device)s requested by agent " LOG.warning(_LW("Device %(device)s requested by agent "
"%(agent_id)s on network %(network_id)s not " "%(agent_id)s on network %(network_id)s not "
"bound, vif_type: %(vif_type)s"), "bound, vif_type: %(vif_type)s"),
{'device': device, {'device': device,
'agent_id': agent_id, 'agent_id': agent_id,
'network_id': port['network_id'], 'network_id': port['network_id'],
@ -100,7 +101,7 @@ class RpcCallbacks(n_rpc.RpcCallback,
'fixed_ips': port['fixed_ips'], 'fixed_ips': port['fixed_ips'],
'device_owner': port['device_owner'], 'device_owner': port['device_owner'],
'profile': port[portbindings.PROFILE]} 'profile': port[portbindings.PROFILE]}
LOG.debug(_("Returning: %s"), entry) LOG.debug("Returning: %s", entry)
return entry return entry
def get_devices_details_list(self, rpc_context, **kwargs): def get_devices_details_list(self, rpc_context, **kwargs):
@ -119,16 +120,16 @@ class RpcCallbacks(n_rpc.RpcCallback,
agent_id = kwargs.get('agent_id') agent_id = kwargs.get('agent_id')
device = kwargs.get('device') device = kwargs.get('device')
host = kwargs.get('host') host = kwargs.get('host')
LOG.debug(_("Device %(device)s no longer exists at agent " LOG.debug("Device %(device)s no longer exists at agent "
"%(agent_id)s"), "%(agent_id)s",
{'device': device, 'agent_id': agent_id}) {'device': device, 'agent_id': agent_id})
plugin = manager.NeutronManager.get_plugin() plugin = manager.NeutronManager.get_plugin()
port_id = plugin._device_to_port_id(device) port_id = plugin._device_to_port_id(device)
port_exists = True port_exists = True
if (host and not plugin.port_bound_to_host(rpc_context, if (host and not plugin.port_bound_to_host(rpc_context,
port_id, host)): port_id, host)):
LOG.debug(_("Device %(device)s not bound to the" LOG.debug("Device %(device)s not bound to the"
" agent host %(host)s"), " agent host %(host)s",
{'device': device, 'host': host}) {'device': device, 'host': host})
return {'device': device, return {'device': device,
'exists': port_exists} 'exists': port_exists}
@ -145,14 +146,14 @@ class RpcCallbacks(n_rpc.RpcCallback,
agent_id = kwargs.get('agent_id') agent_id = kwargs.get('agent_id')
device = kwargs.get('device') device = kwargs.get('device')
host = kwargs.get('host') host = kwargs.get('host')
LOG.debug(_("Device %(device)s up at agent %(agent_id)s"), LOG.debug("Device %(device)s up at agent %(agent_id)s",
{'device': device, 'agent_id': agent_id}) {'device': device, 'agent_id': agent_id})
plugin = manager.NeutronManager.get_plugin() plugin = manager.NeutronManager.get_plugin()
port_id = plugin._device_to_port_id(device) port_id = plugin._device_to_port_id(device)
if (host and not plugin.port_bound_to_host(rpc_context, if (host and not plugin.port_bound_to_host(rpc_context,
port_id, host)): port_id, host)):
LOG.debug(_("Device %(device)s not bound to the" LOG.debug("Device %(device)s not bound to the"
" agent host %(host)s"), " agent host %(host)s",
{'device': device, 'host': host}) {'device': device, 'host': host})
return return