Do not load default service plugins if core plugin is not DB based

Some service plugins make the assumption that Neutron is running
with a datastore (e.g. revision and timestamps). As the datastore
setup is a responsibility of the Neutron core plugin, checking
that this is indeed true avoids errors for those plugins that do
not implement any DB backend (e.g. monolithic OpenContrail plugin).

Change-Id: I872fa6e3c3925e521150d79bba864101d9a5f648
Closes-bug: #1700651
This commit is contained in:
Armando Migliaccio 2017-11-09 12:24:04 -08:00
parent 1665395b19
commit 69d0047cfe
3 changed files with 15 additions and 1 deletions

View File

@ -140,6 +140,9 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon,
__native_pagination_support = True
__native_sorting_support = True
def has_native_datastore(self):
return True
def __new__(cls, *args, **kwargs):
model_query.register_hook(
models_v2.Port,

View File

@ -179,7 +179,11 @@ class NeutronManager(object):
def _get_default_service_plugins(self):
"""Get default service plugins to be loaded."""
return constants.DEFAULT_SERVICE_PLUGINS.keys()
core_plugin = directory.get_plugin()
if core_plugin.has_native_datastore():
return constants.DEFAULT_SERVICE_PLUGINS.keys()
else:
return []
def _load_service_plugins(self):
"""Loads service plugins.

View File

@ -410,3 +410,10 @@ class NeutronPluginBaseV2(base_services.WorkerBase):
"""
return (self.__class__.start_rpc_state_reports_listener !=
NeutronPluginBaseV2.start_rpc_state_reports_listener)
def has_native_datastore(self):
"""Return True if the plugin uses Neutron's native datastore.
.. note:: plugins like ML2 should override this method and return True.
"""
return False