conf: Make list->dict conversion more specific

All of the Nova configuration options' 'list_opts' functions have been
updated to return dicts rather than lists of tuples. However, two
dependency libraries still return dicts.

Replace the general handling code for this with specific code in the
two offending places. This gives a more actionable resolution.

Blueprint centralize-config-options-ocata
Change-Id: I5ce9ac2037e4374215a96e09e12b0873c31dd27e
This commit is contained in:
Stephen Finucane 2016-08-23 17:39:49 +01:00
parent 09870549c9
commit d42b029704

View File

@ -72,19 +72,8 @@ def _import_modules(module_names):
return imported_modules
def _process_old_opts(configs):
"""Convert old-style 2-tuple configs to dicts."""
if isinstance(configs, tuple):
configs = [configs]
return {label: options for label, options in configs}
def _append_config_options(imported_modules, config_options):
for mod in imported_modules:
configs = mod.list_opts()
# TODO(markus_z): Remove this compatibility shim once all list_opts()
# functions have been updated to return dicts.
if not isinstance(configs, dict):
configs = _process_old_opts(configs)
for key, val in configs.items():
config_options[key].extend(val)