diff options
author | Mark McLoughlin <markmc@redhat.com> | 2013-02-23 18:19:44 +0000 |
---|---|---|
committer | Mark McLoughlin <markmc@redhat.com> | 2013-03-01 12:12:41 +0000 |
commit | 2b6f37461b44a0dbdf92d6a6499d2a234195b8f5 (patch) | |
tree | f10f8d023bc6388f3c3f42a83074a15a7e15eff5 /tools | |
parent | 957a2a6909fb6b5d9773ef74160543f4d984cc96 (diff) | |
download | nova-2b6f37461b44a0dbdf92d6a6499d2a234195b8f5.tar.gz |
Regenerate nova.conf.sample
Fix generate_sample.sh script so that we include options from the bin/
scripts too. In order to make this work, sync a zmq-receive fix from
oslo-incubator to delay parsing its config file.
Change-Id: Ia3f9083b2ebc16425dbad8a2a55c2d45f1ff2be3
Diffstat (limited to 'tools')
-rw-r--r-- | tools/conf/extract_opts.py | 25 | ||||
-rwxr-xr-x | tools/conf/generate_sample.sh | 8 |
2 files changed, 26 insertions, 7 deletions
diff --git a/tools/conf/extract_opts.py b/tools/conf/extract_opts.py index 83d99dd19d..89f335d9b4 100644 --- a/tools/conf/extract_opts.py +++ b/tools/conf/extract_opts.py @@ -20,6 +20,7 @@ """Extracts OpenStack config option info from module(s).""" +import imp import os import re import socket @@ -98,7 +99,11 @@ def main(srcfiles): def _import_module(mod_str): try: - return importutils.import_module(mod_str) + if mod_str.startswith('bin.'): + imp.load_source(mod_str[4:], os.path.join('bin', mod_str[4:])) + return sys.modules[mod_str[4:]] + else: + return importutils.import_module(mod_str) except (ValueError, AttributeError), err: return None except ImportError, ie: @@ -141,9 +146,9 @@ def _guess_groups(opt, mod_obj): return 'DEFAULT' if group is None: - sys.stderr("Unable to guess what group " + opt.dest + - " in " + mod_obj.__name__ + - " is in out of " + ','.join(groups) + "\n") + sys.stderr.write("Unable to guess what group " + opt.dest + + " in " + mod_obj.__name__ + + " is in out of " + ','.join(groups) + "\n") sys.exit(1) sys.stderr.write("Guessing that " + opt.dest + @@ -154,13 +159,17 @@ def _guess_groups(opt, mod_obj): def _list_opts(obj): + def is_opt(o): + return (isinstance(o, cfg.Opt) and + not isinstance(o, cfg.SubCommandOpt)) + opts = list() for attr_str in dir(obj): attr_obj = getattr(obj, attr_str) - if isinstance(attr_obj, cfg.Opt): + if is_opt(attr_obj): opts.append(attr_obj) elif (isinstance(attr_obj, list) and - all(map(lambda x: isinstance(x, cfg.Opt), attr_obj))): + all(map(lambda x: is_opt(x), attr_obj))): opts.extend(attr_obj) ret = {} @@ -199,6 +208,8 @@ def _sanitize_default(s): """Set up a reasonably sensible default for pybasedir, my_ip and host.""" if s.startswith(BASEDIR): return s.replace(BASEDIR, '/usr/lib/python/site-packages') + elif BASEDIR in s: + return s.replace(BASEDIR, '') elif s == _get_my_ip(): return '10.0.0.1' elif s == socket.getfqdn(): @@ -241,6 +252,8 @@ def _print_opt(opt): print '#%s=%s' % (opt_name, ','.join(opt_default)) 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 diff --git a/tools/conf/generate_sample.sh b/tools/conf/generate_sample.sh index 25462caa28..283d7a654e 100755 --- a/tools/conf/generate_sample.sh +++ b/tools/conf/generate_sample.sh @@ -19,7 +19,13 @@ FILES=$(find nova -type f -name "*.py" ! -path "nova/tests/*" -exec \ grep -l "Opt(" {} \; | sort -u) +BINS=$(echo bin/nova-*) PYTHONPATH=./:${PYTHONPATH} \ - python $(dirname "$0")/extract_opts.py ${FILES} > \ + python $(dirname "$0")/extract_opts.py ${FILES} ${BINS} > \ etc/nova/nova.conf.sample + +# Remove compiled files created by imp.import_source() +for bin in ${BINS}; do + [ -f ${bin}c ] && rm ${bin}c +done |