Sync config generator from oslo-incubator
Sync from oslo-incubator with the following patches about the config generator: 7c18261 Temporary workaround for config generator 4b3e32b Sort the output of config/generator.py by group name 806272e Improve error reporting on import failures 6cd1c33 Clean up extra modules code 3d077a3 Print the deprecated group/name for each option aec6d94 config.generator: allow extra modules importing ddc4f0d Fix error when no custom config file matches *.conf.sample d4bf84d Allow generate_sample MODULEPATH to be set in env UpgradeImpact DocImpact, the default values in keystone_authtoken config group are changed. Change-Id: If7181e14db2e43e42255bb6221d0543c13c4e5a6
This commit is contained in:
+1182
-1008
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,3 @@
|
||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
|
||||
# Copyright 2012 SINA Corporation
|
||||
# All Rights Reserved.
|
||||
#
|
||||
@@ -28,6 +26,7 @@ import sys
|
||||
import textwrap
|
||||
|
||||
from oslo.config import cfg
|
||||
import six
|
||||
|
||||
from nova.openstack.common import gettextutils
|
||||
from nova.openstack.common import importutils
|
||||
@@ -78,6 +77,16 @@ def generate(srcfiles):
|
||||
# The options list is a list of (module, options) tuples
|
||||
opts_by_group = {'DEFAULT': []}
|
||||
|
||||
extra_modules = os.getenv("NOVA_CONFIG_GENERATOR_EXTRA_MODULES", "")
|
||||
if extra_modules:
|
||||
for module_name in extra_modules.split(','):
|
||||
module_name = module_name.strip()
|
||||
module = _import_module(module_name)
|
||||
if module:
|
||||
for group, opts in _list_opts(module):
|
||||
opts_by_group.setdefault(group, []).append((module_name,
|
||||
opts))
|
||||
|
||||
for pkg_name in pkg_names:
|
||||
mods = mods_by_pkg.get(pkg_name)
|
||||
mods.sort()
|
||||
@@ -93,8 +102,8 @@ def generate(srcfiles):
|
||||
opts_by_group.setdefault(group, []).append((mod_str, opts))
|
||||
|
||||
print_group_opts('DEFAULT', opts_by_group.pop('DEFAULT', []))
|
||||
for group, opts in opts_by_group.items():
|
||||
print_group_opts(group, opts)
|
||||
for group in sorted(opts_by_group.keys()):
|
||||
print_group_opts(group, opts_by_group[group])
|
||||
|
||||
|
||||
def _import_module(mod_str):
|
||||
@@ -104,17 +113,17 @@ def _import_module(mod_str):
|
||||
return sys.modules[mod_str[4:]]
|
||||
else:
|
||||
return importutils.import_module(mod_str)
|
||||
except ImportError as ie:
|
||||
sys.stderr.write("%s\n" % str(ie))
|
||||
return None
|
||||
except Exception:
|
||||
except Exception as e:
|
||||
sys.stderr.write("Error importing module %s: %s\n" % (mod_str, str(e)))
|
||||
return None
|
||||
|
||||
|
||||
def _is_in_group(opt, group):
|
||||
"Check if opt is in group."
|
||||
for key, value in group._opts.items():
|
||||
if value['opt'] == opt:
|
||||
# NOTE(llu): Temporary workaround for bug #1262148, wait until
|
||||
# newly released oslo.config support '==' operator.
|
||||
if not(value['opt'] != opt):
|
||||
return True
|
||||
return False
|
||||
|
||||
@@ -214,11 +223,19 @@ def _print_opt(opt):
|
||||
sys.exit(1)
|
||||
opt_help += ' (' + OPT_TYPES[opt_type] + ')'
|
||||
print('#', "\n# ".join(textwrap.wrap(opt_help, WORDWRAP_WIDTH)))
|
||||
if opt.deprecated_opts:
|
||||
for deprecated_opt in opt.deprecated_opts:
|
||||
if deprecated_opt.name:
|
||||
deprecated_group = (deprecated_opt.group if
|
||||
deprecated_opt.group else "DEFAULT")
|
||||
print('# Deprecated group/name - [%s]/%s' %
|
||||
(deprecated_group,
|
||||
deprecated_opt.name))
|
||||
try:
|
||||
if opt_default is None:
|
||||
print('#%s=<None>' % opt_name)
|
||||
elif opt_type == STROPT:
|
||||
assert(isinstance(opt_default, basestring))
|
||||
assert(isinstance(opt_default, six.string_types))
|
||||
print('#%s=%s' % (opt_name, _sanitize_default(opt_name,
|
||||
opt_default)))
|
||||
elif opt_type == BOOLOPT:
|
||||
@@ -247,9 +264,6 @@ def _print_opt(opt):
|
||||
|
||||
|
||||
def main():
|
||||
if len(sys.argv) < 2:
|
||||
print("usage: %s [srcfile]...\n" % sys.argv[0])
|
||||
sys.exit(0)
|
||||
generate(sys.argv[1:])
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -77,16 +77,23 @@ find $TARGETDIR -type f -name "*.pyc" -delete
|
||||
FILES=$(find $TARGETDIR -type f -name "*.py" ! -path "*/tests/*" \
|
||||
-exec grep -l "Opt(" {} + | sed -e "s/^$BASEDIRESC\///g" | sort -u)
|
||||
|
||||
EXTRA_MODULES_FILE="`dirname $0`/oslo.config.generator.rc"
|
||||
if test -r "$EXTRA_MODULES_FILE"
|
||||
then
|
||||
source "$EXTRA_MODULES_FILE"
|
||||
fi
|
||||
|
||||
export EVENTLET_NO_GREENDNS=yes
|
||||
|
||||
OS_VARS=$(set | sed -n '/^OS_/s/=[^=]*$//gp' | xargs)
|
||||
[ "$OS_VARS" ] && eval "unset \$OS_VARS"
|
||||
|
||||
MODULEPATH=nova.openstack.common.config.generator
|
||||
DEFAULT_MODULEPATH=nova.openstack.common.config.generator
|
||||
MODULEPATH=${MODULEPATH:-$DEFAULT_MODULEPATH}
|
||||
OUTPUTFILE=$OUTPUTDIR/$PACKAGENAME.conf.sample
|
||||
python -m $MODULEPATH $FILES > $OUTPUTFILE
|
||||
|
||||
# Hook to allow projects to specify custom config file snippets
|
||||
for CONCAT_FILE in $BASEDIR/tools/config/*.conf.sample; do
|
||||
# Hook to allow projects to append custom config file snippets
|
||||
CONCAT_FILES=$(ls $BASEDIR/tools/config/*.conf.sample 2>/dev/null)
|
||||
for CONCAT_FILE in $CONCAT_FILES; do
|
||||
cat $CONCAT_FILE >> $OUTPUTFILE
|
||||
done
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
[keystone_authtoken]
|
||||
|
||||
#
|
||||
# Options defined in keystoneclient's authtoken middleware
|
||||
#
|
||||
|
||||
# Host providing the admin Identity API endpoint
|
||||
auth_host = 127.0.0.1
|
||||
|
||||
# Port of the admin Identity API endpoint
|
||||
auth_port = 35357
|
||||
|
||||
# Protocol of the admin Identity API endpoint
|
||||
auth_protocol = http
|
||||
|
||||
# Keystone service account tenant name to validate user tokens
|
||||
admin_tenant_name = %SERVICE_TENANT_NAME%
|
||||
|
||||
# Keystone account username
|
||||
admin_user = %SERVICE_USER%
|
||||
|
||||
# Keystone account password
|
||||
admin_password = %SERVICE_PASSWORD%
|
||||
|
||||
# Directory used to cache files related to PKI tokens
|
||||
# signing_dir is configurable, but the default behavior of the authtoken
|
||||
# middleware should be sufficient. It will create a temporary directory
|
||||
# in the home directory for the user the nova process is running as.
|
||||
#signing_dir = /var/lib/nova/keystone-signing
|
||||
|
||||
# API version of the admin Identity API endpoint
|
||||
# Workaround for https://bugs.launchpad.net/nova/+bug/1154809
|
||||
auth_version = v2.0
|
||||
@@ -0,0 +1 @@
|
||||
export NOVA_CONFIG_GENERATOR_EXTRA_MODULES=keystoneclient.middleware.auth_token
|
||||
Reference in New Issue
Block a user