diff options
| author | Dolph Mathews <dolph.mathews@gmail.com> | 2014-08-13 09:13:04 -0500 |
|---|---|---|
| committer | Brant Knudson <bknudson@us.ibm.com> | 2015-01-02 15:04:20 -0600 |
| commit | 083d1cd5223067ec616e715b7d7cdd213fdb8cb4 (patch) | |
| tree | 8af66da880568229dc2cd0d8a5ecf3d89410e790 /tools | |
| parent | f5c06d619c762d5d39e8ec3bc752215ec02b2756 (diff) | |
| download | keystone-083d1cd5223067ec616e715b7d7cdd213fdb8cb4.tar.gz | |
switch from sample_config.sh to oslo-config-generator
This switches keystone to use oslo-config-generator, where the contents
of our sample configuration file are configured using a configuration
file in config-generators/, because the only way to have tox create
files is to have configuration files for your configuration files
(seriously, it chokes when redirects are included in the command for a
test environment).
This also takes advantage of oslo-config-generator's ability to set the
line wrap width, which is done at 79 chars here to match the rest of our
code.
Also update the actual sample file under etc/
Change-Id: I9f9a157c7802c56a2c7484f6f4adec4aeb4071b8
Closes-Bug: 1324610
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/config/README | 38 | ||||
| -rwxr-xr-x | tools/config/check_uptodate.sh | 29 | ||||
| -rwxr-xr-x | tools/config/generate_sample.sh | 138 | ||||
| -rw-r--r-- | tools/config/oslo.config.generator.rc | 4 |
4 files changed, 0 insertions, 209 deletions
diff --git a/tools/config/README b/tools/config/README deleted file mode 100644 index c6079dab0..000000000 --- a/tools/config/README +++ /dev/null @@ -1,38 +0,0 @@ -This generate_sample.sh tool is used to generate sample config files -from OpenStack project source trees. - -Run it by passing the base directory and package name i.e. - - $> generate_sample.sh --base-dir /opt/stack/nova --package-name nova \ - --output-dir /opt/stack/nova/etc - $> generate_sample.sh -b /opt/stack/neutron -p nova -o /opt/stack/neutron/etc - -Optionally, include libraries that register entry points for option -discovery, such as oslo.messaging: - - $> generate_sample.sh -b /opt/stack/ceilometer -p ceilometer \ - -o /opt/stack/ceilometer/etc -l oslo.messaging - -Watch out for warnings about modules like libvirt, qpid and zmq not -being found - these warnings are significant because they result -in options not appearing in the generated config file. - - - -This check_uptodate.sh tool is used to ensure that the generated sample -config file in the OpenStack project source tree is continually kept up -to date with the code itself. - -This can be done by adding a hook to tox.ini. For example, if a project -already had flake8 enabled in a section like this: - - [testenv.pep8] - commands = - flake8 {posargs} - -This section would be changed to: - - [testenv.pep8] - commands = - flake8 {posargs} - {toxinidir}/tools/config/check_uptodate.sh diff --git a/tools/config/check_uptodate.sh b/tools/config/check_uptodate.sh deleted file mode 100755 index d9ff684e2..000000000 --- a/tools/config/check_uptodate.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env bash - -PROJECT_NAME=${PROJECT_NAME:-keystone} -CFGFILE_NAME=${PROJECT_NAME}.conf.sample - -if [ -e etc/${PROJECT_NAME}/${CFGFILE_NAME} ]; then - CFGFILE=etc/${PROJECT_NAME}/${CFGFILE_NAME} -elif [ -e etc/${CFGFILE_NAME} ]; then - CFGFILE=etc/${CFGFILE_NAME} -else - echo "${0##*/}: can not find config file" - exit 1 -fi - -TEMPDIR=`mktemp -d /tmp/${PROJECT_NAME}.XXXXXX` -trap "rm -rf $TEMPDIR" EXIT - -tools/config/generate_sample.sh -b ./ -p ${PROJECT_NAME} -o ${TEMPDIR} -if [ $? != 0 ] -then - exit 1 -fi - -if ! diff -u ${TEMPDIR}/${CFGFILE_NAME} ${CFGFILE} -then - echo "${0##*/}: ${PROJECT_NAME}.conf.sample is not up to date." - echo "${0##*/}: Please run ${0%%${0##*/}}generate_sample.sh." - exit 1 -fi diff --git a/tools/config/generate_sample.sh b/tools/config/generate_sample.sh deleted file mode 100755 index c5773d127..000000000 --- a/tools/config/generate_sample.sh +++ /dev/null @@ -1,138 +0,0 @@ -#!/usr/bin/env bash - -# Generate sample configuration for your project. -# -# Aside from the command line flags, it also respects a config file which -# should be named oslo.config.generator.rc and be placed in the same directory. -# -# You can then export the following variables: -# KEYSTONE_CONFIG_GENERATOR_EXTRA_MODULES: list of modules to interrogate for options. -# KEYSTONE_CONFIG_GENERATOR_EXTRA_LIBRARIES: list of libraries to discover. -# KEYSTONE_CONFIG_GENERATOR_EXCLUDED_FILES: list of files to remove from automatic listing. - -print_hint() { - echo "Try \`${0##*/} --help' for more information." >&2 -} - -PARSED_OPTIONS=$(getopt -n "${0##*/}" -o hb:p:m:l:o: \ - --long help,base-dir:,package-name:,output-dir:,module:,library: -- "$@") - -if [ $? != 0 ] ; then print_hint ; exit 1 ; fi - -eval set -- "$PARSED_OPTIONS" - -while true; do - case "$1" in - -h|--help) - echo "${0##*/} [options]" - echo "" - echo "options:" - echo "-h, --help show brief help" - echo "-b, --base-dir=DIR project base directory" - echo "-p, --package-name=NAME project package name" - echo "-o, --output-dir=DIR file output directory" - echo "-m, --module=MOD extra python module to interrogate for options" - echo "-l, --library=LIB extra library that registers options for discovery" - exit 0 - ;; - -b|--base-dir) - shift - BASEDIR=`echo $1 | sed -e 's/\/*$//g'` - shift - ;; - -p|--package-name) - shift - PACKAGENAME=`echo $1` - shift - ;; - -o|--output-dir) - shift - OUTPUTDIR=`echo $1 | sed -e 's/\/*$//g'` - shift - ;; - -m|--module) - shift - MODULES="$MODULES -m $1" - shift - ;; - -l|--library) - shift - LIBRARIES="$LIBRARIES -l $1" - shift - ;; - --) - break - ;; - esac -done - -BASEDIR=${BASEDIR:-`pwd`} -if ! [ -d $BASEDIR ] -then - echo "${0##*/}: missing project base directory" >&2 ; print_hint ; exit 1 -elif [[ $BASEDIR != /* ]] -then - BASEDIR=$(cd "$BASEDIR" && pwd) -fi - -PACKAGENAME=${PACKAGENAME:-$(python setup.py --name)} -TARGETDIR=$BASEDIR/$PACKAGENAME -if ! [ -d $TARGETDIR ] -then - echo "${0##*/}: invalid project package name" >&2 ; print_hint ; exit 1 -fi - -OUTPUTDIR=${OUTPUTDIR:-$BASEDIR/etc} -# NOTE(bnemec): Some projects put their sample config in etc/, -# some in etc/$PACKAGENAME/ -if [ -d $OUTPUTDIR/$PACKAGENAME ] -then - OUTPUTDIR=$OUTPUTDIR/$PACKAGENAME -elif ! [ -d $OUTPUTDIR ] -then - echo "${0##*/}: cannot access \`$OUTPUTDIR': No such file or directory" >&2 - exit 1 -fi - -BASEDIRESC=`echo $BASEDIR | sed -e 's/\//\\\\\//g'` -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) - -RC_FILE="`dirname $0`/oslo.config.generator.rc" -if test -r "$RC_FILE" -then - source "$RC_FILE" -fi - -for filename in ${KEYSTONE_CONFIG_GENERATOR_EXCLUDED_FILES}; do - FILES="${FILES[@]/$filename/}" -done - -for mod in ${KEYSTONE_CONFIG_GENERATOR_EXTRA_MODULES}; do - MODULES="$MODULES -m $mod" -done - -for lib in ${KEYSTONE_CONFIG_GENERATOR_EXTRA_LIBRARIES}; do - LIBRARIES="$LIBRARIES -l $lib" -done - -export EVENTLET_NO_GREENDNS=yes - -OS_VARS=$(set | sed -n '/^OS_/s/=[^=]*$//gp' | xargs) -[ "$OS_VARS" ] && eval "unset \$OS_VARS" -DEFAULT_MODULEPATH=keystone.openstack.common.config.generator -MODULEPATH=${MODULEPATH:-$DEFAULT_MODULEPATH} -OUTPUTFILE=$OUTPUTDIR/$PACKAGENAME.conf.sample -python -m $MODULEPATH $MODULES $LIBRARIES $FILES > $OUTPUTFILE -if [ $? != 0 ] -then - echo "Can not generate $OUTPUTFILE" - exit 1 -fi - -# 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 diff --git a/tools/config/oslo.config.generator.rc b/tools/config/oslo.config.generator.rc deleted file mode 100644 index f4d733515..000000000 --- a/tools/config/oslo.config.generator.rc +++ /dev/null @@ -1,4 +0,0 @@ -# Environmental Variables that affect the automatic sample config generation. -# Additions to any of these variables are space delimited. See the "generate_sample.sh" -# script for the variables that can be used. -KEYSTONE_CONFIG_GENERATOR_EXTRA_LIBRARIES='keystone oslo.messaging oslo.db' |
