"neutron/openstack",
"neutron/scheduler",
"neutron/server",
- "neutron/services"]
+ "neutron/services",
+ "neutron/plugins/ml2"]
return any([dir in filename for dir in dirs])
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
)
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})
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()
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
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
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 '
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
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/' %
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"' % (
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')
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
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
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)
# 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
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
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
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."""
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.
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.
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."""
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
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)
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,
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
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']
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']
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."""
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']
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']
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']
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']
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):
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
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
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):
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):
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):
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,
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,
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):
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,
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):
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
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
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,
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,
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):
# 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()
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)
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
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,
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,
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,
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
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)
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,
"""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,
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)
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
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
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
{"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()
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
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 = {}
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
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
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})
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,
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
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
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
"""
def initialize(self):
- LOG.debug(_('Initializing driver'))
+ LOG.debug('Initializing driver')
# register plugin config opts
pl_config.register_config()
# 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):
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'],
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
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':
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]
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
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],
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]
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
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):
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)
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]
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
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
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:
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)
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
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):
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))
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
# 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
"""
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
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
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
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()
# 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})
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})
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
'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})
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
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):
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):
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,
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
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
# 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)
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 = []
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)
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
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):
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."""
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)
# 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):
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)
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
'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})
# 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):
"""
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):
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
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}
)
"""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})
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
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)
# 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
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 {}
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 {}
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
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
# 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:
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.
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)
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:
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:
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:
# 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):
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
# 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
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:
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:
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:
# 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']
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
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
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
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)
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)
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
# 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):
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)
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(
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
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,
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
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}
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'],
'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):
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}
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