cinder/tools/config/check_uptodate.sh
Kendall Nelson 2f9e4163f4 Downstream Fix for Genconfig
This patch adds the opts.py file to the tree as a fix for deployers
that package cinder. The opts.py file is no longer being deleted right
away by generate_sample.sh after the cinder.sample.conf is being
generated.

This patch also introduces a pep8 check to make sure that the opts.py
file is up to date, so that it will catch when new opts get added to
Cinder without the opts.py being updated.

To support the ability to keep and check the opts file a number
of changes were needed in the check_uptodate.sh script as well as
the generate_sample.sh script:
    - check_uptodate now takes --checkopts instead of --checkonly
      When checkopts is used the opts.py file is generated using the
      current code and the generated file is compared to the existing
      file.  The check fails if there are differences.
    - generate_sample now has the --nosamplefile option.
      When this option is used, only the opts.py file is generated.
      The oslo-config-generator code is skipped so no sample file
      is created.
    - generate_sample also has some coding style consistency changes.
    - Added the 'genopts' option to tox so users can generate
      a fresh opts.py without a sample file when necessary.

Closes-Bug: 1501820
Co-Author: Jay Bryant <jsbryant@us.ibm.com>

Change-Id: I1f5494ebb19d5f4e8c651cbeef0acad07ad96829
2015-11-13 12:36:21 -06:00

58 lines
2.1 KiB
Bash
Executable File

#!/usr/bin/env bash
CHECKOPTS=0
if [ "$1" == "--checkopts" ]; then
CHECKOPTS=1
fi
PROJECT_NAME=${PROJECT_NAME:-cinder}
CFGFILE_NAME=${PROJECT_NAME}.conf.sample
if [ $CHECKOPTS -eq 1 ]; then
if [ ! -e cinder/opts.py ]; then
echo -en "\n\n#################################################"
echo -en "\nERROR: cinder/opts.py file is missing."
echo -en "\n#################################################\n"
exit 1
else
mv cinder/opts.py cinder/opts.py.orig
tox -e genopts &> /dev/null
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"
mv cinder/opts.py.orig cinder/opts.py
exit 1
else
diff cinder/opts.py.orig cinder/opts.py
if [ $? -ne 0 ]; then
echo -en "\n\n########################################################"
echo -en "\nERROR: Configuration options change detected."
echo -en "\n A new cinder/opts.py file must be generated."
echo -en "\n Run 'tox -e genopts' from the base directory"
echo -en "\n and add the result to your commit."
echo -en "\n########################################################\n\n"
rm cinder/opts.py
mv cinder/opts.py.orig cinder/opts.py
exit 1
else
rm cinder/opts.py.orig
fi
fi
fi
else
tox -e genconfig &> /dev/null
if [ -e etc/${PROJECT_NAME}/${CFGFILE_NAME} ]; then
CFGFILE=etc/${PROJECT_NAME}/${CFGFILE_NAME}
rm -f $CFGFILE
else
echo -en "\n\n####################################################"
echo -en "\n${0##*/}: Can't find config file."
echo -en "\n####################################################\n\n"
exit 1
fi
fi