diff options
author | Jenkins <jenkins@review.openstack.org> | 2015-04-08 16:51:04 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2015-04-08 16:51:04 +0000 |
commit | 596d16237ab5ec624e3088a45e09b74ad9762ec6 (patch) | |
tree | 58f91821706ebe03682878af136dc01631b44472 | |
parent | 019e291a65460278593ba1a5c1f88558b8cf53f0 (diff) | |
parent | 42ad8b03560a5010e565ef04e73fa27f57b48052 (diff) | |
download | nova-596d16237ab5ec624e3088a45e09b74ad9762ec6.tar.gz |
Merge "Print choices in the config generator"
-rw-r--r-- | nova/openstack/common/config/generator.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/nova/openstack/common/config/generator.py b/nova/openstack/common/config/generator.py index 73749834a5..a4b2ab5938 100644 --- a/nova/openstack/common/config/generator.py +++ b/nova/openstack/common/config/generator.py @@ -241,6 +241,14 @@ def _sanitize_default(name, value): return value +def _get_choice_text(choice): + if choice is None: + return '<None>' + elif choice == '': + return "''" + return six.text_type(choice) + + def _print_opt(opt): opt_name, opt_default, opt_help = opt.dest, opt.default, opt.help if not opt_help: @@ -268,6 +276,11 @@ def _print_opt(opt): print('#%s=<None>' % opt_name) elif opt_type == STROPT: assert(isinstance(opt_default, six.string_types)) + if (getattr(opt, 'type', None) and + getattr(opt.type, 'choices', None)): + choices_text = ', '.join([_get_choice_text(choice) + for choice in opt.type.choices]) + print('# Allowed values: %s' % choices_text) print('#%s=%s' % (opt_name, _sanitize_default(opt_name, opt_default))) elif opt_type == BOOLOPT: |