Update config generator
Updated straight from oslo-incubator. Change-Id: I3ff25a7e70e03c0651b6dfa23a526771c6496cfb
This commit is contained in:
parent
f505ae11b7
commit
acd0aa87f2
@ -78,6 +78,13 @@ def generate(srcfiles):
|
|||||||
# The options list is a list of (module, options) tuples
|
# The options list is a list of (module, options) tuples
|
||||||
opts_by_group = {'DEFAULT': []}
|
opts_by_group = {'DEFAULT': []}
|
||||||
|
|
||||||
|
for module_name in os.getenv(
|
||||||
|
"OSLO_CONFIG_GENERATOR_EXTRA_MODULES", "").split(','):
|
||||||
|
module = _import_module(module_name)
|
||||||
|
if module:
|
||||||
|
for group, opts in _list_opts(module):
|
||||||
|
opts_by_group.setdefault(group, []).append((module_name, opts))
|
||||||
|
|
||||||
for pkg_name in pkg_names:
|
for pkg_name in pkg_names:
|
||||||
mods = mods_by_pkg.get(pkg_name)
|
mods = mods_by_pkg.get(pkg_name)
|
||||||
mods.sort()
|
mods.sort()
|
||||||
@ -247,9 +254,6 @@ def _print_opt(opt):
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
if len(sys.argv) < 2:
|
|
||||||
print("usage: %s [srcfile]...\n" % sys.argv[0])
|
|
||||||
sys.exit(0)
|
|
||||||
generate(sys.argv[1:])
|
generate(sys.argv[1:])
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@ -18,9 +18,9 @@ while true; do
|
|||||||
echo ""
|
echo ""
|
||||||
echo "options:"
|
echo "options:"
|
||||||
echo "-h, --help show brief help"
|
echo "-h, --help show brief help"
|
||||||
echo "-b, --base-dir=DIR Project base directory (required)"
|
echo "-b, --base-dir=DIR project base directory"
|
||||||
echo "-p, --package-name=NAME Project package name"
|
echo "-p, --package-name=NAME project package name"
|
||||||
echo "-o, --output-dir=DIR File output directory"
|
echo "-o, --output-dir=DIR file output directory"
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
-b|--base-dir)
|
-b|--base-dir)
|
||||||
@ -44,26 +44,49 @@ while true; do
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ -z $BASEDIR ] || ! [ -d $BASEDIR ]
|
BASEDIR=${BASEDIR:-`pwd`}
|
||||||
|
if ! [ -d $BASEDIR ]
|
||||||
then
|
then
|
||||||
echo "${0##*/}: missing project base directory" >&2 ; print_hint ; exit 1
|
echo "${0##*/}: missing project base directory" >&2 ; print_hint ; exit 1
|
||||||
|
elif [[ $BASEDIR != /* ]]
|
||||||
|
then
|
||||||
|
BASEDIR=$(cd "$BASEDIR" && pwd)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
PACKAGENAME=${PACKAGENAME:-${BASEDIR##*/}}
|
PACKAGENAME=${PACKAGENAME:-${BASEDIR##*/}}
|
||||||
|
TARGETDIR=$BASEDIR/$PACKAGENAME
|
||||||
|
if ! [ -d $TARGETDIR ]
|
||||||
|
then
|
||||||
|
echo "${0##*/}: invalid project package name" >&2 ; print_hint ; exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
OUTPUTDIR=${OUTPUTDIR:-$BASEDIR/etc}
|
OUTPUTDIR=${OUTPUTDIR:-$BASEDIR/etc}
|
||||||
if ! [ -d $OUTPUTDIR ]
|
# 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
|
then
|
||||||
echo "${0##*/}: cannot access \`$OUTPUTDIR': No such file or directory" >&2
|
echo "${0##*/}: cannot access \`$OUTPUTDIR': No such file or directory" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
BASEDIRESC=`echo $BASEDIR | sed -e 's/\//\\\\\//g'`
|
BASEDIRESC=`echo $BASEDIR | sed -e 's/\//\\\\\//g'`
|
||||||
FILES=$(find $BASEDIR/$PACKAGENAME -type f -name "*.py" ! -path "*/tests/*" \
|
FILES=$(find $TARGETDIR -type f -name "*.py" ! -path "*/tests/*" \
|
||||||
-exec grep -l "Opt(" {} + | sed -e "s/^$BASEDIRESC\///g" | sort -u)
|
-exec grep -l "Opt(" {} + | sed -e "s/^$BASEDIRESC\///g" | sort -u)
|
||||||
|
|
||||||
|
EXTRA_MODULES_FILE="`dirname $0`/oslo.config.generator.rc"
|
||||||
|
if test -r "$EXTRA_MODULES_FILE"
|
||||||
|
then
|
||||||
|
source "$EXTRA_MODULES_FILE"
|
||||||
|
fi
|
||||||
|
|
||||||
export EVENTLET_NO_GREENDNS=yes
|
export EVENTLET_NO_GREENDNS=yes
|
||||||
|
|
||||||
|
OS_VARS=$(set | sed -n '/^OS_/s/=[^=]*$//gp' | xargs)
|
||||||
|
[ "$OS_VARS" ] && eval "unset \$OS_VARS"
|
||||||
|
|
||||||
MODULEPATH=ceilometer.openstack.common.config.generator
|
MODULEPATH=ceilometer.openstack.common.config.generator
|
||||||
OUTPUTFILE=$OUTPUTDIR/$PACKAGENAME.conf.sample
|
OUTPUTFILE=$OUTPUTDIR/$PACKAGENAME.conf.sample
|
||||||
python -m $MODULEPATH $FILES > $OUTPUTFILE
|
python -m $MODULEPATH $FILES > $OUTPUTFILE
|
||||||
|
Loading…
Reference in New Issue
Block a user