Merge "Nova options tool enhancements"
This commit is contained in:
commit
01dbefb085
@ -44,6 +44,10 @@ class NovaConfigOpts(cfg.CommonConfigOpts):
|
|||||||
with flagfile.handle_flagfiles_managed(argv[1:]) as args:
|
with flagfile.handle_flagfiles_managed(argv[1:]) as args:
|
||||||
return argv[:1] + super(NovaConfigOpts, self).__call__(args)
|
return argv[:1] + super(NovaConfigOpts, self).__call__(args)
|
||||||
|
|
||||||
|
def retrieve_opt(self, opt_name, group=None):
|
||||||
|
return self._get_opt_info(opt_name, group)
|
||||||
|
|
||||||
|
|
||||||
FLAGS = NovaConfigOpts()
|
FLAGS = NovaConfigOpts()
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,7 +26,6 @@ import sys
|
|||||||
|
|
||||||
|
|
||||||
_PY_EXT = ".py"
|
_PY_EXT = ".py"
|
||||||
_SCREEN_WIDTH = 72
|
|
||||||
_FLAGS = "FLAGS"
|
_FLAGS = "FLAGS"
|
||||||
|
|
||||||
_STROPT = "StrOpt"
|
_STROPT = "StrOpt"
|
||||||
@ -93,25 +92,18 @@ def print_module(mod_str):
|
|||||||
return
|
return
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
return
|
return
|
||||||
for opt_name, opt_dict in sorted(flags._opts.items(),
|
for opt_name in sorted(flags.keys()):
|
||||||
key=lambda (x, y): x):
|
|
||||||
# check if option was processed
|
# check if option was processed
|
||||||
if opt_name in _OPTION_CACHE:
|
if opt_name in _OPTION_CACHE:
|
||||||
continue
|
continue
|
||||||
|
opt_dict = flags.retrieve_opt(opt_name)
|
||||||
opts.append(opt_dict['opt'])
|
opts.append(opt_dict['opt'])
|
||||||
_OPTION_CACHE.append(opt_name)
|
_OPTION_CACHE.append(opt_name)
|
||||||
# return if flags has no unique options
|
# return if flags has no unique options
|
||||||
if not opts:
|
if not opts:
|
||||||
return
|
return
|
||||||
# print out module info
|
# print out module info
|
||||||
remain_width = _SCREEN_WIDTH - len(mod_str) - 5
|
print ''.join(['[', mod_str, ']'])
|
||||||
print '#' * _SCREEN_WIDTH
|
|
||||||
print '#', mod_str,
|
|
||||||
if remain_width > 0:
|
|
||||||
print " " * remain_width, "#"
|
|
||||||
else:
|
|
||||||
print
|
|
||||||
print '#' * _SCREEN_WIDTH
|
|
||||||
print
|
print
|
||||||
for opt in opts:
|
for opt in opts:
|
||||||
print_opt(opt)
|
print_opt(opt)
|
||||||
@ -128,19 +120,13 @@ def print_opt(opt):
|
|||||||
# print out option info
|
# print out option info
|
||||||
print "#", "".join(["(", opt_type, ")"]), opt.help
|
print "#", "".join(["(", opt_type, ")"]), opt.help
|
||||||
if opt_type == _BOOLOPT:
|
if opt_type == _BOOLOPT:
|
||||||
if opt.default is True:
|
print "# default: %s" % opt.default
|
||||||
print "# Comment line to disable"
|
print "#", ''.join(["--", opt.name])
|
||||||
else:
|
|
||||||
print "# Uncomment line to enable"
|
|
||||||
print "#",
|
|
||||||
print ''.join(["--", opt.name])
|
|
||||||
else:
|
else:
|
||||||
opt_value = str(opt.default)
|
opt_value = str(opt.default)
|
||||||
if (opt.default is None or
|
if (opt.default is None or (opt_type == _STROPT and not opt.default)):
|
||||||
(isinstance(opt.default, str) and not opt.default)):
|
|
||||||
opt_value = "<%s>" % opt.name
|
opt_value = "<%s>" % opt.name
|
||||||
print "#",
|
print "#", ''.join(["--", opt.name, "=", opt_value])
|
||||||
print ''.join(["--", opt.name, "=", opt_value])
|
|
||||||
print
|
print
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user