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/scheduler",
"neutron/server",
"neutron/services"]
"neutron/services",
"neutron/plugins/ml2"]
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.extensions import portbindings
from neutron import manager
from neutron.openstack.common.gettextutils import _LE, _LI
from neutron.openstack.common import log
from neutron.openstack.common import uuidutils
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)
segment[api.ID] = record.id
LOG.info(_("Added segment %(id)s of type %(network_type)s for network"
" %(network_id)s"),
LOG.info(_LI("Added segment %(id)s of type %(network_type)s for network"
" %(network_id)s"),
{'id': record.id,
'network_type': record.network_type,
'network_id': record.network_id})
@ -203,13 +204,13 @@ def get_port(session, port_id):
except exc.NoResultFound:
return
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)
return
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()
qry = session.query(models_v2.Port).filter_by(mac_address=device_mac)
return qry.first()
@ -283,11 +284,11 @@ def get_port_binding_host(port_id):
filter(models.PortBinding.port_id.startswith(port_id)).
one())
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})
return
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)
return
return query.host

View File

@ -21,6 +21,7 @@ from oslo.config import cfg
from neutron import context as nctx
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.plugins.ml2.drivers.arista import exceptions as arista_exc
@ -369,13 +370,13 @@ class AristaL3Driver(object):
command_end = ['exit']
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:
# this returns array of return values for every command in
# full_command list
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:
msg = (_('Error occured while trying to execute '

View File

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

View File

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

View File

@ -22,6 +22,7 @@ from ncclient import manager
from xml.etree import ElementTree
from neutron.openstack.common import excutils
from neutron.openstack.common.gettextutils import _LE
from neutron.openstack.common import log as logging
from neutron.plugins.ml2.drivers.brocade.nos import nctemplates as template
@ -81,9 +82,9 @@ class NOSdriver():
except 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))
return self.mgr
@ -100,7 +101,7 @@ class NOSdriver():
return self.nos_version_request(mgr)
except Exception:
with excutils.save_and_reraise_exception():
LOG.exception(_("NETCONF error"))
LOG.exception(_LE("NETCONF error"))
self.close_session()
def is_virtual_fabric_enabled(self, host, username, password):
@ -110,7 +111,7 @@ class NOSdriver():
return (self.virtual_fabric_info(mgr) == "enabled")
except Exception:
with excutils.save_and_reraise_exception():
LOG.exception(_("NETCONF error"))
LOG.exception(_LE("NETCONF error"))
self.close_session()
def create_network(self, host, username, password, net_id):
@ -138,7 +139,7 @@ class NOSdriver():
self.activate_port_profile(mgr, name)
except Exception:
with excutils.save_and_reraise_exception():
LOG.exception(_("NETCONF error"))
LOG.exception(_LE("NETCONF error"))
self.close_session()
def delete_network(self, host, username, password, net_id):
@ -155,7 +156,7 @@ class NOSdriver():
self.delete_vlan_interface(mgr, net_id)
except Exception:
with excutils.save_and_reraise_exception():
LOG.exception(_("NETCONF error"))
LOG.exception(_LE("NETCONF error"))
self.close_session()
def associate_mac_to_network(self, host, username, password,
@ -168,7 +169,7 @@ class NOSdriver():
self.associate_mac_to_port_profile(mgr, name, mac)
except Exception:
with excutils.save_and_reraise_exception():
LOG.exception(_("NETCONF error"))
LOG.exception(_LE("NETCONF error"))
self.close_session()
def dissociate_mac_from_network(self, host, username, password,
@ -181,7 +182,7 @@ class NOSdriver():
self.dissociate_mac_from_port_profile(mgr, name, mac)
except Exception:
with excutils.save_and_reraise_exception():
LOG.exception(_("NETCONF error"))
LOG.exception(_LE("NETCONF error"))
self.close_session()
def create_vlan_interface(self, mgr, vlan_id):
@ -324,7 +325,7 @@ class NOSdriver():
self.activate_svi(mgr, rbridge_id, vlan_id)
except Exception as ex:
with excutils.save_and_reraise_exception():
LOG.exception(_("NETCONF error: %s"), ex)
LOG.exception(_LE("NETCONF error: %s"), ex)
self.close_session()
def delete_svi(self, host, username, password,
@ -335,7 +336,7 @@ class NOSdriver():
self.remove_svi(mgr, rbridge_id, vlan_id)
except Exception as ex:
with excutils.save_and_reraise_exception():
LOG.exception(_("NETCONF error: %s"), ex)
LOG.exception(_LE("NETCONF error: %s"), ex)
self.close_session()
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)
except Exception:
with excutils.save_and_reraise_exception():
LOG.exception(_("NETCONF error"))
LOG.exception(_LE("NETCONF error"))
self.close_session()
try:
# For Nos5.0.0
@ -367,7 +368,7 @@ class NOSdriver():
vrf_name)
except Exception:
with excutils.save_and_reraise_exception():
LOG.exception(_("NETCONF error"))
LOG.exception(_LE("NETCONF error"))
self.close_session()
ctxt.reraise = False
@ -381,7 +382,7 @@ class NOSdriver():
self.delete_vrf(mgr, rbridge_id, vrf_name)
except Exception:
with excutils.save_and_reraise_exception():
LOG.exception(_("NETCONF error"))
LOG.exception(_LE("NETCONF error"))
self.close_session()
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)
except Exception:
with excutils.save_and_reraise_exception():
LOG.exception(_("NETCONF error"))
LOG.exception(_LE("NETCONF error"))
self.close_session()
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)
except Exception:
with excutils.save_and_reraise_exception():
LOG.exception(_("NETCONF error"))
LOG.exception(_LE("NETCONF error"))
self.close_session()
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.
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()
@ -117,12 +117,12 @@ class CiscoNexusMechanismDriver(api.MechanismDriver):
previous_bindings = [row for row in all_bindings
if row.instance_id != device_id]
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,
intf_type, nexus_port)
else:
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(
switch_ip, vlan_id, vlan_name, intf_type, nexus_port)

View File

@ -17,6 +17,7 @@
import sqlalchemy.orm.exc as sa_exc
import neutron.db.api as db
from neutron.openstack.common.gettextutils import _LW
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 nexus_models_v2
@ -27,7 +28,7 @@ LOG = logging.getLogger(__name__)
def get_nexusport_binding(port_id, vlan_id, switch_ip, instance_id):
"""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,
vlan_id=vlan_id,
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):
"""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)
def add_nexusport_binding(port_id, vlan_id, switch_ip, instance_id):
"""Adds a nexusport binding."""
LOG.debug(_("add_nexusport_binding() called"))
LOG.debug("add_nexusport_binding() called")
session = db.get_session()
binding = nexus_models_v2.NexusPortBinding(port_id=port_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):
"""Removes a nexusport binding."""
LOG.debug(_("remove_nexusport_binding() called"))
LOG.debug("remove_nexusport_binding() called")
session = db.get_session()
binding = _lookup_all_nexus_bindings(session=session,
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):
"""Updates nexusport binding."""
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
LOG.debug(_("update_nexusport_binding called"))
LOG.debug("update_nexusport_binding called")
session = db.get_session()
binding = _lookup_one_nexus_binding(session=session, port_id=port_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):
"""Lists nexusvm bindings."""
LOG.debug(_("get_nexusvm_bindings() called"))
LOG.debug("get_nexusvm_bindings() called")
return _lookup_all_nexus_bindings(instance_id=instance_id,
vlan_id=vlan_id)
def get_port_vlan_switch_binding(port_id, vlan_id, switch_ip):
"""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,
switch_ip=switch_ip,
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):
"""List all vm/vlan bindings on a Nexus switch port."""
LOG.debug(_("get_port_switch_bindings() called, "
"port:'%(port_id)s', switch:'%(switch_ip)s'"),
LOG.debug("get_port_switch_bindings() called, "
"port:'%(port_id)s', switch:'%(switch_ip)s'",
{'port_id': port_id, 'switch_ip': switch_ip})
try:
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."""
confstr = snippet % (intf_type, interface, vlanid, intf_type)
confstr = self.create_xml_snippet(confstr)
LOG.debug(_("NexusDriver: %s"), confstr)
LOG.debug("NexusDriver: %s", confstr)
return confstr
def enable_vlan_on_trunk_int(self, nexus_host, vlanid, intf_type,
@ -196,7 +196,7 @@ class CiscoNexusDriver(object):
intf_type, nexus_port):
"""Create VLAN and trunk it on the specified ports."""
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:
self.enable_vlan_on_trunk_int(nexus_host, vlan_id, intf_type,
nexus_port)

View File

@ -16,6 +16,7 @@
from neutron.common import constants as n_const
from neutron.common import log
from neutron.extensions import portbindings
from neutron.openstack.common.gettextutils import _LI
from neutron.openstack.common import log as logging
from neutron.plugins.common import constants
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_details = {portbindings.CAP_PORT_FILTER: True}
LOG.info(_("Initializing CRD client... "))
LOG.info(_LI("Initializing CRD client... "))
self._crdclient = config.get_crdclient()
# Network Management

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -41,9 +41,9 @@ class LinuxbridgeMechanismDriver(mech_agent.SimpleAgentMechanismDriverBase):
def check_segment_for_agent(self, segment, agent):
mappings = agent['configurations'].get('interface_mappings', {})
tunnel_types = agent['configurations'].get('tunnel_types', [])
LOG.debug(_("Checking segment: %(segment)s "
"for mappings: %(mappings)s "
"with tunnel_types: %(tunnel_types)s"),
LOG.debug("Checking segment: %(segment)s "
"for mappings: %(mappings)s "
"with tunnel_types: %(tunnel_types)s",
{'segment': segment, 'mappings': mappings,
'tunnel_types': tunnel_types})
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.extensions import portbindings
from neutron.openstack.common.gettextutils import _LE
from neutron.openstack.common import log
from neutron.plugins.common import constants
from neutron.plugins.ml2 import driver_api as api
@ -88,9 +89,9 @@ class NuageMechanismDriver(plugin.NuagePlugin,
LOG.debug("Bound using segment: %s", segment)
return
else:
LOG.error(_("Refusing to bind port for segment ID %(id)s, "
"segment %(seg)s, phys net %(physnet)s, and "
"network type %(nettype)s"),
LOG.error(_LE("Refusing to bind port for segment ID %(id)s, "
"segment %(seg)s, phys net %(physnet)s, and "
"network type %(nettype)s"),
{'id': segment[api.ID],
'seg': segment[api.SEGMENTATION_ID],
'physnet': segment[api.PHYSICAL_NETWORK],

View File

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

View File

@ -18,6 +18,7 @@ from oslo.config import cfg
from neutron.common import constants
from neutron.extensions import portbindings
from neutron.openstack.common.gettextutils import _LE, _LW
from neutron.openstack.common import log
from neutron.plugins.common import constants as p_const
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)
self.agent_required = cfg.CONF.ml2_sriov.agent_required
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"))
def bind_port(self, context):
@ -109,7 +110,7 @@ class SriovNicSwitchMechanismDriver(api.MechanismDriver):
if self.try_to_bind(context, agent):
return
else:
LOG.warning(_("Attempting to bind with dead agent: %s"),
LOG.warning(_LW("Attempting to bind with dead agent: %s"),
agent)
else:
self.try_to_bind(context)

View File

@ -51,8 +51,8 @@ class MlnxMechanismDriver(mech_agent.SimpleAgentMechanismDriverBase):
def check_segment_for_agent(self, segment, agent):
mappings = agent['configurations'].get('interface_mappings', {})
LOG.debug(_("Checking segment: %(segment)s "
"for mappings: %(mappings)s "),
LOG.debug("Checking segment: %(segment)s "
"for mappings: %(mappings)s ",
{'segment': segment, 'mappings': mappings})
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.db import model_base
from neutron.openstack.common.gettextutils import _LI, _LW
from neutron.openstack.common import log
from neutron.plugins.common import constants as p_const
from neutron.plugins.ml2 import driver_api as api
@ -66,20 +67,20 @@ class FlatTypeDriver(api.TypeDriver):
def _parse_networks(self, entries):
self.flat_networks = entries
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
elif not all(self.flat_networks):
msg = _("physical network name is empty")
raise exc.InvalidInput(error_message=msg)
else:
LOG.info(_("Allowable flat physical_network names: %s"),
LOG.info(_LI("Allowable flat physical_network names: %s"),
self.flat_networks)
def get_type(self):
return p_const.TYPE_FLAT
def initialize(self):
LOG.info(_("ML2 FlatTypeDriver initialization complete"))
LOG.info(_LI("ML2 FlatTypeDriver initialization complete"))
def is_partial_segment(self, segment):
return False
@ -104,8 +105,8 @@ class FlatTypeDriver(api.TypeDriver):
physical_network = segment[api.PHYSICAL_NETWORK]
with session.begin(subtransactions=True):
try:
LOG.debug(_("Reserving flat network on physical "
"network %s"), physical_network)
LOG.debug("Reserving flat network on physical "
"network %s", physical_network)
alloc = FlatAllocation(physical_network=physical_network)
alloc.save(session)
except db_exc.DBDuplicateEntry:
@ -127,5 +128,5 @@ class FlatTypeDriver(api.TypeDriver):
LOG.debug("Releasing flat network on physical network %s",
physical_network)
else:
LOG.warning(_("No flat network found on physical network %s"),
LOG.warning(_LW("No flat network found on physical network %s"),
physical_network)

View File

@ -22,7 +22,7 @@ from sqlalchemy import sql
from neutron.common import exceptions as exc
from neutron.db import api as db_api
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.plugins.common import constants as p_const
from neutron.plugins.ml2.drivers import type_tunnel
@ -72,8 +72,8 @@ class GreTypeDriver(type_tunnel.TunnelTypeDriver):
try:
self._initialize(cfg.CONF.ml2_type_gre.tunnel_id_ranges)
except exc.NetworkTunnelRangeError:
LOG.exception(_("Failed to parse tunnel_id_ranges. "
"Service terminated!"))
LOG.exception(_LE("Failed to parse tunnel_id_ranges. "
"Service terminated!"))
raise SystemExit()
def sync_allocations(self):
@ -84,7 +84,7 @@ class GreTypeDriver(type_tunnel.TunnelTypeDriver):
tun_min, tun_max = gre_id_range
if tun_max + 1 - tun_min > 1000000:
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})
else:
gre_ids |= set(moves.xrange(tun_min, tun_max + 1))
@ -129,5 +129,5 @@ class GreTypeDriver(type_tunnel.TunnelTypeDriver):
except db_exc.DBDuplicateEntry:
gre_endpoint = (session.query(GreEndpoints).
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

View File

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

View File

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

View File

@ -22,7 +22,7 @@ from sqlalchemy import sql
from neutron.common import exceptions as exc
from neutron.db import api as db_api
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.plugins.common import constants as p_const
from neutron.plugins.ml2.drivers import type_tunnel
@ -79,8 +79,8 @@ class VxlanTypeDriver(type_tunnel.TunnelTypeDriver):
try:
self._initialize(cfg.CONF.ml2_type_vxlan.vni_ranges)
except exc.NetworkTunnelRangeError:
LOG.exception(_("Failed to parse vni_ranges. "
"Service terminated!"))
LOG.exception(_LE("Failed to parse vni_ranges. "
"Service terminated!"))
raise SystemExit()
def sync_allocations(self):
@ -129,7 +129,7 @@ class VxlanTypeDriver(type_tunnel.TunnelTypeDriver):
def get_endpoints(self):
"""Get every vxlan endpoints from database."""
LOG.debug(_("get_vxlan_endpoints() called"))
LOG.debug("get_vxlan_endpoints() called")
session = db_api.get_session()
with session.begin(subtransactions=True):
@ -139,7 +139,7 @@ class VxlanTypeDriver(type_tunnel.TunnelTypeDriver):
for vxlan_endpoint in vxlan_endpoints]
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()
try:
vxlan_endpoint = VxlanEndpoints(ip_address=ip,
@ -148,5 +148,5 @@ class VxlanTypeDriver(type_tunnel.TunnelTypeDriver):
except db_exc.DBDuplicateEntry:
vxlan_endpoint = (session.query(VxlanEndpoints).
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

View File

@ -21,6 +21,7 @@ from neutron.common import exceptions as exc
from neutron.extensions import multiprovidernet as mpnet
from neutron.extensions import portbindings
from neutron.extensions import providernet as provider
from neutron.openstack.common.gettextutils import _LE, _LI, _LW
from neutron.openstack.common import log
from neutron.plugins.ml2.common import exceptions as ml2_exc
from neutron.plugins.ml2 import db
@ -36,12 +37,12 @@ class TypeManager(stevedore.named.NamedExtensionManager):
# Mapping from type name to DriverManager
self.drivers = {}
LOG.info(_("Configured type driver names: %s"),
LOG.info(_LI("Configured type driver names: %s"),
cfg.CONF.ml2.type_drivers)
super(TypeManager, self).__init__('neutron.ml2.type_drivers',
cfg.CONF.ml2.type_drivers,
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._check_tenant_network_types(cfg.CONF.ml2.tenant_network_types)
@ -49,15 +50,15 @@ class TypeManager(stevedore.named.NamedExtensionManager):
for ext in self:
network_type = ext.obj.get_type()
if network_type in self.drivers:
LOG.error(_("Type driver '%(new_driver)s' ignored because type"
" driver '%(old_driver)s' is already registered"
" for type '%(type)s'"),
LOG.error(_LE("Type driver '%(new_driver)s' ignored because"
" type driver '%(old_driver)s' is already"
" registered for type '%(type)s'"),
{'new_driver': ext.name,
'old_driver': self.drivers[network_type].name,
'type': network_type})
else:
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):
self.tenant_network_types = []
@ -65,11 +66,10 @@ class TypeManager(stevedore.named.NamedExtensionManager):
if network_type in self.drivers:
self.tenant_network_types.append(network_type)
else:
msg = _("No type driver for tenant network_type: %s. "
"Service terminated!") % network_type
LOG.error(msg)
LOG.error(_LE("No type driver for tenant network_type: %s. "
"Service terminated!"), network_type)
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):
network_type = self._get_attribute(segment, provider.NETWORK_TYPE)
@ -124,7 +124,7 @@ class TypeManager(stevedore.named.NamedExtensionManager):
id = network['id']
segments = db.get_network_segments(context.session, id)
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.PHYSICAL_NETWORK] = None
network[provider.SEGMENTATION_ID] = None
@ -142,7 +142,7 @@ class TypeManager(stevedore.named.NamedExtensionManager):
def initialize(self):
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()
def create_network_segments(self, context, network, tenant_id):
@ -202,8 +202,8 @@ class TypeManager(stevedore.named.NamedExtensionManager):
if driver:
driver.obj.release_segment(session, segment)
else:
LOG.error(_("Failed to release segment '%s' because "
"network type is not supported."), segment)
LOG.error(_LE("Failed to release segment '%s' because "
"network type is not supported."), segment)
def allocate_dynamic_segment(self, session, network_id, segment):
"""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)
db.delete_network_segment(session, segment_id)
else:
LOG.error(_("Failed to release segment '%s' because "
"network type is not supported."), segment)
LOG.error(_LE("Failed to release segment '%s' because "
"network type is not supported."), segment)
else:
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.
self.ordered_mech_drivers = []
LOG.info(_("Configured mechanism driver names: %s"),
LOG.info(_LI("Configured mechanism driver names: %s"),
cfg.CONF.ml2.mechanism_drivers)
super(MechanismManager, self).__init__('neutron.ml2.mechanism_drivers',
cfg.CONF.ml2.mechanism_drivers,
invoke_on_load=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()
def _register_mechanisms(self):
@ -263,14 +263,14 @@ class MechanismManager(stevedore.named.NamedExtensionManager):
for ext in self:
self.mech_drivers[ext.name] = 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])
def initialize(self):
# For ML2 to support bulk operations, each driver must support them
self.native_bulk_support = True
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()
self.native_bulk_support &= getattr(driver.obj,
'native_bulk_support', True)
@ -292,7 +292,7 @@ class MechanismManager(stevedore.named.NamedExtensionManager):
getattr(driver.obj, method_name)(context)
except 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}
)
error = True
@ -594,11 +594,11 @@ class MechanismManager(stevedore.named.NamedExtensionManager):
'segment': binding.segment})
return
except Exception:
LOG.exception(_("Mechanism driver %s failed in "
"bind_port"),
LOG.exception(_LE("Mechanism driver %s failed in "
"bind_port"),
driver.name)
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'],
'host': binding.host})
@ -611,13 +611,13 @@ class ExtensionManager(stevedore.named.NamedExtensionManager):
# the order in which the drivers are called.
self.ordered_ext_drivers = []
LOG.info(_("Configured extension driver names: %s"),
LOG.info(_LI("Configured extension driver names: %s"),
cfg.CONF.ml2.extension_drivers)
super(ExtensionManager, self).__init__('neutron.ml2.extension_drivers',
cfg.CONF.ml2.extension_drivers,
invoke_on_load=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()
def _register_drivers(self):
@ -628,13 +628,13 @@ class ExtensionManager(stevedore.named.NamedExtensionManager):
"""
for ext in self:
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])
def initialize(self):
# Initialize each driver in the list.
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()
def extension_aliases(self):
@ -642,7 +642,7 @@ class ExtensionManager(stevedore.named.NamedExtensionManager):
for driver in self.ordered_ext_drivers:
alias = driver.obj.extension_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})
return exts
@ -653,7 +653,7 @@ class ExtensionManager(stevedore.named.NamedExtensionManager):
getattr(driver.obj, method_name)(session, data, result)
except 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}
)
@ -689,19 +689,19 @@ class ExtensionManager(stevedore.named.NamedExtensionManager):
"""Notify all extension drivers to extend network dictionary."""
for driver in self.ordered_ext_drivers:
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})
def extend_subnet_dict(self, session, result):
"""Notify all extension drivers to extend subnet dictionary."""
for driver in self.ordered_ext_drivers:
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})
def extend_port_dict(self, session, result):
"""Notify all extension drivers to extend port dictionary."""
for driver in self.ordered_ext_drivers:
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})

View File

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

View File

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