diff options
| author | Pavlo Shchelokovskyy <shchelokovskyy@gmail.com> | 2016-11-17 14:25:23 +0200 |
|---|---|---|
| committer | Pavlo Shchelokovskyy <shchelokovskyy@gmail.com> | 2016-12-09 21:01:02 +0200 |
| commit | 762f3bf4e65ce8cd279581bae50ecd70f7800ec8 (patch) | |
| tree | 3f68fefc92d6ae0ca160eaf740ef6d72a1e0556d /tools | |
| parent | 73825b28b89a85435072cd8f3f8140bc86c3b763 (diff) | |
| download | ironic-python-agent-762f3bf4e65ce8cd279581bae50ecd70f7800ec8.tar.gz | |
Use oslo-config-generator for sample config
The old generate_sample.sh is broken already as it refers to
non-existing openstack/common path.
Let's use oslo-config-generator as many other OpenStack projects do.
Also, where applicable, option descriptions are updated with the
corresponding kernel parameters to set those options durig pxe boot.
Change-Id: Id4a0df30ea573d52f3b359f357fe8f4a29751939
Diffstat (limited to 'tools')
| -rwxr-xr-x | tools/config/check_uptodate.sh | 11 | ||||
| -rwxr-xr-x | tools/config/generate_sample.sh | 117 | ||||
| -rw-r--r-- | tools/config/ipa-config-generator.conf | 5 | ||||
| -rw-r--r-- | tools/config/oslo.config.generator.rc | 0 |
4 files changed, 13 insertions, 120 deletions
diff --git a/tools/config/check_uptodate.sh b/tools/config/check_uptodate.sh index 49e49f0a..d1a5cc29 100755 --- a/tools/config/check_uptodate.sh +++ b/tools/config/check_uptodate.sh @@ -2,6 +2,7 @@ PROJECT_NAME=${PROJECT_NAME:-ironic_python_agent} CFGFILE_NAME=${PROJECT_NAME}.conf.sample +OSLO_CFGFILE_OPTION=${OSLO_CFGFILE_OPTION:-tools/config/ipa-config-generator.conf} if [ -e etc/${PROJECT_NAME}/${CFGFILE_NAME} ]; then CFGFILE=etc/${PROJECT_NAME}/${CFGFILE_NAME} @@ -15,10 +16,14 @@ 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 + echo "oslo-config-generator failed to create a sample config file ${TEMPDIR}/${CFGFILE_NAME} with --config-file ${OSLO_CFGFILE_OPTION}" + exit 1 +fi -if ! diff -u ${TEMPDIR}/${CFGFILE_NAME} ${CFGFILE} ; then +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 7058a129..00000000 --- a/tools/config/generate_sample.sh +++ /dev/null @@ -1,117 +0,0 @@ -#!/usr/bin/env bash - -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:-${BASEDIR##*/}} -PACKAGENAME=`echo $PACKAGENAME | tr - _` -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 mod in ${IRONIC_PYTHON_AGENT_CONFIG_GENERATOR_EXTRA_MODULES}; do - MODULES="$MODULES -m $mod" -done - -for lib in ${IRONIC_PYTHON_AGENT_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=ironic_python_agent.openstack.common.config.generator -MODULEPATH=${MODULEPATH:-$DEFAULT_MODULEPATH} -OUTPUTFILE=$OUTPUTDIR/$PACKAGENAME.conf.sample -python -m $MODULEPATH $MODULES $LIBRARIES $FILES > $OUTPUTFILE - -# 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/ipa-config-generator.conf b/tools/config/ipa-config-generator.conf new file mode 100644 index 00000000..424cbb28 --- /dev/null +++ b/tools/config/ipa-config-generator.conf @@ -0,0 +1,5 @@ +[DEFAULT] +output_file = etc/ironic_python_agent/ironic_python_agent.conf.sample +wrap_width = 62 +namespace = ironic-python-agent +namespace = oslo.log diff --git a/tools/config/oslo.config.generator.rc b/tools/config/oslo.config.generator.rc deleted file mode 100644 index e69de29b..00000000 --- a/tools/config/oslo.config.generator.rc +++ /dev/null |
