diff options
author | Jenkins <jenkins@review.openstack.org> | 2016-03-03 11:04:22 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2016-03-03 11:04:22 +0000 |
commit | 5821bd661cd2f5a66141c5fc86a6aeb06688f281 (patch) | |
tree | 1e02dcda43a6d58c44cc9e6823ec69d03262da44 /ironic | |
parent | 80fd454ef7e9f6b340af74a84c2a82e86bb5bf0e (diff) | |
parent | e38f345709032a50ebd9d9435937ee3e3ac69406 (diff) | |
download | ironic-5821bd661cd2f5a66141c5fc86a6aeb06688f281.tar.gz |
Merge "Add possible values for config options"
Diffstat (limited to 'ironic')
-rw-r--r-- | ironic/common/config_generator/generator.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/ironic/common/config_generator/generator.py b/ironic/common/config_generator/generator.py index b58f1b6ee..62818614d 100644 --- a/ironic/common/config_generator/generator.py +++ b/ironic/common/config_generator/generator.py @@ -233,6 +233,14 @@ def print_group_opts(group, opts_by_module): print('') +def _get_choice_text(choice): + if choice is None: + return '<None>' + elif choice == '': + return "''" + return six.text_type(choice) + + def _get_my_ip(): try: csock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) @@ -276,6 +284,28 @@ def _print_opt(opt, group): opt_help = u'%s (%s)' % (opt_help, OPT_TYPES[opt_type]) print('#', "\n# ".join(textwrap.wrap(opt_help, WORDWRAP_WIDTH))) + + min_value = getattr(opt.type, 'min', None) + max_value = getattr(opt.type, 'max', None) + choices = getattr(opt.type, 'choices', None) + + # NOTE(lintan): choices are mutually exclusive with 'min/max', + # see oslo.config for more details. + if min_value is not None and max_value is not None: + print('# Possible values: %(min_value)d-%(max_value)d' % + {'min_value': min_value, 'max_value': max_value}) + elif min_value is not None: + print('# Minimum value: %d' % min_value) + elif max_value is not None: + print('# Maximum value: %d' % max_value) + elif choices is not None: + if choices == []: + print('# No possible values.') + else: + choices_text = ', '.join([_get_choice_text(choice) + for choice in choices]) + print('# Possible values: %s' % choices_text) + if opt.deprecated_opts: for deprecated_opt in opt.deprecated_opts: deprecated_name = (deprecated_opt.name if |