]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Base ML2 bulk support on the loaded drivers
authorKevin Benton <blak111@gmail.com>
Fri, 24 Jan 2014 19:43:54 +0000 (19:43 +0000)
committerKevin Benton <blak111@gmail.com>
Wed, 5 Feb 2014 06:35:01 +0000 (22:35 -0800)
Changes the ML2 plugin bulk support flag to
be based on the bulk support of the underlying
drivers.

Closes-Bug: #1272490
Change-Id: I28281c9ecc1696b929c7e0125d02a37946948744

neutron/plugins/ml2/managers.py
neutron/plugins/ml2/plugin.py
neutron/tests/unit/ml2/drivers/mechanism_bulkless.py [new file with mode: 0644]
neutron/tests/unit/ml2/test_ml2_plugin.py
setup.cfg

index dec707bad35edc1c980cce876bd3163f357a51d7..a60e20987b84b778b202688bf105a7702c000190 100644 (file)
@@ -133,9 +133,13 @@ class MechanismManager(stevedore.named.NamedExtensionManager):
                  [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):
index 7b78ac1f031fe034f461863a56ce21522cd8e4a2..9e0c6a0baa42cc59faf84528bf9e3fafd240e0ea 100644 (file)
@@ -103,6 +103,8 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
         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()
 
diff --git a/neutron/tests/unit/ml2/drivers/mechanism_bulkless.py b/neutron/tests/unit/ml2/drivers/mechanism_bulkless.py
new file mode 100644 (file)
index 0000000..0a0d3de
--- /dev/null
@@ -0,0 +1,23 @@
+# 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
index 5334262a72b50bae516fa9cda23a22670ee2dced..61d26f9d505e20cc63655bbd4a35e154a31adcf6 100644 (file)
@@ -29,6 +29,7 @@ PLUGIN_NAME = 'neutron.plugins.ml2.plugin.Ml2Plugin'
 class Ml2PluginV2TestCase(test_plugin.NeutronDbPluginV2TestCase):
 
     _plugin_name = PLUGIN_NAME
+    _mechanism_drivers = ['logger', 'test']
 
     def setUp(self):
         # We need a L3 service plugin
@@ -39,7 +40,7 @@ class Ml2PluginV2TestCase(test_plugin.NeutronDbPluginV2TestCase):
         # 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'
@@ -52,6 +53,21 @@ class Ml2PluginV2TestCase(test_plugin.NeutronDbPluginV2TestCase):
         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
index fc1eb6e05de657d9fdd57b2a075fe289c89db008..d8c21da15c5dc14804d2173330bbb7f7dc889da7 100644 (file)
--- a/setup.cfg
+++ b/setup.cfg
@@ -150,6 +150,7 @@ neutron.ml2.type_drivers =
 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