Relax service module check on service providers

service_provider is a 'special' configuration. It is a MultiStr
option that used to be in neutron.conf, but moved into its own *-aas
config files after the service split. We allow for the definition to
be available 'anywhere': either in neutron.conf or in the *-aas
service's config file.

The list of 'service_provider' can include drivers from within the *-aas
tree, or from elsewhere, and can apply to different service types. Due to
the polymorphic nature of this variable it is very tricky to identify only
the drivers that pertain a specific service module: the service module
may as well implement more than one service type and may have support
from drivers out of tree.

For this reason it is best to relax this check and rely on query filters
when the ServiceManager.get_service_providers() is invoked. Furthermore,
without this fix there was a situation where the value returned by
'service_providers' may be differ depending on how the configuration is
passed on the CLI, and this inconsistency may only cause headaches.

Closes-bug: #1492069

Change-Id: I4db4ce0b287c984d86181227edf769531ecb7bb8
This commit is contained in:
armando-migliaccio 2015-09-18 13:13:59 -07:00 committed by Armando Migliaccio
parent 522b278963
commit d24633a468
1 changed files with 8 additions and 12 deletions

View File

@ -82,22 +82,18 @@ class NeutronModule(object):
def service_providers(self): def service_providers(self):
"""Return the service providers for the extension module.""" """Return the service providers for the extension module."""
providers = [] providers = []
# Attempt to read the config from cfg.CONF; this is possible # Attempt to read the config from cfg.CONF first; when passing
# when passing --config-dir. Since the multiStr config option # --config-dir, the option is merged from all the definitions
# gets merged, extract only the providers pertinent to this # made across all the imported config files
# service module.
try: try:
providers = [ providers = cfg.CONF.service_providers.service_provider
sp for sp in cfg.CONF.service_providers.service_provider
if self.module_name in sp
]
except cfg.NoSuchOptError: except cfg.NoSuchOptError:
pass pass
# Alternatively, if the option is not avaialable, load the # Alternatively, if the option is not available, try to load
# config option using the module's built-in ini parser. # it from the provider module's config file; this may be
# this may be necessary, if modules are loaded on the fly # necessary, if modules are loaded on the fly (DevStack may
# (DevStack may be an example) # be an example)
if not providers: if not providers:
providers = self.ini().service_providers.service_provider providers = self.ini().service_providers.service_provider