From 116f54dbf188a17b5e3dd966658e98bf19b8912b Mon Sep 17 00:00:00 2001 From: John Griffith Date: Tue, 15 Jul 2014 11:45:17 -0600 Subject: [PATCH] Update cinder generate_sample script Cinder's generate sample script has fallen a bit out of date and was no longer working properly in local venv. This patch updates it with a working version that reads the rc file and makes some other updates. Even better, we'll update the tox.ini file here so that it actually works, and finally add some more info to the error message when update check fails to make is obvious how to run these appropriately. Change-Id: I2389910d8ece6f737a9609ce4aa05263d9293e14 --- tools/config/check_uptodate.sh | 5 ++++- tools/config/generate_sample.sh | 21 ++++++++++++++++++++- tox.ini | 5 +++-- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/tools/config/check_uptodate.sh b/tools/config/check_uptodate.sh index 55f01c93f..cf51c8caf 100755 --- a/tools/config/check_uptodate.sh +++ b/tools/config/check_uptodate.sh @@ -20,6 +20,9 @@ tools/config/generate_sample.sh -b ./ -p ${PROJECT_NAME} -o ${TEMPDIR} 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 ${0%%${0##*/}}generate_sample.sh from within a VENV." + echo " \'source .venv/bin/activate; generate_sample.sh\'" + echo "OR simply run tox genconfig" + echo " \'tox -egenconfig\'" exit 1 fi diff --git a/tools/config/generate_sample.sh b/tools/config/generate_sample.sh index b94718036..0416d2aee 100755 --- a/tools/config/generate_sample.sh +++ b/tools/config/generate_sample.sh @@ -1,5 +1,15 @@ #!/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: +# CINDER_CONFIG_GENERATOR_EXTRA_MODULES: list of modules to interrogate for options. +# CINDER_CONFIG_GENERATOR_EXTRA_LIBRARIES: list of libraries to discover. +# CINDER_CONFIG_GENERATOR_EXCLUDED_FILES: list of files to remove from automatic listing. + print_hint() { echo "Try \`${0##*/} --help' for more information." >&2 } @@ -65,7 +75,7 @@ then BASEDIR=$(cd "$BASEDIR" && pwd) fi -PACKAGENAME=${PACKAGENAME:-${BASEDIR##*/}} +PACKAGENAME=${PACKAGENAME:-$(python setup.py --name)} TARGETDIR=$BASEDIR/$PACKAGENAME if ! [ -d $TARGETDIR ] then @@ -95,6 +105,10 @@ then source "$RC_FILE" fi +for filename in ${CINDER_CONFIG_GENERATOR_EXCLUDED_FILES}; do + FILES="${FILES[@]/$filename/}" +done + for mod in ${CINDER_CONFIG_GENERATOR_EXTRA_MODULES}; do MODULES="$MODULES -m $mod" done @@ -111,6 +125,11 @@ DEFAULT_MODULEPATH=cinder.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) diff --git a/tox.ini b/tox.ini index 76932487d..7e4beb99a 100644 --- a/tox.ini +++ b/tox.ini @@ -40,8 +40,9 @@ commands = --testr-args='^(?!.*test.*coverage).*$' [testenv:genconfig] -commands = - bash tools/config/generate_sample.sh -b . -p cinder -o etc/cinder +sitepackages = False +envdir = {toxworkdir}/venv +commands = {toxinidir}/tools/config/generate_sample.sh -b . -p cinder -o etc/cinder [testenv:venv] commands = {posargs} -- 2.45.2