Base ML2 bulk support on the loaded drivers
Changes the ML2 plugin bulk support flag to be based on the bulk support of the underlying drivers. Closes-Bug: #1272490 Change-Id: I28281c9ecc1696b929c7e0125d02a37946948744
This commit is contained in:
parent
63fd1a0f6a
commit
1027d02977
@ -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):
|
||||
|
@ -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()
|
||||
|
||||
|
23
neutron/tests/unit/ml2/drivers/mechanism_bulkless.py
Normal file
23
neutron/tests/unit/ml2/drivers/mechanism_bulkless.py
Normal file
@ -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
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user