Use sample config generator from Oslo

Also enable gating on check_uptodate.sh to ensure
that the config is always accurate.

Change-Id: I85b00bf5d6f152af18d4269c8f0802f0c01bb3ea
This commit is contained in:
Dirk Mueller 2013-12-18 12:03:33 +01:00
parent 1f7b2167de
commit ba0d47e4ed
7 changed files with 206 additions and 84 deletions

View File

@ -1,11 +1,5 @@
[DEFAULT]
#
# Ironic API entrypoint URL (without trailing slash)
#
#ironic_url=http://ironic.local:6543/v1
#
# Options defined in tuskar.netconf
#
@ -27,7 +21,9 @@
# The port for the Tuskar API server (integer value)
#tuskar_api_port=8585
#tht_local_dir="/etc/tuskar/tripleo-heat-templates/"
# Local path holding tripleo-heat-templates (string value)
#tht_local_dir=/etc/tuskar/tripleo-heat-templates/
#
# Options defined in tuskar.api.app
@ -37,6 +33,14 @@
#auth_strategy=noauth
#
# Options defined in tuskar.api.controllers.v1.types.link
#
# Ironic API entrypoint URL (string value)
#ironic_url=http://ironic.local:6543/v1
#
# Options defined in tuskar.common.exception
#
@ -72,6 +76,14 @@
#policy_default_rule=default
#
# Options defined in tuskar.compute.nova
#
# nova overcloud keystone uri and credentials (string value)
#nova_overcloud_config=/etc/tuskar/nova_overcloud_config.yml
#
# Options defined in tuskar.db.sqlalchemy.models
#
@ -106,8 +118,7 @@
# Whether to disable inter-process locks (boolean value)
#disable_process_locking=false
# Directory to use for lock files. Default to a temp directory
# (string value)
# Directory to use for lock files. (string value)
#lock_path=<None>
@ -408,42 +419,6 @@
#matchmaker_heartbeat_ttl=600
[rpc_notifier2]
#
# Options defined in tuskar.openstack.common.notifier.rpc_notifier2
#
# AMQP topic(s) used for openstack notifications (list value)
#topics=notifications
[matchmaker_redis]
#
# Options defined in tuskar.openstack.common.rpc.matchmaker_redis
#
# Host to locate redis (string value)
#host=127.0.0.1
# Use this port to connect to redis host. (integer value)
#port=6379
# Password for Redis server. (optional) (string value)
#password=<None>
[matchmaker_ring]
#
# Options defined in tuskar.openstack.common.rpc.matchmaker_ring
#
# Matchmaker ring file (JSON) (string value)
#ringfile=/etc/oslo/matchmaker_ring.json
[database]
#
@ -464,7 +439,7 @@
# The SQLAlchemy connection string used to connect to the
# database (string value)
connection=sqlite:///tuskar.sqlite
#connection=sqlite:////tuskar/openstack/common/db/$sqlite_db
# timeout before idle sql connections are reaped (integer
# value)
@ -499,17 +474,81 @@ connection=sqlite:///tuskar.sqlite
#connection_trace=false
[heat]
stack_name = overcloud
service_type = orchestration
[heat_keystone]
# Heat API keystone configuration.
#
# Options defined in tuskar.heat.client
#
#username = heat
#password = heat
#tenant_name = admin
#auth_url = http://localhost:35357/v2.0
#insecure = True
# The name of a user the overcloud is deployed on behalf of
# (string value)
#username=admin
# The pass of a user the overcloud is deployed on behalf of
# (string value)
#password=<None>
# The tenant name the overcloud is deployed on behalf of
# (string value)
#tenant_name=admin
# Keystone authentication URL (string value)
#auth_url=http://localhost:35357/v2.0
# Set to False when Heat API uses HTTPS (boolean value)
#insecure=true
[rpc_notifier2]
#
# Options defined in tuskar.openstack.common.notifier.rpc_notifier2
#
# AMQP topic(s) used for openstack notifications (list value)
#topics=notifications
[heat]
#
# Options defined in tuskar.heat.client
#
# Name of the overcloud Heat stack (string value)
#stack_name=overcloud
# Heat API service type registered in keystone (string value)
#service_type=orchestration
# Heat API service endpoint type in keystone (string value)
#endpoint_type=publicURL
[matchmaker_redis]
#
# Options defined in tuskar.openstack.common.rpc.matchmaker_redis
#
# Host to locate redis (string value)
#host=127.0.0.1
# Use this port to connect to redis host. (integer value)
#port=6379
# Password for Redis server. (optional) (string value)
#password=<None>
[matchmaker_ring]
#
# Options defined in tuskar.openstack.common.rpc.matchmaker_ring
#
# Matchmaker ring file (JSON) (string value)
#ringfile=/etc/oslo/matchmaker_ring.json
# Total option count: 111

View File

@ -1,27 +0,0 @@
#!/usr/bin/env bash
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2012 SINA Corporation
# All Rights Reserved.
# Author: Zhongyue Luo <lzyeval@gmail.com>
#
# 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.
FILES=$(find tuskar -type f -name "*.py" ! -path "tuskar/tests/*" \
-exec grep -l "Opt(" {} + | sort -u)
export EVENTLET_NO_GREENDNS=yes
MODULEPATH=$(dirname "$0")/../../tuskar/openstack/common/config/generator.py
OUTPUTPATH=etc/tuskar/tuskar.conf.sample
PYTHONPATH=./:${PYTHONPATH} python $MODULEPATH $FILES > $OUTPUTPATH

9
tools/config/check_uptodate.sh Executable file
View File

@ -0,0 +1,9 @@
#!/bin/sh
TEMPDIR=`mktemp -d`
CFGFILE=tuskar.conf.sample
tools/config/generate_sample.sh -b ./ -p tuskar -o $TEMPDIR
if ! diff $TEMPDIR/$CFGFILE etc/tuskar/$CFGFILE
then
echo "E: tuskar.conf.sample is not up to date, please run tools/config/generate_sample.sh"
exit 42
fi

99
tools/config/generate_sample.sh Executable file
View File

@ -0,0 +1,99 @@
#!/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"
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
BASEDIR=${BASEDIR:-`pwd`}
if ! [ -d $BASEDIR ]
then
echo "${0##*/}: missing project base directory" >&2 ; print_hint ; exit 1
elif [[ $BASEDIR != /* ]]
then
BASEDIR=$(cd "$BASEDIR" && pwd)
fi
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}
# 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
echo "${0##*/}: cannot access \`$OUTPUTDIR': No such file or directory" >&2
exit 1
fi
BASEDIRESC=`echo $BASEDIR | sed -e 's/\//\\\\\//g'`
find $TARGETDIR -type f -name "*.pyc" -delete
FILES=$(find $TARGETDIR -type f -name "*.py" ! -path "*/tests/*" \
-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
OS_VARS=$(set | sed -n '/^OS_/s/=[^=]*$//gp' | xargs)
[ "$OS_VARS" ] && eval "unset \$OS_VARS"
DEFAULT_MODULEPATH=tuskar.openstack.common.config.generator
MODULEPATH=${MODULEPATH:-$DEFAULT_MODULEPATH}
OUTPUTFILE=$OUTPUTDIR/$PACKAGENAME.conf.sample
python -m $MODULEPATH $FILES > $OUTPUTFILE
# Hook to allow projects to append custom config file snippets
CONCAT_FILES=$(ls $BASEDIR/tools/config/*.conf.sample 2>/dev/null)
for CONCAT_FILE in $CONCAT_FILES; do
cat $CONCAT_FILE >> $OUTPUTFILE
done

View File

@ -0,0 +1 @@
export OSLO_CONFIG_GENERATOR_EXTRA_MODULES=keystoneclient.middleware.auth_token

View File

@ -14,6 +14,7 @@ deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
commands =
python setup.py testr --slowest --testr-args='{posargs}'
{toxinidir}/tools/config/check_uptodate.sh
[tox:jenkins]
downloadcache = ~/cache/pip