Update config generator to use new style list_opts discovery
Stop-gap until we move to oslo-config-generator. We need something to get by the fatal_deprecation problem. The oslo-incubator changeset referenced should be merged first. Closes-Bug: #1424576 Depends-On: Ie6d1da242b79bb1dfd03494dee82fbb73eb94217 Change-Id: I7b9aa7588d91ee7b7d2faeb090b4e0ca6ced1c0a
This commit is contained in:
@@ -179,6 +179,10 @@ def _list_opts(obj):
|
|||||||
not isinstance(o, cfg.SubCommandOpt))
|
not isinstance(o, cfg.SubCommandOpt))
|
||||||
|
|
||||||
opts = list()
|
opts = list()
|
||||||
|
|
||||||
|
if 'list_opts' in dir(obj):
|
||||||
|
return getattr(obj, 'list_opts')()
|
||||||
|
|
||||||
for attr_str in dir(obj):
|
for attr_str in dir(obj):
|
||||||
attr_obj = getattr(obj, attr_str)
|
attr_obj = getattr(obj, attr_str)
|
||||||
if is_opt(attr_obj):
|
if is_opt(attr_obj):
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
Helpers for comparing version strings.
|
Helpers for comparing version strings.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import copy
|
||||||
import functools
|
import functools
|
||||||
import inspect
|
import inspect
|
||||||
import logging
|
import logging
|
||||||
@@ -32,13 +33,19 @@ LOG = logging.getLogger(__name__)
|
|||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
|
|
||||||
|
|
||||||
opts = [
|
deprecated_opts = [
|
||||||
cfg.BoolOpt('fatal_deprecations',
|
cfg.BoolOpt('fatal_deprecations',
|
||||||
default=False,
|
default=False,
|
||||||
help='Enables or disables fatal status of deprecations.'),
|
help='Enables or disables fatal status of deprecations.'),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def list_opts():
|
||||||
|
"""Entry point for oslo.config-generator.
|
||||||
|
"""
|
||||||
|
return [(None, copy.deepcopy(deprecated_opts))]
|
||||||
|
|
||||||
|
|
||||||
class deprecated(object):
|
class deprecated(object):
|
||||||
"""A decorator to mark callables as deprecated.
|
"""A decorator to mark callables as deprecated.
|
||||||
|
|
||||||
@@ -230,7 +237,7 @@ def report_deprecated_feature(logger, msg, *args, **kwargs):
|
|||||||
fatal deprecations.
|
fatal deprecations.
|
||||||
"""
|
"""
|
||||||
stdmsg = _("Deprecated: %s") % msg
|
stdmsg = _("Deprecated: %s") % msg
|
||||||
CONF.register_opts(opts)
|
CONF.register_opts(deprecated_opts)
|
||||||
if CONF.fatal_deprecations:
|
if CONF.fatal_deprecations:
|
||||||
logger.critical(stdmsg, *args, **kwargs)
|
logger.critical(stdmsg, *args, **kwargs)
|
||||||
raise DeprecatedConfig(msg=stdmsg)
|
raise DeprecatedConfig(msg=stdmsg)
|
||||||
|
|||||||
Reference in New Issue
Block a user