diff options
| author | Mark McLoughlin <markmc@redhat.com> | 2012-08-23 10:35:17 +0100 |
|---|---|---|
| committer | Mark McLoughlin <markmc@redhat.com> | 2012-08-23 12:09:06 +0100 |
| commit | 63cc191c2deee369b4076847204d846cf577d78b (patch) | |
| tree | 5909025afa56293a8f9b86657d7f6abbfffd38b4 /tools | |
| parent | 7968a5ffbe7cf37232d670827ad017f0e8f77e99 (diff) | |
| download | nova-63cc191c2deee369b4076847204d846cf577d78b.tar.gz nova-63cc191c2deee369b4076847204d846cf577d78b.tar.xz nova-63cc191c2deee369b4076847204d846cf577d78b.zip | |
Include CommonConfigOpts options in sample config
Options defined by CommonConfigOpts are declared within the class rather
than at module level, so they weren't being included in the sample conf.
Also, in essex (and up until commit 991614add8), the sample conf file
didn't contain these options but they included the hyphen in the name.
The hyphen is only used on the command line, it is converted to an
underscore automatically in the config file. Use opt.dest rather than
opt.name as the config file key. Fixes bug #1034970.
DocImpact: update nova.conf docs
Change-Id: Ia7f3dded9148deedeb198c19a8d343db6dd93f99
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/conf/extract_opts.py | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/tools/conf/extract_opts.py b/tools/conf/extract_opts.py index 44ae2b000..ed4ad55aa 100644 --- a/tools/conf/extract_opts.py +++ b/tools/conf/extract_opts.py @@ -48,6 +48,8 @@ WORDWRAP_WIDTH = 60 def main(srcfiles): print '\n'.join(['#' * 20, '# nova.conf sample #', '#' * 20, '', '[DEFAULT]', '']) + _list_opts(cfg.CommonConfigOpts, + cfg.__name__ + ':' + cfg.CommonConfigOpts.__name__) mods_by_pkg = dict() for filepath in srcfiles: pkg_name = filepath.split(os.sep)[3] @@ -69,8 +71,6 @@ def main(srcfiles): def _print_module(mod_str): - global OPTION_COUNT - opts = list() mod_obj = None if mod_str.endswith('.__init__'): mod_str = mod_str[:mod_str.rfind(".")] @@ -83,18 +83,23 @@ def _print_module(mod_str): return except Exception, e: return - for attr_str in dir(mod_obj): - attr_obj = getattr(mod_obj, attr_str) + _list_opts(mod_obj, mod_str) + + +def _list_opts(obj, name): + opts = list() + for attr_str in dir(obj): + attr_obj = getattr(obj, attr_str) if isinstance(attr_obj, cfg.Opt): opts.append(attr_obj) elif (isinstance(attr_obj, list) and all(map(lambda x: isinstance(x, cfg.Opt), attr_obj))): opts.extend(attr_obj) - # NOTE(lzyeval): return if module has no options if not opts: return + global OPTION_COUNT OPTION_COUNT += len(opts) - print '######## defined in %s ########\n' % mod_str + print '######## defined in %s ########\n' % name for opt in opts: _print_opt(opt) print @@ -114,7 +119,7 @@ def _wrap(msg, indent): def _print_opt(opt): - opt_name, opt_default, opt_help = opt.name, opt.default, opt.help + opt_name, opt_default, opt_help = opt.dest, opt.default, opt.help if not opt_help: sys.stderr.write('WARNING: "%s" is missing help string.\n' % opt_name) opt_type = None |
