[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)
driver.obj.initialize()
+ self.native_bulk_support &= getattr(driver.obj,
+ 'native_bulk_support', True)
def _call_on_drivers(self, method_name, context,
continue_on_failure=False):
db.initialize()
self.type_manager.initialize()
self.mechanism_manager.initialize()
+ # bulk support depends on the underlying drivers
+ self.__native_bulk_support = self.mechanism_manager.native_bulk_support
self._setup_rpc()
--- /dev/null
+# Copyright (c) 2014 OpenStack Foundation
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from neutron.plugins.ml2 import driver_api as api
+
+
+class BulklessMechanismDriver(api.MechanismDriver):
+ """Test mechanism driver for testing bulk emulation."""
+
+ def initialize(self):
+ self.native_bulk_support = False
class Ml2PluginV2TestCase(test_plugin.NeutronDbPluginV2TestCase):
_plugin_name = PLUGIN_NAME
+ _mechanism_drivers = ['logger', 'test']
def setUp(self):
# We need a L3 service plugin
# we can successfully call through to all mechanism
# driver apis.
config.cfg.CONF.set_override('mechanism_drivers',
- ['logger', 'test'],
+ self._mechanism_drivers,
group='ml2')
self.physnet = 'physnet1'
self.vlan_range = '1:100'
self.port_create_status = 'DOWN'
+class TestMl2BulkToggle(Ml2PluginV2TestCase):
+
+ def test_bulk_disable_with_bulkless_driver(self):
+ self.tearDown()
+ self._mechanism_drivers = ['logger', 'test', 'bulkless']
+ self.setUp()
+ self.assertTrue(self._skip_native_bulk)
+
+ def test_bulk_enabled_with_bulk_drivers(self):
+ self.tearDown()
+ self._mechanism_drivers = ['logger', 'test']
+ self.setUp()
+ self.assertFalse(self._skip_native_bulk)
+
+
class TestMl2BasicGet(test_plugin.TestBasicGet,
Ml2PluginV2TestCase):
pass
neutron.ml2.mechanism_drivers =
logger = neutron.tests.unit.ml2.drivers.mechanism_logger:LoggerMechanismDriver
test = neutron.tests.unit.ml2.drivers.mechanism_test:TestMechanismDriver
+ bulkless = neutron.tests.unit.ml2.drivers.mechanism_bulkless:BulklessMechanismDriver
linuxbridge = neutron.plugins.ml2.drivers.mech_linuxbridge:LinuxbridgeMechanismDriver
openvswitch = neutron.plugins.ml2.drivers.mech_openvswitch:OpenvswitchMechanismDriver
hyperv = neutron.plugins.ml2.drivers.mech_hyperv:HypervMechanismDriver