summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorLin Tan <lin.tan@intel.com>2015-11-19 14:50:38 +0800
committerLin Tan <lin.tan@intel.com>2016-05-25 11:59:13 +0800
commit773aa20a4ac0364a2219877863017224c7f1089f (patch)
treea1bc60f361ba6a064b36f815dad8c344aec234a2 /tools
parent28314faae70ac029d77b3491bcfd4d5f2ba290e2 (diff)
downloadironic-773aa20a4ac0364a2219877863017224c7f1089f.tar.gz
Make use of oslo-config-generator
oslo_config provide a utility for generating sample config files, which provide more detail about opts, like Minimum/Maximum value and Allowed values. So drop Ironic's "generate_sample.sh" which was copied from oslo-incubator long time ago. Add a new entry point "ironic" under oslo.config.opts namespace to explore config options to oslo-config-generator. After this patch, new config options of Ironic code should register with ironic/conf/opts.py. New external libraries should register with tools/config/ironic-config-generator.conf There is a bug #1554657 with oslo-config about deprecated_group. This bug have impact of some configs from keystonemiddleware and oslo.messaging in ironic.conf.sample So currently, deprecated option should always add the deprecated_group even it didn't alter the group, otherwise the deprecated group value will be 'DEFAULT'. Update etc/ironic/ironic.conf.sample via running 'tox -egenconfig'. Closes-Bug: #1564195 Change-Id: If7721e98e69b6f54f1ee04a07477396b86583371
Diffstat (limited to 'tools')
-rwxr-xr-xtools/config/check_uptodate.sh5
-rwxr-xr-xtools/config/generate_sample.sh138
-rw-r--r--tools/config/ironic-config-generator.conf17
-rw-r--r--tools/config/oslo.config.generator.rc2
4 files changed, 20 insertions, 142 deletions
diff --git a/tools/config/check_uptodate.sh b/tools/config/check_uptodate.sh
index 392a08b77..d762c9254 100755
--- a/tools/config/check_uptodate.sh
+++ b/tools/config/check_uptodate.sh
@@ -2,6 +2,7 @@
PROJECT_NAME=${PROJECT_NAME:-ironic}
CFGFILE_NAME=${PROJECT_NAME}.conf.sample
+OSLO_CFGFILE_OPTION=${OSLO_CFGFILE_OPTION:-tools/config/ironic-config-generator.conf}
if [ -e etc/${PROJECT_NAME}/${CFGFILE_NAME} ]; then
CFGFILE=etc/${PROJECT_NAME}/${CFGFILE_NAME}
@@ -15,7 +16,7 @@ fi
TEMPDIR=`mktemp -d /tmp/${PROJECT_NAME}.XXXXXX`
trap "rm -rf $TEMPDIR" EXIT
-tools/config/generate_sample.sh -b ./ -p ${PROJECT_NAME} -o ${TEMPDIR}
+oslo-config-generator --config-file=${OSLO_CFGFILE_OPTION} --output-file ${TEMPDIR}/${CFGFILE_NAME}
if [ $? != 0 ]
then
exit 1
@@ -24,6 +25,6 @@ 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."
+ echo "${0##*/}: Please run oslo-config-generator --config-file=${OSLO_CFGFILE_OPTION}"
exit 1
fi
diff --git a/tools/config/generate_sample.sh b/tools/config/generate_sample.sh
deleted file mode 100755
index 5363fbf47..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:
-# IRONIC_CONFIG_GENERATOR_EXTRA_MODULES: list of modules to interrogate for options.
-# IRONIC_CONFIG_GENERATOR_EXTRA_LIBRARIES: list of libraries to discover.
-# IRONIC_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/*" ! -path "*/nova/*" \
- -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 ${IRONIC_CONFIG_GENERATOR_EXCLUDED_FILES}; do
- FILES="${FILES[@]/$filename/}"
-done
-
-for mod in ${IRONIC_CONFIG_GENERATOR_EXTRA_MODULES}; do
- MODULES="$MODULES -m $mod"
-done
-
-for lib in ${IRONIC_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_CONFIG_GENERATOR=ironic.common.config_generator.generator
-CONFIG_GENERATOR=${CONFIG_GENERATOR:-$DEFAULT_CONFIG_GENERATOR}
-OUTPUTFILE=$OUTPUTDIR/$PACKAGENAME.conf.sample
-python -m $CONFIG_GENERATOR $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/ironic-config-generator.conf b/tools/config/ironic-config-generator.conf
new file mode 100644
index 000000000..4196cda88
--- /dev/null
+++ b/tools/config/ironic-config-generator.conf
@@ -0,0 +1,17 @@
+[DEFAULT]
+output_file = etc/ironic/ironic.conf.sample
+wrap_width = 62
+namespace = ironic
+namespace = ironic_lib.disk_utils
+namespace = ironic_lib.disk_partitioner
+namespace = ironic_lib.utils
+namespace = oslo.db
+namespace = oslo.messaging
+namespace = oslo.middleware.cors
+namespace = oslo.concurrency
+namespace = oslo.policy
+namespace = oslo.log
+namespace = oslo.service.service
+namespace = oslo.service.periodic_task
+namespace = oslo.service.sslutils
+namespace = keystonemiddleware.auth_token
diff --git a/tools/config/oslo.config.generator.rc b/tools/config/oslo.config.generator.rc
deleted file mode 100644
index 447d8144d..000000000
--- a/tools/config/oslo.config.generator.rc
+++ /dev/null
@@ -1,2 +0,0 @@
-export IRONIC_CONFIG_GENERATOR_EXTRA_LIBRARIES='oslo.db oslo.messaging oslo.middleware.cors keystonemiddleware.auth_token oslo.concurrency oslo.policy oslo.log oslo.service.service oslo.service.periodic_task oslo.service.sslutils'
-export IRONIC_CONFIG_GENERATOR_EXTRA_MODULES='ironic_lib.disk_utils ironic_lib.disk_partitioner ironic_lib.utils'