111a056c0f
As it stands, the opts.py file that is passed into oslo-config-generator isn't being generated dynamically and the old way of generating the cinder.conf.sample is dependent on oslo-incubator which Cinder is trying to move away from. oslo-config-generator works differently than oslo-incubator so a number of changes had to be made in order to make this switch. This patch adds the config directory to Cinder and in it are two files: -generate_cinder_opts.py that will take the results of a grep command to create the opts.py file to be passed into oslo-config-generator. -cinder.conf which is the new configuration for oslo-config-generator. The file is inside the config directory to be consistent with other projects. Some changes were made to the generate_sample.sh file in order to give the base directories and target directories to the generate_cinder_opts.py program. tox.ini was edited to remove the checkonly option because all that needs to happen in check_uptodate.sh is a check to ensure that the cinder.conf.sample is actually being generated with no issues. All options were removed from the check_uptodate.sh because they were unnecessary given the new, more simple way of generating the cinder.conf.sample. setup.cfg was also edited in order to add information oslo-config-generator needs to run. Co-Authored By: Jay Bryant <jsbryant@us.ibm.com> Co-Authored By: Jacob Gregor <jgregor@us.ibm.com> Change-Id: I643dbe5675ae9280e204f691781e617266f570d5 Closes-Bug: 1473768 Closes-Bug: 1437904 Closes-Bug: 1381563
85 lines
2.6 KiB
Bash
Executable File
85 lines
2.6 KiB
Bash
Executable File
#!/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.
|
||
|
||
BASEDIR=${BASEDIR:-`pwd`}
|
||
|
||
print_error ()
|
||
{
|
||
echo -en "\n\n##########################################################"
|
||
echo -en "\nERROR: ${0} was not called from tox."
|
||
echo -en "\n Execute 'tox -e genconfig' for cinder.conf.sample"
|
||
echo -en "\n generation."
|
||
echo -en "\n##########################################################\n\n"
|
||
}
|
||
|
||
if [ -z ${1} ] ; then
|
||
print_error
|
||
exit 1
|
||
fi
|
||
|
||
if [ ${1} != "from_tox" ] ; then
|
||
print_error
|
||
exit 1
|
||
fi
|
||
|
||
if ! [ -d $BASEDIR ]
|
||
then
|
||
echo "${0##*/}: missing project base directory" >&2 ; 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 ; exit 1
|
||
fi
|
||
|
||
BASEDIRESC=`echo $BASEDIR | sed -e 's/\//\\\\\//g'`
|
||
find $TARGETDIR -type f -name "*.pyc" -delete
|
||
|
||
export TARGETDIR=$TARGETDIR
|
||
export BASEDIRESC=$BASEDIRESC
|
||
|
||
python cinder/config/generate_cinder_opts.py
|
||
|
||
if [ $? -ne 0 ]
|
||
then
|
||
echo -en "\n\n#################################################"
|
||
echo -en "\nERROR: Non-zero exit from generate_cinder_opts.py."
|
||
echo -en "\n See output above for details.\n"
|
||
echo -en "#################################################\n"
|
||
exit 1
|
||
fi
|
||
|
||
oslo-config-generator --config-file=cinder/config/cinder-config-generator.conf
|
||
|
||
if [ $? -ne 0 ]
|
||
then
|
||
echo -en "\n\n#################################################"
|
||
echo -en "\nERROR: Non-zero exit from oslo-config-generator."
|
||
echo -en "\n See output above for details.\n"
|
||
echo -en "#################################################\n"
|
||
exit 1
|
||
fi
|
||
if [ ! -s ./etc/cinder/cinder.conf.sample ] ; then
|
||
echo -en "\n\n#########################################################"
|
||
echo -en "\nERROR: etc/cinder/cinder.sample.conf not created properly."
|
||
echo -en "\n See above output for details.\n"
|
||
echo -en "###########################################################\n"
|
||
exit 1
|
||
fi
|
||
|
||
rm -f cinder/opts.py
|
||
rm -f cinder/opts.pyc
|