summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorZhongyue Luo <lzyeval@gmail.com>2012-02-21 20:50:08 +0800
committerZhongyue Luo <lzyeval@gmail.com>2012-02-24 07:10:40 +0800
commitcce1c217eb39998c5390d37ba61f2c7f0056b25e (patch)
treeedd69acf76be7c3dc5c30a1e22e4a66dabd754ca /tools
parent5baaa3117ab2c1cab8a573a2bd488a55478b6189 (diff)
downloadnova-cce1c217eb39998c5390d37ba61f2c7f0056b25e.tar.gz
nova-cce1c217eb39998c5390d37ba61f2c7f0056b25e.tar.xz
nova-cce1c217eb39998c5390d37ba61f2c7f0056b25e.zip
Nova options tool enhancements
Fixes bug #936898 1. Just import the modules and only look at nova.flags.FLAGS when they're all imported 2. ConfigOpts is iterable, there should be no need to iterate the private FLAGS._opts dict 3. Output should be .ini style 4. The output should only contain comments i.e. each option default should be commented out Change-Id: I15835bb437bc6d575e8311d7c55b3a29d67b006d
Diffstat (limited to 'tools')
-rw-r--r--tools/conf/create_conf.py28
1 files changed, 7 insertions, 21 deletions
diff --git a/tools/conf/create_conf.py b/tools/conf/create_conf.py
index 231fd9836..af702f732 100644
--- a/tools/conf/create_conf.py
+++ b/tools/conf/create_conf.py
@@ -26,7 +26,6 @@ import sys
_PY_EXT = ".py"
-_SCREEN_WIDTH = 72
_FLAGS = "FLAGS"
_STROPT = "StrOpt"
@@ -93,25 +92,18 @@ def print_module(mod_str):
return
except Exception, e:
return
- for opt_name, opt_dict in sorted(flags._opts.items(),
- key=lambda (x, y): x):
+ for opt_name in sorted(flags.keys()):
# check if option was processed
if opt_name in _OPTION_CACHE:
continue
+ opt_dict = flags.retrieve_opt(opt_name)
opts.append(opt_dict['opt'])
_OPTION_CACHE.append(opt_name)
# return if flags has no unique options
if not opts:
return
# print out module info
- remain_width = _SCREEN_WIDTH - len(mod_str) - 5
- print '#' * _SCREEN_WIDTH
- print '#', mod_str,
- if remain_width > 0:
- print " " * remain_width, "#"
- else:
- print
- print '#' * _SCREEN_WIDTH
+ print ''.join(['[', mod_str, ']'])
print
for opt in opts:
print_opt(opt)
@@ -128,19 +120,13 @@ def print_opt(opt):
# print out option info
print "#", "".join(["(", opt_type, ")"]), opt.help
if opt_type == _BOOLOPT:
- if opt.default is True:
- print "# Comment line to disable"
- else:
- print "# Uncomment line to enable"
- print "#",
- print ''.join(["--", opt.name])
+ print "# default: %s" % opt.default
+ print "#", ''.join(["--", opt.name])
else:
opt_value = str(opt.default)
- if (opt.default is None or
- (isinstance(opt.default, str) and not opt.default)):
+ if (opt.default is None or (opt_type == _STROPT and not opt.default)):
opt_value = "<%s>" % opt.name
- print "#",
- print ''.join(["--", opt.name, "=", opt_value])
+ print "#", ''.join(["--", opt.name, "=", opt_value])
print