diff --git a/neutron/plugins/ml2/driver_api.py b/neutron/plugins/ml2/driver_api.py index 4ca1a3c97cb..d66c3dc59f1 100644 --- a/neutron/plugins/ml2/driver_api.py +++ b/neutron/plugins/ml2/driver_api.py @@ -15,25 +15,20 @@ import abc +from neutron_lib.plugins.ml2 import api import six -# The following keys are used in the segment dictionaries passed via -# the driver API. These are defined separately from similar keys in -# neutron.extensions.providernet so that drivers don't need to change -# if/when providernet moves to the core API. -# -ID = 'id' -NETWORK_TYPE = 'network_type' -PHYSICAL_NETWORK = 'physical_network' -SEGMENTATION_ID = 'segmentation_id' -MTU = 'mtu' -NETWORK_ID = 'network_id' -# The following keys are used in the binding level dictionaries -# available via the binding_levels and original_binding_levels -# PortContext properties. -BOUND_DRIVER = 'bound_driver' -BOUND_SEGMENT = 'bound_segment' +# TODO(boden): remove once consumers are moved over to lib's version +MechanismDriver = api.MechanismDriver +ID = api.ID +NETWORK_TYPE = api.NETWORK_TYPE +PHYSICAL_NETWORK = api.PHYSICAL_NETWORK +SEGMENTATION_ID = api.SEGMENTATION_ID +MTU = api.MTU +NETWORK_ID = api.NETWORK_ID +BOUND_DRIVER = api.BOUND_DRIVER +BOUND_SEGMENT = api.BOUND_SEGMENT @six.add_metaclass(abc.ABCMeta) @@ -626,387 +621,6 @@ class PortContext(object): pass -@six.add_metaclass(abc.ABCMeta) -class MechanismDriver(object): - """Define stable abstract interface for ML2 mechanism drivers. - - A mechanism driver is called on the creation, update, and deletion - of networks and ports. For every event, there are two methods that - get called - one within the database transaction (method suffix of - _precommit), one right afterwards (method suffix of _postcommit). - - Exceptions raised by methods called inside the transaction can - rollback, but should not make any blocking calls (for example, - REST requests to an outside controller). Methods called after - transaction commits can make blocking external calls, though these - will block the entire process. Exceptions raised in calls after - the transaction commits may cause the associated resource to be - deleted. - - Because rollback outside of the transaction is not done in the - update network/port case, all data validation must be done within - methods that are part of the database transaction. - """ - - @abc.abstractmethod - def initialize(self): - """Perform driver initialization. - - Called after all drivers have been loaded and the database has - been initialized. No abstract methods defined below will be - called prior to this method being called. - """ - pass - - def create_network_precommit(self, context): - """Allocate resources for a new network. - - :param context: NetworkContext instance describing the new - network. - - Create a new network, allocating resources as necessary in the - database. Called inside transaction context on session. Call - cannot block. Raising an exception will result in a rollback - of the current transaction. - """ - pass - - def create_network_postcommit(self, context): - """Create a network. - - :param context: NetworkContext instance describing the new - network. - - Called after the transaction commits. Call can block, though - will block the entire process so care should be taken to not - drastically affect performance. Raising an exception will - cause the deletion of the resource. - """ - pass - - def update_network_precommit(self, context): - """Update resources of a network. - - :param context: NetworkContext instance describing the new - state of the network, as well as the original state prior - to the update_network call. - - Update values of a network, updating the associated resources - in the database. Called inside transaction context on session. - Raising an exception will result in rollback of the - transaction. - - update_network_precommit is called for all changes to the - network state. It is up to the mechanism driver to ignore - state or state changes that it does not know or care about. - """ - pass - - def update_network_postcommit(self, context): - """Update a network. - - :param context: NetworkContext instance describing the new - state of the network, as well as the original state prior - to the update_network call. - - Called after the transaction commits. Call can block, though - will block the entire process so care should be taken to not - drastically affect performance. Raising an exception will - cause the deletion of the resource. - - update_network_postcommit is called for all changes to the - network state. It is up to the mechanism driver to ignore - state or state changes that it does not know or care about. - """ - pass - - def delete_network_precommit(self, context): - """Delete resources for a network. - - :param context: NetworkContext instance describing the current - state of the network, prior to the call to delete it. - - Delete network resources previously allocated by this - mechanism driver for a network. Called inside transaction - context on session. Runtime errors are not expected, but - raising an exception will result in rollback of the - transaction. - """ - pass - - def delete_network_postcommit(self, context): - """Delete a network. - - :param context: NetworkContext instance describing the current - state of the network, prior to the call to delete it. - - Called after the transaction commits. Call can block, though - will block the entire process so care should be taken to not - drastically affect performance. Runtime errors are not - expected, and will not prevent the resource from being - deleted. - """ - pass - - def create_subnet_precommit(self, context): - """Allocate resources for a new subnet. - - :param context: SubnetContext instance describing the new - subnet. - - Create a new subnet, allocating resources as necessary in the - database. Called inside transaction context on session. Call - cannot block. Raising an exception will result in a rollback - of the current transaction. - """ - pass - - def create_subnet_postcommit(self, context): - """Create a subnet. - - :param context: SubnetContext instance describing the new - subnet. - - Called after the transaction commits. Call can block, though - will block the entire process so care should be taken to not - drastically affect performance. Raising an exception will - cause the deletion of the resource. - """ - pass - - def update_subnet_precommit(self, context): - """Update resources of a subnet. - - :param context: SubnetContext instance describing the new - state of the subnet, as well as the original state prior - to the update_subnet call. - - Update values of a subnet, updating the associated resources - in the database. Called inside transaction context on session. - Raising an exception will result in rollback of the - transaction. - - update_subnet_precommit is called for all changes to the - subnet state. It is up to the mechanism driver to ignore - state or state changes that it does not know or care about. - """ - pass - - def update_subnet_postcommit(self, context): - """Update a subnet. - - :param context: SubnetContext instance describing the new - state of the subnet, as well as the original state prior - to the update_subnet call. - - Called after the transaction commits. Call can block, though - will block the entire process so care should be taken to not - drastically affect performance. Raising an exception will - cause the deletion of the resource. - - update_subnet_postcommit is called for all changes to the - subnet state. It is up to the mechanism driver to ignore - state or state changes that it does not know or care about. - """ - pass - - def delete_subnet_precommit(self, context): - """Delete resources for a subnet. - - :param context: SubnetContext instance describing the current - state of the subnet, prior to the call to delete it. - - Delete subnet resources previously allocated by this - mechanism driver for a subnet. Called inside transaction - context on session. Runtime errors are not expected, but - raising an exception will result in rollback of the - transaction. - """ - pass - - def delete_subnet_postcommit(self, context): - """Delete a subnet. - - :param context: SubnetContext instance describing the current - state of the subnet, prior to the call to delete it. - - Called after the transaction commits. Call can block, though - will block the entire process so care should be taken to not - drastically affect performance. Runtime errors are not - expected, and will not prevent the resource from being - deleted. - """ - pass - - def create_port_precommit(self, context): - """Allocate resources for a new port. - - :param context: PortContext instance describing the port. - - Create a new port, allocating resources as necessary in the - database. Called inside transaction context on session. Call - cannot block. Raising an exception will result in a rollback - of the current transaction. - """ - pass - - def create_port_postcommit(self, context): - """Create a port. - - :param context: PortContext instance describing the port. - - Called after the transaction completes. Call can block, though - will block the entire process so care should be taken to not - drastically affect performance. Raising an exception will - result in the deletion of the resource. - """ - pass - - def update_port_precommit(self, context): - """Update resources of a port. - - :param context: PortContext instance describing the new - state of the port, as well as the original state prior - to the update_port call. - - Called inside transaction context on session to complete a - port update as defined by this mechanism driver. Raising an - exception will result in rollback of the transaction. - - update_port_precommit is called for all changes to the port - state. It is up to the mechanism driver to ignore state or - state changes that it does not know or care about. - """ - pass - - def update_port_postcommit(self, context): - """Update a port. - - :param context: PortContext instance describing the new - state of the port, as well as the original state prior - to the update_port call. - - Called after the transaction completes. Call can block, though - will block the entire process so care should be taken to not - drastically affect performance. Raising an exception will - result in the deletion of the resource. - - update_port_postcommit is called for all changes to the port - state. It is up to the mechanism driver to ignore state or - state changes that it does not know or care about. - """ - pass - - def delete_port_precommit(self, context): - """Delete resources of a port. - - :param context: PortContext instance describing the current - state of the port, prior to the call to delete it. - - Called inside transaction context on session. Runtime errors - are not expected, but raising an exception will result in - rollback of the transaction. - """ - pass - - def delete_port_postcommit(self, context): - """Delete a port. - - :param context: PortContext instance describing the current - state of the port, prior to the call to delete it. - - Called after the transaction completes. Call can block, though - will block the entire process so care should be taken to not - drastically affect performance. Runtime errors are not - expected, and will not prevent the resource from being - deleted. - """ - pass - - def bind_port(self, context): - """Attempt to bind a port. - - :param context: PortContext instance describing the port - - This method is called outside any transaction to attempt to - establish a port binding using this mechanism driver. Bindings - may be created at each of multiple levels of a hierarchical - network, and are established from the top level downward. At - each level, the mechanism driver determines whether it can - bind to any of the network segments in the - context.segments_to_bind property, based on the value of the - context.host property, any relevant port or network - attributes, and its own knowledge of the network topology. At - the top level, context.segments_to_bind contains the static - segments of the port's network. At each lower level of - binding, it contains static or dynamic segments supplied by - the driver that bound at the level above. If the driver is - able to complete the binding of the port to any segment in - context.segments_to_bind, it must call context.set_binding - with the binding details. If it can partially bind the port, - it must call context.continue_binding with the network - segments to be used to bind at the next lower level. - - If the binding results are committed after bind_port returns, - they will be seen by all mechanism drivers as - update_port_precommit and update_port_postcommit calls. But if - some other thread or process concurrently binds or updates the - port, these binding results will not be committed, and - update_port_precommit and update_port_postcommit will not be - called on the mechanism drivers with these results. Because - binding results can be discarded rather than committed, - drivers should avoid making persistent state changes in - bind_port, or else must ensure that such state changes are - eventually cleaned up. - - Implementing this method explicitly declares the mechanism - driver as having the intention to bind ports. This is inspected - by the QoS service to identify the available QoS rules you - can use with ports. - """ - pass - - @property - def _supports_port_binding(self): - return self.__class__.bind_port != MechanismDriver.bind_port - - def check_vlan_transparency(self, context): - """Check if the network supports vlan transparency. - - :param context: NetworkContext instance describing the network. - - Check if the network supports vlan transparency or not. - """ - pass - - def get_workers(self): - """Get any worker instances that should have their own process - - Any driver that needs to run processes separate from the API or RPC - workers, can return a sequence of worker instances. - """ - return () - - @classmethod - def is_host_filtering_supported(cls): - return (cls.filter_hosts_with_segment_access != - MechanismDriver.filter_hosts_with_segment_access) - - def filter_hosts_with_segment_access( - self, context, segments, candidate_hosts, agent_getter): - """Filter hosts with access to at least one segment. - - :returns: a set with a subset of candidate_hosts. - - A driver can overload this method to return a subset of candidate_hosts - with the ones with access to at least one segment. - - Default implementation returns all hosts to disable filtering - (backward compatibility). - """ - return candidate_hosts - - @six.add_metaclass(abc.ABCMeta) class ExtensionDriver(object): """Define stable abstract interface for ML2 extension drivers. diff --git a/neutron/plugins/ml2/driver_context.py b/neutron/plugins/ml2/driver_context.py index b94d2dd8efb..cf70ccac90a 100644 --- a/neutron/plugins/ml2/driver_context.py +++ b/neutron/plugins/ml2/driver_context.py @@ -17,6 +17,7 @@ import copy from neutron_lib.api.definitions import portbindings from neutron_lib import constants +from neutron_lib.plugins.ml2 import api as ml2_api from oslo_log import log from oslo_serialization import jsonutils @@ -174,16 +175,16 @@ class PortContext(MechanismDriverContext, api.PortContext): def binding_levels(self): if self._binding_levels: return [{ - api.BOUND_DRIVER: level.driver, - api.BOUND_SEGMENT: self._expand_segment(level.segment_id) + ml2_api.BOUND_DRIVER: level.driver, + ml2_api.BOUND_SEGMENT: self._expand_segment(level.segment_id) } for level in self._binding_levels] @property def original_binding_levels(self): if self._original_binding_levels: return [{ - api.BOUND_DRIVER: level.driver, - api.BOUND_SEGMENT: self._expand_segment(level.segment_id) + ml2_api.BOUND_DRIVER: level.driver, + ml2_api.BOUND_SEGMENT: self._expand_segment(level.segment_id) } for level in self._original_binding_levels] @property diff --git a/neutron/plugins/ml2/drivers/l2pop/mech_driver.py b/neutron/plugins/ml2/drivers/l2pop/mech_driver.py index 0c3f5012e9f..c57643f8bad 100644 --- a/neutron/plugins/ml2/drivers/l2pop/mech_driver.py +++ b/neutron/plugins/ml2/drivers/l2pop/mech_driver.py @@ -17,6 +17,7 @@ from neutron_lib import constants as const from neutron_lib import context as n_context from neutron_lib import exceptions from neutron_lib.plugins import directory +from neutron_lib.plugins.ml2 import api from oslo_config import cfg from oslo_log import log as logging @@ -24,7 +25,6 @@ from neutron._i18n import _, _LW from neutron.conf.plugins.ml2.drivers import l2pop as config from neutron.db import api as db_api from neutron.db import l3_hamode_db -from neutron.plugins.ml2 import driver_api as api from neutron.plugins.ml2.drivers.l2pop import db as l2pop_db from neutron.plugins.ml2.drivers.l2pop import rpc as l2pop_rpc diff --git a/neutron/plugins/ml2/drivers/macvtap/mech_driver/mech_macvtap.py b/neutron/plugins/ml2/drivers/macvtap/mech_driver/mech_macvtap.py index 309cbb3b4b0..4e6a1a30b86 100644 --- a/neutron/plugins/ml2/drivers/macvtap/mech_driver/mech_macvtap.py +++ b/neutron/plugins/ml2/drivers/macvtap/mech_driver/mech_macvtap.py @@ -17,10 +17,10 @@ from neutron._i18n import _LE from neutron_lib.api.definitions import portbindings from neutron_lib import constants +from neutron_lib.plugins.ml2 import api from oslo_log import log from neutron.plugins.common import constants as p_constants -from neutron.plugins.ml2 import driver_api as api from neutron.plugins.ml2.drivers.macvtap import macvtap_common from neutron.plugins.ml2.drivers import mech_agent diff --git a/neutron/plugins/ml2/drivers/mech_agent.py b/neutron/plugins/ml2/drivers/mech_agent.py index e22c7668569..7d26b4c56f9 100644 --- a/neutron/plugins/ml2/drivers/mech_agent.py +++ b/neutron/plugins/ml2/drivers/mech_agent.py @@ -18,13 +18,13 @@ import abc from neutron_lib.api.definitions import portbindings from neutron_lib.callbacks import resources from neutron_lib import constants as const +from neutron_lib.plugins.ml2 import api from oslo_log import log import six from neutron._i18n import _LW from neutron.db import provisioning_blocks from neutron.plugins.common import constants as p_constants -from neutron.plugins.ml2 import driver_api as api LOG = log.getLogger(__name__) diff --git a/neutron/plugins/ml2/drivers/mech_sriov/mech_driver/mech_driver.py b/neutron/plugins/ml2/drivers/mech_sriov/mech_driver/mech_driver.py index 3ee731aaea9..443c59a9842 100644 --- a/neutron/plugins/ml2/drivers/mech_sriov/mech_driver/mech_driver.py +++ b/neutron/plugins/ml2/drivers/mech_sriov/mech_driver/mech_driver.py @@ -15,11 +15,11 @@ from neutron_lib.api.definitions import portbindings from neutron_lib import constants +from neutron_lib.plugins.ml2 import api from oslo_log import log from neutron._i18n import _LW from neutron.plugins.common import constants as p_const -from neutron.plugins.ml2 import driver_api as api from neutron.plugins.ml2.drivers import mech_agent from neutron.plugins.ml2.drivers.mech_sriov.mech_driver \ import exceptions as exc diff --git a/neutron/plugins/ml2/drivers/type_flat.py b/neutron/plugins/ml2/drivers/type_flat.py index 7db1fac1403..7f493b05ac4 100644 --- a/neutron/plugins/ml2/drivers/type_flat.py +++ b/neutron/plugins/ml2/drivers/type_flat.py @@ -14,6 +14,7 @@ # under the License. from neutron_lib import exceptions as exc +from neutron_lib.plugins.ml2 import api from oslo_config import cfg from oslo_log import log @@ -24,7 +25,6 @@ from neutron.db import api as db_api from neutron.objects import exceptions as obj_base from neutron.objects.plugins.ml2 import flatallocation as flat_obj from neutron.plugins.common import constants as p_const -from neutron.plugins.ml2 import driver_api as api from neutron.plugins.ml2.drivers import helpers LOG = log.getLogger(__name__) diff --git a/neutron/plugins/ml2/drivers/type_local.py b/neutron/plugins/ml2/drivers/type_local.py index 89378d8a5e3..4a7c4892650 100644 --- a/neutron/plugins/ml2/drivers/type_local.py +++ b/neutron/plugins/ml2/drivers/type_local.py @@ -14,16 +14,17 @@ # under the License. from neutron_lib import exceptions as exc +from neutron_lib.plugins.ml2 import api from oslo_log import log from neutron._i18n import _, _LI from neutron.plugins.common import constants as p_const -from neutron.plugins.ml2 import driver_api as api +from neutron.plugins.ml2 import driver_api LOG = log.getLogger(__name__) -class LocalTypeDriver(api.ML2TypeDriver): +class LocalTypeDriver(driver_api.ML2TypeDriver): """Manage state for local networks with ML2. The LocalTypeDriver implements the 'local' network_type. Local diff --git a/neutron/plugins/ml2/drivers/type_tunnel.py b/neutron/plugins/ml2/drivers/type_tunnel.py index cb6e076fb06..7dd79c042b3 100644 --- a/neutron/plugins/ml2/drivers/type_tunnel.py +++ b/neutron/plugins/ml2/drivers/type_tunnel.py @@ -19,6 +19,7 @@ import operator import netaddr from neutron_lib import context from neutron_lib import exceptions as exc +from neutron_lib.plugins.ml2 import api from oslo_config import cfg from oslo_db import exception as db_exc from oslo_log import log @@ -31,7 +32,6 @@ from neutron.common import topics from neutron.db import api as db_api from neutron.plugins.common import constants as p_const from neutron.plugins.common import utils as plugin_utils -from neutron.plugins.ml2 import driver_api as api from neutron.plugins.ml2.drivers import helpers LOG = log.getLogger(__name__) diff --git a/neutron/plugins/ml2/drivers/type_vlan.py b/neutron/plugins/ml2/drivers/type_vlan.py index fc33981e3a5..0a8fbf1bc77 100644 --- a/neutron/plugins/ml2/drivers/type_vlan.py +++ b/neutron/plugins/ml2/drivers/type_vlan.py @@ -17,6 +17,7 @@ import sys from neutron_lib import context from neutron_lib import exceptions as exc +from neutron_lib.plugins.ml2 import api from oslo_config import cfg from oslo_log import log from six import moves @@ -27,7 +28,6 @@ from neutron.db import api as db_api from neutron.db.models.plugins.ml2 import vlanallocation as vlan_alloc_model from neutron.plugins.common import constants as p_const from neutron.plugins.common import utils as plugin_utils -from neutron.plugins.ml2 import driver_api as api from neutron.plugins.ml2.drivers import helpers LOG = log.getLogger(__name__) diff --git a/neutron/plugins/ml2/managers.py b/neutron/plugins/ml2/managers.py index 244561c430e..d4930e37abf 100644 --- a/neutron/plugins/ml2/managers.py +++ b/neutron/plugins/ml2/managers.py @@ -18,6 +18,7 @@ from neutron_lib.api.definitions import provider_net as provider from neutron_lib.api import validators from neutron_lib import constants from neutron_lib import exceptions as exc +from neutron_lib.plugins.ml2 import api as ml2_api from oslo_config import cfg from oslo_log import log from oslo_utils import excutils @@ -92,9 +93,9 @@ class TypeManager(stevedore.named.NamedExtensionManager): for attr in provider.ATTRIBUTES) if validators.is_attr_set(network_type): - segment = {api.NETWORK_TYPE: network_type, - api.PHYSICAL_NETWORK: physical_network, - api.SEGMENTATION_ID: segmentation_id} + segment = {ml2_api.NETWORK_TYPE: network_type, + ml2_api.PHYSICAL_NETWORK: physical_network, + ml2_api.SEGMENTATION_ID: segmentation_id} self.validate_provider_segment(segment) return segment @@ -166,15 +167,17 @@ class TypeManager(stevedore.named.NamedExtensionManager): network[attr] = None elif len(segments) > 1: network[mpnet.SEGMENTS] = [ - {provider.NETWORK_TYPE: segment[api.NETWORK_TYPE], - provider.PHYSICAL_NETWORK: segment[api.PHYSICAL_NETWORK], - provider.SEGMENTATION_ID: segment[api.SEGMENTATION_ID]} + {provider.NETWORK_TYPE: segment[ml2_api.NETWORK_TYPE], + provider.PHYSICAL_NETWORK: segment[ml2_api.PHYSICAL_NETWORK], + provider.SEGMENTATION_ID: segment[ml2_api.SEGMENTATION_ID]} for segment in segments] else: segment = segments[0] - network[provider.NETWORK_TYPE] = segment[api.NETWORK_TYPE] - network[provider.PHYSICAL_NETWORK] = segment[api.PHYSICAL_NETWORK] - network[provider.SEGMENTATION_ID] = segment[api.SEGMENTATION_ID] + network[provider.NETWORK_TYPE] = segment[ml2_api.NETWORK_TYPE] + network[provider.PHYSICAL_NETWORK] = segment[ + ml2_api.PHYSICAL_NETWORK] + network[provider.SEGMENTATION_ID] = segment[ + ml2_api.SEGMENTATION_ID] def initialize(self): for network_type, driver in self.drivers.items(): @@ -208,16 +211,16 @@ class TypeManager(stevedore.named.NamedExtensionManager): def reserve_network_segment(self, context, segment_data): """Call type drivers to reserve a network segment.""" # Validate the data of segment - if not validators.is_attr_set(segment_data[api.NETWORK_TYPE]): + if not validators.is_attr_set(segment_data[ml2_api.NETWORK_TYPE]): msg = _("network_type required") raise exc.InvalidInput(error_message=msg) - net_type = self._get_attribute(segment_data, api.NETWORK_TYPE) - phys_net = self._get_attribute(segment_data, api.PHYSICAL_NETWORK) - seg_id = self._get_attribute(segment_data, api.SEGMENTATION_ID) - segment = {api.NETWORK_TYPE: net_type, - api.PHYSICAL_NETWORK: phys_net, - api.SEGMENTATION_ID: seg_id} + net_type = self._get_attribute(segment_data, ml2_api.NETWORK_TYPE) + phys_net = self._get_attribute(segment_data, ml2_api.PHYSICAL_NETWORK) + seg_id = self._get_attribute(segment_data, ml2_api.SEGMENTATION_ID) + segment = {ml2_api.NETWORK_TYPE: net_type, + ml2_api.PHYSICAL_NETWORK: phys_net, + ml2_api.SEGMENTATION_ID: seg_id} self.validate_provider_segment(segment) @@ -226,7 +229,7 @@ class TypeManager(stevedore.named.NamedExtensionManager): return self.reserve_provider_segment(context, segment) def is_partial_segment(self, segment): - network_type = segment[api.NETWORK_TYPE] + network_type = segment[ml2_api.NETWORK_TYPE] driver = self.drivers.get(network_type) if driver: return driver.obj.is_partial_segment(segment) @@ -235,7 +238,7 @@ class TypeManager(stevedore.named.NamedExtensionManager): raise exc.InvalidInput(error_message=msg) def validate_provider_segment(self, segment): - network_type = segment[api.NETWORK_TYPE] + network_type = segment[ml2_api.NETWORK_TYPE] driver = self.drivers.get(network_type) if driver: driver.obj.validate_provider_segment(segment) @@ -244,7 +247,7 @@ class TypeManager(stevedore.named.NamedExtensionManager): raise exc.InvalidInput(error_message=msg) def reserve_provider_segment(self, context, segment): - network_type = segment.get(api.NETWORK_TYPE) + network_type = segment.get(ml2_api.NETWORK_TYPE) driver = self.drivers.get(network_type) if isinstance(driver.obj, api.TypeDriver): return driver.obj.reserve_provider_segment(context.session, @@ -282,7 +285,7 @@ class TypeManager(stevedore.named.NamedExtensionManager): self.release_network_segment(context, segment) def release_network_segment(self, context, segment): - network_type = segment.get(api.NETWORK_TYPE) + network_type = segment.get(ml2_api.NETWORK_TYPE) driver = self.drivers.get(network_type) if driver: if isinstance(driver.obj, api.TypeDriver): @@ -296,13 +299,13 @@ class TypeManager(stevedore.named.NamedExtensionManager): def allocate_dynamic_segment(self, context, network_id, segment): """Allocate a dynamic segment using a partial or full segment dict.""" dynamic_segment = segments_db.get_dynamic_segment( - context, network_id, segment.get(api.PHYSICAL_NETWORK), - segment.get(api.SEGMENTATION_ID)) + context, network_id, segment.get(ml2_api.PHYSICAL_NETWORK), + segment.get(ml2_api.SEGMENTATION_ID)) if dynamic_segment: return dynamic_segment - driver = self.drivers.get(segment.get(api.NETWORK_TYPE)) + driver = self.drivers.get(segment.get(ml2_api.NETWORK_TYPE)) if isinstance(driver.obj, api.TypeDriver): dynamic_segment = driver.obj.reserve_provider_segment( context.session, segment) @@ -317,7 +320,7 @@ class TypeManager(stevedore.named.NamedExtensionManager): """Delete a dynamic segment.""" segment = segments_db.get_segment_by_id(context, segment_id) if segment: - driver = self.drivers.get(segment.get(api.NETWORK_TYPE)) + driver = self.drivers.get(segment.get(ml2_api.NETWORK_TYPE)) if driver: if isinstance(driver.obj, api.TypeDriver): driver.obj.release_segment(context.session, segment) @@ -847,7 +850,7 @@ class MechanismManager(stevedore.named.NamedExtensionManager): # level to one of the segments we are currently trying to # bind. Note that it is OK for the same driver to bind at # multiple levels using different segments. - segment_ids_to_bind = {s[api.SEGMENTATION_ID] + segment_ids_to_bind = {s[ml2_api.SEGMENTATION_ID] for s in segments_to_bind} for level in binding_levels: if (level.driver == driver and diff --git a/neutron/plugins/ml2/plugin.py b/neutron/plugins/ml2/plugin.py index b2018dab2b7..8c45f4ef50b 100644 --- a/neutron/plugins/ml2/plugin.py +++ b/neutron/plugins/ml2/plugin.py @@ -29,6 +29,7 @@ from neutron_lib import constants as const from neutron_lib import exceptions as exc from neutron_lib.exceptions import port_security as psec_exc from neutron_lib.plugins import directory +from neutron_lib.plugins.ml2 import api from oslo_config import cfg from oslo_db import exception as os_db_exception from oslo_log import helpers as log_helpers @@ -81,7 +82,6 @@ from neutron.extensions import vlantransparent from neutron.plugins.ml2.common import exceptions as ml2_exc from neutron.plugins.ml2 import config # noqa from neutron.plugins.ml2 import db -from neutron.plugins.ml2 import driver_api as api from neutron.plugins.ml2 import driver_context from neutron.plugins.ml2.extensions import qos as qos_ext from neutron.plugins.ml2 import managers diff --git a/neutron/plugins/ml2/rpc.py b/neutron/plugins/ml2/rpc.py index ada4dd66ee4..22ea803e20e 100644 --- a/neutron/plugins/ml2/rpc.py +++ b/neutron/plugins/ml2/rpc.py @@ -19,6 +19,7 @@ from neutron_lib.callbacks import resources from neutron_lib import constants as n_const from neutron_lib import exceptions from neutron_lib.plugins import directory +from neutron_lib.plugins.ml2 import api from oslo_log import log import oslo_messaging from sqlalchemy.orm import exc @@ -31,7 +32,6 @@ from neutron.common import topics from neutron.db import l3_hamode_db from neutron.db import provisioning_blocks from neutron.plugins.ml2 import db as ml2_db -from neutron.plugins.ml2 import driver_api as api from neutron.plugins.ml2.drivers import type_tunnel from neutron.services.qos import qos_consts # REVISIT(kmestery): Allow the type and mechanism drivers to supply the diff --git a/neutron/services/trunk/rules.py b/neutron/services/trunk/rules.py index 1e90e4a1e65..7cbed6f570c 100644 --- a/neutron/services/trunk/rules.py +++ b/neutron/services/trunk/rules.py @@ -18,11 +18,11 @@ from neutron_lib.api.definitions import provider_net as provider from neutron_lib.api import validators from neutron_lib import exceptions as n_exc from neutron_lib.plugins import directory +from neutron_lib.plugins.ml2 import api from neutron._i18n import _ from neutron.common import utils as n_utils from neutron.objects import trunk as trunk_objects -from neutron.plugins.ml2 import driver_api as api from neutron.services.trunk import constants from neutron.services.trunk import exceptions as trunk_exc from neutron.services.trunk import utils diff --git a/neutron/tests/unit/plugins/ml2/_test_mech_agent.py b/neutron/tests/unit/plugins/ml2/_test_mech_agent.py index 0734de426b8..1d5593c494a 100644 --- a/neutron/tests/unit/plugins/ml2/_test_mech_agent.py +++ b/neutron/tests/unit/plugins/ml2/_test_mech_agent.py @@ -14,6 +14,7 @@ # under the License. from neutron_lib.api.definitions import portbindings +from neutron_lib.plugins.ml2 import api as mech_api from neutron.plugins.ml2 import driver_api as api from neutron.tests import base @@ -77,8 +78,9 @@ class FakePortContext(api.PortContext): def binding_levels(self): if self._bound_segment: return [{ - api.BOUND_DRIVER: 'fake_driver', - api.BOUND_SEGMENT: self._expand_segment(self._bound_segment) + mech_api.BOUND_DRIVER: 'fake_driver', + mech_api.BOUND_SEGMENT: self._expand_segment( + self._bound_segment) }] @property @@ -103,7 +105,7 @@ class FakePortContext(api.PortContext): def _expand_segment(self, segment_id): for segment in self._network_context.network_segments: - if segment[api.ID] == self._bound_segment_id: + if segment[mech_api.ID] == self._bound_segment_id: return segment @property @@ -172,7 +174,7 @@ class AgentMechanismBaseTestCase(base.BaseTestCase): self.assertIsNone(context._bound_vif_details) def _check_bound(self, context, segment): - self.assertEqual(context._bound_segment_id, segment[api.ID]) + self.assertEqual(context._bound_segment_id, segment[mech_api.ID]) self.assertEqual(context._bound_vif_type, self.VIF_TYPE) vif_details = context._bound_vif_details self.assertIsNotNone(vif_details) @@ -190,9 +192,9 @@ class AgentMechanismBaseTestCase(base.BaseTestCase): class AgentMechanismGenericTestCase(AgentMechanismBaseTestCase): - UNKNOWN_TYPE_SEGMENTS = [{api.ID: 'unknown_segment_id', - api.NETWORK_TYPE: 'no_such_type', - api.NETWORK_ID: 'fake_network_id'}] + UNKNOWN_TYPE_SEGMENTS = [{mech_api.ID: 'unknown_segment_id', + mech_api.NETWORK_TYPE: 'no_such_type', + mech_api.NETWORK_ID: 'fake_network_id'}] def test_unknown_type(self): context = FakePortContext(self.AGENT_TYPE, @@ -204,12 +206,12 @@ class AgentMechanismGenericTestCase(AgentMechanismBaseTestCase): class AgentMechanismLocalTestCase(AgentMechanismBaseTestCase): - LOCAL_SEGMENTS = [{api.ID: 'unknown_segment_id', - api.NETWORK_TYPE: 'no_such_type', - api.NETWORK_ID: 'fake_network_id'}, - {api.ID: 'local_segment_id', - api.NETWORK_TYPE: 'local', - api.NETWORK_ID: 'fake_network_id'}] + LOCAL_SEGMENTS = [{mech_api.ID: 'unknown_segment_id', + mech_api.NETWORK_TYPE: 'no_such_type', + mech_api.NETWORK_ID: 'fake_network_id'}, + {mech_api.ID: 'local_segment_id', + mech_api.NETWORK_TYPE: 'local', + mech_api.NETWORK_ID: 'fake_network_id'}] def test_type_local(self): context = FakePortContext(self.AGENT_TYPE, @@ -229,13 +231,13 @@ class AgentMechanismLocalTestCase(AgentMechanismBaseTestCase): class AgentMechanismFlatTestCase(AgentMechanismBaseTestCase): - FLAT_SEGMENTS = [{api.ID: 'unknown_segment_id', - api.NETWORK_TYPE: 'no_such_type', - api.NETWORK_ID: 'fake_network_id'}, - {api.ID: 'flat_segment_id', - api.NETWORK_TYPE: 'flat', - api.PHYSICAL_NETWORK: 'fake_physical_network', - api.NETWORK_ID: 'fake_network_id'}] + FLAT_SEGMENTS = [{mech_api.ID: 'unknown_segment_id', + mech_api.NETWORK_TYPE: 'no_such_type', + mech_api.NETWORK_ID: 'fake_network_id'}, + {mech_api.ID: 'flat_segment_id', + mech_api.NETWORK_TYPE: 'flat', + mech_api.PHYSICAL_NETWORK: 'fake_physical_network', + mech_api.NETWORK_ID: 'fake_network_id'}] def test_type_flat(self): context = FakePortContext(self.AGENT_TYPE, @@ -255,14 +257,14 @@ class AgentMechanismFlatTestCase(AgentMechanismBaseTestCase): class AgentMechanismVlanTestCase(AgentMechanismBaseTestCase): - VLAN_SEGMENTS = [{api.ID: 'unknown_segment_id', - api.NETWORK_TYPE: 'no_such_type', - api.NETWORK_ID: 'fake_network_id'}, - {api.ID: 'vlan_segment_id', - api.NETWORK_TYPE: 'vlan', - api.PHYSICAL_NETWORK: 'fake_physical_network', - api.SEGMENTATION_ID: 1234, - api.NETWORK_ID: 'fake_network_id'}] + VLAN_SEGMENTS = [{mech_api.ID: 'unknown_segment_id', + mech_api.NETWORK_TYPE: 'no_such_type', + mech_api.NETWORK_ID: 'fake_network_id'}, + {mech_api.ID: 'vlan_segment_id', + mech_api.NETWORK_TYPE: 'vlan', + mech_api.PHYSICAL_NETWORK: 'fake_physical_network', + mech_api.SEGMENTATION_ID: 1234, + mech_api.NETWORK_ID: 'fake_network_id'}] def test_type_vlan(self): context = FakePortContext(self.AGENT_TYPE, @@ -282,13 +284,13 @@ class AgentMechanismVlanTestCase(AgentMechanismBaseTestCase): class AgentMechanismGreTestCase(AgentMechanismBaseTestCase): - GRE_SEGMENTS = [{api.ID: 'unknown_segment_id', - api.NETWORK_TYPE: 'no_such_type', - api.NETWORK_ID: 'fake_network_id'}, - {api.ID: 'gre_segment_id', - api.NETWORK_TYPE: 'gre', - api.SEGMENTATION_ID: 1234, - api.NETWORK_ID: 'fake_network_id'}] + GRE_SEGMENTS = [{mech_api.ID: 'unknown_segment_id', + mech_api.NETWORK_TYPE: 'no_such_type', + mech_api.NETWORK_ID: 'fake_network_id'}, + {mech_api.ID: 'gre_segment_id', + mech_api.NETWORK_TYPE: 'gre', + mech_api.SEGMENTATION_ID: 1234, + mech_api.NETWORK_ID: 'fake_network_id'}] def test_type_gre(self): context = FakePortContext(self.AGENT_TYPE, diff --git a/neutron/tests/unit/plugins/ml2/drivers/base_type_tunnel.py b/neutron/tests/unit/plugins/ml2/drivers/base_type_tunnel.py index ef9aa4588b9..1eed54e93cb 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/base_type_tunnel.py +++ b/neutron/tests/unit/plugins/ml2/drivers/base_type_tunnel.py @@ -16,13 +16,13 @@ import mock from neutron_lib import context from neutron_lib import exceptions as exc +from neutron_lib.plugins.ml2 import api from six import moves import testtools from testtools import matchers from neutron.plugins.common import constants as p_const from neutron.plugins.ml2 import config -from neutron.plugins.ml2 import driver_api as api from neutron.plugins.ml2.drivers import type_tunnel TUNNEL_IP_ONE = "10.10.10.10" diff --git a/neutron/tests/unit/plugins/ml2/drivers/macvtap/mech_driver/test_mech_macvtap.py b/neutron/tests/unit/plugins/ml2/drivers/macvtap/mech_driver/test_mech_macvtap.py index 535e7a210ca..f0300af53f1 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/macvtap/mech_driver/test_mech_macvtap.py +++ b/neutron/tests/unit/plugins/ml2/drivers/macvtap/mech_driver/test_mech_macvtap.py @@ -15,8 +15,8 @@ from neutron_lib.api.definitions import portbindings from neutron_lib import constants +from neutron_lib.plugins.ml2 import api -from neutron.plugins.ml2 import driver_api as api from neutron.plugins.ml2.drivers.macvtap.mech_driver import mech_macvtap from neutron.tests.unit.plugins.ml2 import _test_mech_agent as base diff --git a/neutron/tests/unit/plugins/ml2/drivers/mech_sriov/mech_driver/test_mech_sriov_nic_switch.py b/neutron/tests/unit/plugins/ml2/drivers/mech_sriov/mech_driver/test_mech_sriov_nic_switch.py index 227e7aa8e00..bc3a0498b8f 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/mech_sriov/mech_driver/test_mech_sriov_nic_switch.py +++ b/neutron/tests/unit/plugins/ml2/drivers/mech_sriov/mech_driver/test_mech_sriov_nic_switch.py @@ -15,10 +15,10 @@ from neutron_lib.api.definitions import portbindings from neutron_lib import constants +from neutron_lib.plugins.ml2 import api import testtools from neutron.plugins.common import constants as p_const -from neutron.plugins.ml2 import driver_api as api from neutron.plugins.ml2.drivers.mech_sriov.mech_driver \ import exceptions as exc from neutron.plugins.ml2.drivers.mech_sriov.mech_driver import mech_driver diff --git a/neutron/tests/unit/plugins/ml2/drivers/mechanism_logger.py b/neutron/tests/unit/plugins/ml2/drivers/mechanism_logger.py index 30f62eed8d0..cbee90a0f0c 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/mechanism_logger.py +++ b/neutron/tests/unit/plugins/ml2/drivers/mechanism_logger.py @@ -13,10 +13,10 @@ # License for the specific language governing permissions and limitations # under the License. +from neutron_lib.plugins.ml2 import api from oslo_log import log from neutron._i18n import _ -from neutron.plugins.ml2 import driver_api as api LOG = log.getLogger(__name__) diff --git a/neutron/tests/unit/plugins/ml2/drivers/mechanism_test.py b/neutron/tests/unit/plugins/ml2/drivers/mechanism_test.py index 678a69117ed..6bb6762ac1d 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/mechanism_test.py +++ b/neutron/tests/unit/plugins/ml2/drivers/mechanism_test.py @@ -15,11 +15,12 @@ from neutron_lib.api.definitions import portbindings from neutron_lib import constants as const +from neutron_lib.plugins.ml2 import api as mech_api from neutron.plugins.ml2 import driver_api as api -class TestMechanismDriver(api.MechanismDriver): +class TestMechanismDriver(mech_api.MechanismDriver): """Test mechanism driver for testing mechanism driver api.""" def initialize(self): @@ -93,7 +94,7 @@ class TestMechanismDriver(api.MechanismDriver): if context.vif_type in (portbindings.VIF_TYPE_UNBOUND, portbindings.VIF_TYPE_BINDING_FAILED): if (context.segments_to_bind and - context.segments_to_bind[0][api.NETWORK_TYPE] == 'vlan'): + context.segments_to_bind[0][mech_api.NETWORK_TYPE] == 'vlan'): # Partially bound. self._check_bound(context.binding_levels, context.top_bound_segment, @@ -172,13 +173,13 @@ class TestMechanismDriver(api.MechanismDriver): top_level = levels[0] assert(isinstance(top_level, dict)) assert(isinstance(top_segment, dict)) - assert(top_segment == top_level[api.BOUND_SEGMENT]) - assert('test' == top_level[api.BOUND_DRIVER]) + assert(top_segment == top_level[mech_api.BOUND_SEGMENT]) + assert('test' == top_level[mech_api.BOUND_DRIVER]) bottom_level = levels[-1] assert(isinstance(bottom_level, dict)) assert(isinstance(bottom_segment, dict)) - assert(bottom_segment == bottom_level[api.BOUND_SEGMENT]) - assert('test' == bottom_level[api.BOUND_DRIVER]) + assert(bottom_segment == bottom_level[mech_api.BOUND_SEGMENT]) + assert('test' == bottom_level[mech_api.BOUND_DRIVER]) def create_port_precommit(self, context): self._check_port_context(context, False) @@ -208,7 +209,7 @@ class TestMechanismDriver(api.MechanismDriver): host = context.host segment = context.segments_to_bind[0] - segment_id = segment[api.ID] + segment_id = segment[mech_api.ID] if host == "host-ovs-no_filter": context.set_binding(segment_id, portbindings.VIF_TYPE_OVS, {portbindings.CAP_PORT_FILTER: False}) @@ -223,11 +224,11 @@ class TestMechanismDriver(api.MechanismDriver): status=const.PORT_STATUS_ACTIVE) self.bound_ports.add((context.current['id'], host)) elif host == "host-hierarchical": - segment_type = segment[api.NETWORK_TYPE] + segment_type = segment[mech_api.NETWORK_TYPE] if segment_type == 'local': next_segment = context.allocate_dynamic_segment( - {api.NETWORK_TYPE: 'vlan', - api.PHYSICAL_NETWORK: 'physnet1'} + {mech_api.NETWORK_TYPE: 'vlan', + mech_api.PHYSICAL_NETWORK: 'physnet1'} ) context.continue_binding(segment_id, [next_segment]) elif segment_type == 'vlan': diff --git a/neutron/tests/unit/plugins/ml2/drivers/openvswitch/mech_driver/test_mech_openvswitch.py b/neutron/tests/unit/plugins/ml2/drivers/openvswitch/mech_driver/test_mech_openvswitch.py index 8548bc9964a..ff22690252e 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/openvswitch/mech_driver/test_mech_openvswitch.py +++ b/neutron/tests/unit/plugins/ml2/drivers/openvswitch/mech_driver/test_mech_openvswitch.py @@ -17,9 +17,9 @@ from neutron_lib.api.definitions import portbindings from neutron_lib.callbacks import events from neutron_lib.callbacks import registry from neutron_lib import constants +from neutron_lib.plugins.ml2 import api from oslo_config import cfg -from neutron.plugins.ml2 import driver_api as api from neutron.plugins.ml2.drivers.openvswitch.agent.common import ( constants as a_const) from neutron.plugins.ml2.drivers.openvswitch.mech_driver import ( diff --git a/neutron/tests/unit/plugins/ml2/drivers/test_type_flat.py b/neutron/tests/unit/plugins/ml2/drivers/test_type_flat.py index 0c55cf55df2..6eb522cac8c 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/test_type_flat.py +++ b/neutron/tests/unit/plugins/ml2/drivers/test_type_flat.py @@ -15,12 +15,12 @@ from neutron_lib import context from neutron_lib import exceptions as exc +from neutron_lib.plugins.ml2 import api from neutron.common import exceptions as n_exc from neutron.objects.plugins.ml2 import flatallocation as flat_obj from neutron.plugins.common import constants as p_const from neutron.plugins.ml2 import config -from neutron.plugins.ml2 import driver_api as api from neutron.plugins.ml2.drivers import type_flat from neutron.tests import base from neutron.tests.unit import testlib_api diff --git a/neutron/tests/unit/plugins/ml2/drivers/test_type_local.py b/neutron/tests/unit/plugins/ml2/drivers/test_type_local.py index 4c7714019d0..bbeab29f4f1 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/test_type_local.py +++ b/neutron/tests/unit/plugins/ml2/drivers/test_type_local.py @@ -14,9 +14,9 @@ # under the License. from neutron_lib import exceptions as exc +from neutron_lib.plugins.ml2 import api from neutron.plugins.common import constants as p_const -from neutron.plugins.ml2 import driver_api as api from neutron.plugins.ml2.drivers import type_local from neutron.tests import base diff --git a/neutron/tests/unit/plugins/ml2/drivers/test_type_vlan.py b/neutron/tests/unit/plugins/ml2/drivers/test_type_vlan.py index 5455d2f06b1..0ef7753d53d 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/test_type_vlan.py +++ b/neutron/tests/unit/plugins/ml2/drivers/test_type_vlan.py @@ -16,6 +16,7 @@ import mock from neutron_lib import context from neutron_lib import exceptions as exc +from neutron_lib.plugins.ml2 import api from testtools import matchers from neutron.db import api as db_api @@ -23,7 +24,6 @@ from neutron.db.models.plugins.ml2 import vlanallocation as vlan_alloc_model from neutron.plugins.common import constants as p_const from neutron.plugins.common import utils as plugin_utils from neutron.plugins.ml2 import config -from neutron.plugins.ml2 import driver_api as api from neutron.plugins.ml2.drivers import type_vlan from neutron.tests.unit import testlib_api diff --git a/neutron/tests/unit/plugins/ml2/test_db.py b/neutron/tests/unit/plugins/ml2/test_db.py index 1cc76205fac..b2bf0d2d4a2 100644 --- a/neutron/tests/unit/plugins/ml2/test_db.py +++ b/neutron/tests/unit/plugins/ml2/test_db.py @@ -20,6 +20,7 @@ import netaddr from neutron_lib.api.definitions import portbindings from neutron_lib import constants from neutron_lib import context +from neutron_lib.plugins.ml2 import api from oslo_utils import uuidutils from sqlalchemy.orm import exc from sqlalchemy.orm import query @@ -32,7 +33,6 @@ from neutron.db import segments_db from neutron.objects import network as network_obj from neutron.objects import ports as port_obj from neutron.plugins.ml2 import db as ml2_db -from neutron.plugins.ml2 import driver_api as api from neutron.plugins.ml2 import models from neutron.tests.unit import testlib_api diff --git a/neutron/tests/unit/plugins/ml2/test_managers.py b/neutron/tests/unit/plugins/ml2/test_managers.py index 7381ff460cb..97b8abb57dd 100644 --- a/neutron/tests/unit/plugins/ml2/test_managers.py +++ b/neutron/tests/unit/plugins/ml2/test_managers.py @@ -16,11 +16,11 @@ import mock +from neutron_lib.plugins.ml2 import api from oslo_db import exception as db_exc from neutron.plugins.ml2.common import exceptions as ml2_exc from neutron.plugins.ml2 import config -from neutron.plugins.ml2 import driver_api as api from neutron.plugins.ml2 import managers from neutron.tests import base from neutron.tests.unit.plugins.ml2.drivers import mechanism_test diff --git a/neutron/tests/unit/plugins/ml2/test_plugin.py b/neutron/tests/unit/plugins/ml2/test_plugin.py index 5a250b4f90f..796d3d71e18 100644 --- a/neutron/tests/unit/plugins/ml2/test_plugin.py +++ b/neutron/tests/unit/plugins/ml2/test_plugin.py @@ -30,6 +30,7 @@ from neutron_lib import constants from neutron_lib import context from neutron_lib import exceptions as exc from neutron_lib.plugins import directory +from neutron_lib.plugins.ml2 import api as driver_api from oslo_db import exception as db_exc from oslo_utils import uuidutils @@ -48,7 +49,6 @@ from neutron.plugins.common import constants as p_const from neutron.plugins.ml2.common import exceptions as ml2_exc from neutron.plugins.ml2 import config from neutron.plugins.ml2 import db as ml2_db -from neutron.plugins.ml2 import driver_api from neutron.plugins.ml2 import driver_context from neutron.plugins.ml2.drivers import type_vlan from neutron.plugins.ml2 import managers diff --git a/neutron/tests/unit/services/trunk/test_rules.py b/neutron/tests/unit/services/trunk/test_rules.py index 7776aaab461..d79ca5f0aa9 100644 --- a/neutron/tests/unit/services/trunk/test_rules.py +++ b/neutron/tests/unit/services/trunk/test_rules.py @@ -20,10 +20,10 @@ import testtools from neutron_lib.api.definitions import trunk as trunk_api from neutron_lib import exceptions as n_exc from neutron_lib.plugins import directory +from neutron_lib.plugins.ml2 import api from oslo_utils import uuidutils from neutron.plugins.common import utils -from neutron.plugins.ml2 import driver_api as api from neutron.services.trunk import constants from neutron.services.trunk import drivers from neutron.services.trunk import exceptions as trunk_exc