Prepare for transition to oslo-config-generator

Do formatting changes to make our current generator output match up more
with how it will be with oslo-config-generator. This will make it easier
to review what changes occur to the ironic.conf.sample file when moving
to the use of oslo-config-generator.

* Put spaces between variable and value. For example "foo = spam",
  instead of "foo=spam". If value is empty string, don't have trailing
  space after equal.

* When there are 'choices' change the wording to "Allowed values" from
  "Possible values".  Intentionally did not change any of the other
  messages with the wording 'Possible.*'

* When min_value and max_value are both present, no longer use
  'Possible values' anymore but output them separately instead.

* Change the value of OPT type to 'unknown value'.

* Change the output of deprecated_for_removal flag.

* Regenerate sample config.

Co-Authored-By: Lin Tan <lin.tan@intel.com>
Change-Id: I1bc8b00eb98055a6e0f06af287cfa10c02ee2094
This commit is contained in:
John L. Villalovos 2016-04-07 12:43:06 -07:00
parent 56380f0e12
commit 52fe4a9687
2 changed files with 435 additions and 424 deletions

File diff suppressed because it is too large Load Diff

View File

@ -52,7 +52,7 @@ MULTISTROPT = "MultiStrOpt"
PORTOPT = "PortOpt"
OPT_TYPES = {
OPT: 'type of value is unknown',
OPT: 'unknown value',
STROPT: 'string value',
BOOLOPT: 'boolean value',
INTOPT: 'integer value',
@ -291,20 +291,17 @@ def _print_opt(opt, group):
# 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:
if min_value is not None:
print('# Minimum value: %d' % min_value)
elif max_value is not None:
if max_value is not None:
print('# Maximum value: %d' % max_value)
elif choices is not None:
if 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)
print('# Allowed values: %s' % choices_text)
if opt.deprecated_opts:
for deprecated_opt in opt.deprecated_opts:
@ -316,11 +313,11 @@ def _print_opt(opt, group):
(deprecated_group,
deprecated_name))
if opt.deprecated_for_removal:
print('# This option is deprecated and planned for removal in a '
'future release.')
print('# This option is deprecated for removal.')
print('# Its value may be silently ignored in the future.')
try:
if opt_default is None:
print('#%s=<None>' % opt_name)
print('#%s = <None>' % opt_name)
else:
_print_type(opt_type, opt_name, opt_default)
print('')
@ -331,39 +328,42 @@ def _print_opt(opt, group):
def _print_type(opt_type, opt_name, opt_default):
if opt_type == OPT:
print('#%s=%s' % (opt_name, opt_default))
print('#%s = %s' % (opt_name, opt_default))
elif opt_type == STROPT:
assert(isinstance(opt_default, six.string_types))
print('#%s=%s' % (opt_name, _sanitize_default(opt_name,
opt_default)))
value = _sanitize_default(opt_name, opt_default)
if value:
print('#%s = %s' % (opt_name, value))
else:
print('#%s =' % (opt_name))
elif opt_type == BOOLOPT:
assert(isinstance(opt_default, bool))
print('#%s=%s' % (opt_name, str(opt_default).lower()))
print('#%s = %s' % (opt_name, str(opt_default).lower()))
elif opt_type == INTOPT:
assert(isinstance(opt_default, int) and
not isinstance(opt_default, bool))
print('#%s=%s' % (opt_name, opt_default))
print('#%s = %s' % (opt_name, opt_default))
elif opt_type == PORTOPT:
assert(isinstance(opt_default, int) and
not isinstance(opt_default, bool))
print('#%s=%s' % (opt_name, opt_default))
print('#%s = %s' % (opt_name, opt_default))
elif opt_type == FLOATOPT:
assert(isinstance(opt_default, float))
print('#%s=%s' % (opt_name, opt_default))
print('#%s = %s' % (opt_name, opt_default))
elif opt_type == LISTOPT:
assert(isinstance(opt_default, list))
print('#%s=%s' % (opt_name, ','.join(opt_default)))
print('#%s = %s' % (opt_name, ','.join(opt_default)))
elif opt_type == DICTOPT:
assert(isinstance(opt_default, dict))
opt_default_strlist = [str(key) + ':' + str(value)
for (key, value) in opt_default.items()]
print('#%s=%s' % (opt_name, ','.join(opt_default_strlist)))
print('#%s = %s' % (opt_name, ','.join(opt_default_strlist)))
elif opt_type == MULTISTROPT:
assert(isinstance(opt_default, list))
if not opt_default:
opt_default = ['']
for default in opt_default:
print('#%s=%s' % (opt_name, default))
print('#%s = %s' % (opt_name, default))
else:
raise ValueError("unknown oslo_config type %s" % opt_type)