[ML2] Change way how list of supported API extensions is made

Previously if extension was not supported by one of the mech drivers,
but it wasn't filtered out by next mech driver, it was available finally
in the list.
Now, this patch changes that so if extension is disabled by one of the
drivers it isn't available on the list at all.
This will work better e.g. with discoverability of what is available
e.g. when OVN backend is used by Neutron.

Closes-Bug: #1929676
Change-Id: I6a4ff42f47f7ee90365516d37472c09ac87773e5
This commit is contained in:
Slawek Kaplonski 2021-05-26 12:52:39 +02:00
parent bc82a664b6
commit db2207f32d
3 changed files with 18 additions and 6 deletions

View File

@ -313,10 +313,10 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
if not self.mechanism_manager.ordered_mech_drivers:
return aliases
supported_extensions = set([])
supported_extensions = set(aliases)
for mech_driver in self.mechanism_manager.ordered_mech_drivers:
supported_extensions |= mech_driver.obj.supported_extensions(
set(aliases))
supported_extensions &= mech_driver.obj.supported_extensions(
supported_extensions)
return list(supported_extensions)
@registry.receives(resources.PORT,

View File

@ -177,15 +177,14 @@ class TestMl2FilterExtensions(Ml2PluginV2TestCase):
def test__filter_extensions_by_mech_driver(self):
extension_aliases = ['ext1', 'ext2', 'ext3', 'ext4', 'ext5']
supported_aliases = [{'ext0', 'ext1', 'ext2'},
{'ext4', 'ext5', 'ext6'}]
{'ext1', 'ext5', 'ext6'}]
for idx, mech_driver in enumerate(
self.plugin.mechanism_manager.ordered_mech_drivers):
mech_driver.obj._supported_extensions = supported_aliases[idx]
supported_extensions = sorted(
self.plugin._filter_extensions_by_mech_driver(extension_aliases))
self.assertEqual(['ext1', 'ext2', 'ext4', 'ext5'],
supported_extensions)
self.assertEqual(['ext1'], supported_extensions)
class TestMl2BasicGet(test_plugin.TestBasicGet,

View File

@ -0,0 +1,13 @@
---
upgrade:
- |
The way the ML2 plugin filters out API extensions which are not supported
by loaded mechanism drivers has changed.
Before, the API extension was on the list if at least one of the mechanism drivers
supported it, but now the extension needs to be supported by all the mechanism
drivers. If at least one of them filters it out, it will be removed from
the final list of enabled API extensions.
Currently, only the OVN mechanism driver is filtering out some of the ML2
API extensions, thus if that mechanism driver is loaded in Neutron with any other
mechanism driver, the list of the enabled API extensions may be smaller than it
was before.