diff --git a/tools/conf/check_uptodate.sh b/tools/conf/check_uptodate.sh deleted file mode 100755 index f0501c3ae5..0000000000 --- a/tools/conf/check_uptodate.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -TMPFILE=`mktemp` -trap "rm -f ${TMPFILE}" EXIT -tools/conf/generate_sample.sh "${TMPFILE}" -if ! diff "${TMPFILE}" etc/nova/nova.conf.sample -then - echo "E: nova.conf.sample is not up to date, please run tools/conf/generate_sample.sh" - exit 42 -fi diff --git a/tools/conf/generate_sample.sh b/tools/conf/generate_sample.sh deleted file mode 100755 index fad7210025..0000000000 --- a/tools/conf/generate_sample.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env bash -# vim: tabstop=4 shiftwidth=4 softtabstop=4 - -# Copyright 2012 SINA Corporation -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# @author: Zhongyue Luo, Intel Corporation. -# - -FILES=$(find nova -type f -name "*.py" ! -path "nova/tests/*" \ - -exec grep -l "Opt(" {} + | sort -u) - -export EVENTLET_NO_GREENDNS=yes - -MODULEPATH=$(dirname "$0")/../../nova/openstack/common/config/generator.py -OUTPUTPATH=${1:-etc/nova/nova.conf.sample} -PYTHONPATH=./:${PYTHONPATH} python $MODULEPATH $FILES > $OUTPUTPATH diff --git a/tools/conf/README b/tools/config/README similarity index 89% rename from tools/conf/README rename to tools/config/README index fc2465272f..64c9f09025 100644 --- a/tools/conf/README +++ b/tools/config/README @@ -2,7 +2,7 @@ This generate_sample.sh tool is used to generate etc/nova/nova.conf.sample Run it from the top-level working directory i.e. - $> ./tools/conf/generate_sample.sh + $> ./tools/config/generate_sample.sh Watch out for warnings about modules like libvirt, qpid and zmq not being found - these warnings are significant because they result @@ -16,5 +16,5 @@ The tool also identifies any options which are set to the default value. Run it from the top-level working directory i.e. - $> ./tools/conf/analyze_opts.py + $> ./tools/config/analyze_opts.py diff --git a/tools/conf/analyze_opts.py b/tools/config/analyze_opts.py similarity index 100% rename from tools/conf/analyze_opts.py rename to tools/config/analyze_opts.py diff --git a/tools/config/check_uptodate.sh b/tools/config/check_uptodate.sh new file mode 100755 index 0000000000..b1f86aaf5f --- /dev/null +++ b/tools/config/check_uptodate.sh @@ -0,0 +1,9 @@ +#!/bin/sh +TEMPDIR=`mktemp -d` +CFGFILE=nova.conf.sample +tools/config/generate_sample.sh -b ./ -p nova -o $TEMPDIR +if ! diff $TEMPDIR/$CFGFILE etc/nova/$CFGFILE +then + echo "E: nova.conf.sample is not up to date, please run tools/config/generate_sample.sh" + exit 42 +fi diff --git a/tools/config/generate_sample.sh b/tools/config/generate_sample.sh new file mode 100755 index 0000000000..9ac41f0dc4 --- /dev/null +++ b/tools/config/generate_sample.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash + +print_hint() { + echo "Try \`${0##*/} --help' for more information." >&2 +} + +PARSED_OPTIONS=$(getopt -n "${0##*/}" -o hb:p:o: \ + --long help,base-dir:,package-name:,output-dir: -- "$@") + +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 (required)" + echo "-p, --package-name=NAME Project package name" + echo "-o, --output-dir=DIR File output directory" + 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 + ;; + --) + break + ;; + esac +done + +if [ -z $BASEDIR ] || ! [ -d $BASEDIR ] +then + echo "${0##*/}: missing project base directory" >&2 ; print_hint ; exit 1 +fi + +PACKAGENAME=${PACKAGENAME:-${BASEDIR##*/}} + +OUTPUTDIR=${OUTPUTDIR:-$BASEDIR/etc} +if ! [ -d $OUTPUTDIR ] +then + echo "${0##*/}: cannot access \`$OUTPUTDIR': No such file or directory" >&2 + exit 1 +fi + +BASEDIRESC=`echo $BASEDIR | sed -e 's/\//\\\\\//g'` +FILES=$(find $BASEDIR/$PACKAGENAME -type f -name "*.py" ! -path "*/tests/*" \ + -exec grep -l "Opt(" {} + | sed -e "s/^$BASEDIRESC\///g" | sort -u) + +export EVENTLET_NO_GREENDNS=yes + +MODULEPATH=nova.openstack.common.config.generator +OUTPUTFILE=$OUTPUTDIR/$PACKAGENAME.conf.sample +python -m $MODULEPATH $FILES > $OUTPUTFILE diff --git a/tox.ini b/tox.ini index 617fd12a01..c95e97a238 100644 --- a/tox.ini +++ b/tox.ini @@ -22,7 +22,7 @@ downloadcache = ~/cache/pip sitepackages = False commands = flake8 {posargs} - {toxinidir}/tools/conf/check_uptodate.sh + {toxinidir}/tools/config/check_uptodate.sh [testenv:pylint] setenv = VIRTUAL_ENV={envdir}