9dc0ae8498
Change-Id: I854bdeffa3b2765837c3449e65b99f631c087148
282 lines
7.8 KiB
Bash
Executable File
282 lines
7.8 KiB
Bash
Executable File
#!/bin/bash
|
|
# 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.
|
|
|
|
set -e
|
|
|
|
HERE=$(pwd)
|
|
VENVDIR=$HERE/venv
|
|
SOURCESDIR=$HERE/sources
|
|
MANUALSREPO=$SOURCESDIR/openstack-manuals
|
|
MAPPINGS_DIR=$MANUALSREPO/tools/autogenerate-config-flagmappings
|
|
AUTOHELP="python $HERE/autohelp.py"
|
|
EXTRACT_SWIFT="python $HERE/extract_swift_flags.py"
|
|
GITBASE=${GITBASE:-git://git.openstack.org/openstack}
|
|
GITPROJ=${GITPROJ:-git://git.openstack.org/openstack}
|
|
PROJECTS="aodh ceilometer cinder glance heat ironic keystone manila \
|
|
murano neutron nova sahara senlin swift trove zaqar"
|
|
MANUALS_PROJECTS="openstack-manuals"
|
|
BRANCH=master
|
|
FAST=0
|
|
QUIET=0
|
|
|
|
usage() {
|
|
echo "Wrapper for autohelp.py"
|
|
echo "Usage:"
|
|
echo " $(basename $0) [ OPTIONS ] update|docbook|rst|setup [ project... ]"
|
|
echo
|
|
echo "Subcommands:"
|
|
echo " update: Update or create the flagmapping files"
|
|
echo " docbook: Generate the options tables in docbook format"
|
|
echo " rst: Generate the options tables in RST format"
|
|
echo " setup: Install the environment only"
|
|
echo
|
|
echo "Options:"
|
|
echo " -b BRANCH: Work on this branch (defaults to master)"
|
|
echo " -g GITPROJ: Use this location for the project git repos "
|
|
echo " (defaults to git://git.openstack.org/openstack)"
|
|
echo " -c: Recreate the virtual environment"
|
|
echo " -f: Work offline: Do not change environment or sources"
|
|
echo " -e PATH: Create the virtualenv in PATH"
|
|
echo " -v LEVEL: Verbose message (1 or 2)"
|
|
echo " (check various python modules imported or not)"
|
|
}
|
|
|
|
setup_venv() {
|
|
project=$1
|
|
|
|
if [ ! -e $VENVDIR/$project/bin/activate ]; then
|
|
mkdir -p $VENVDIR/$project
|
|
virtualenv $VENVDIR/$project
|
|
fi
|
|
activate_venv $project
|
|
}
|
|
|
|
activate_venv() {
|
|
project=$1
|
|
|
|
. $VENVDIR/$project/bin/activate
|
|
pip install --upgrade pip setuptools
|
|
}
|
|
|
|
get_project() {
|
|
project=$1
|
|
git_url=$GITPROJ
|
|
|
|
if [ ! -e $SOURCESDIR/$project ]; then
|
|
if [[ $MANUALS_PROJECTS =~ (^| )$project($| ) ]]; then
|
|
git_url=$GITBASE
|
|
fi
|
|
git clone $git_url/$project $SOURCESDIR/$project
|
|
|
|
if [ -e $MAPPINGS_DIR/$project.extra_repos ]; then
|
|
while read extra; do
|
|
git clone $git_url/$extra $SOURCESDIR/$extra
|
|
done < $MAPPINGS_DIR/$project.extra_repos
|
|
fi
|
|
|
|
else
|
|
if [ $project != openstack-manuals ]; then
|
|
(cd $SOURCESDIR/$project && git pull)
|
|
fi
|
|
|
|
if [ -e $MAPPINGS_DIR/$project.extra_repos ]; then
|
|
while read extra; do
|
|
(cd $SOURCESDIR/$extra && git pull)
|
|
done < $MAPPINGS_DIR/$project.extra_repos
|
|
fi
|
|
fi
|
|
}
|
|
|
|
setup_tools() {
|
|
pip install -rrequirements.txt
|
|
}
|
|
|
|
while getopts :b:g:e:v:cfq opt; do
|
|
case $opt in
|
|
b)
|
|
BRANCH=$OPTARG
|
|
;;
|
|
g)
|
|
GITPROJ=$OPTARG
|
|
;;
|
|
c)
|
|
rm -rf $VENVDIR
|
|
;;
|
|
e)
|
|
VENVDIR=$OPTARG
|
|
;;
|
|
f)
|
|
FAST=1
|
|
;;
|
|
q)
|
|
QUIET=1
|
|
;;
|
|
v)
|
|
AUTOOPT="-v"
|
|
if [ $OPTARG = 2 ]; then
|
|
AUTOOPT="-vv"
|
|
fi
|
|
;;
|
|
\?)
|
|
usage
|
|
exit 1
|
|
;;
|
|
esac
|
|
done
|
|
shift $(($OPTIND - 1))
|
|
|
|
if [ $# -lt 1 ]; then
|
|
usage
|
|
exit 1
|
|
fi
|
|
|
|
ACTION=$1
|
|
shift
|
|
|
|
if [ $QUIET -eq 1 ]; then
|
|
exec 3>&1 >/dev/null
|
|
exec 4>&2 2>/dev/null
|
|
fi
|
|
|
|
case $ACTION in
|
|
update|docbook|rst|dump|setup) ;;
|
|
*)
|
|
usage
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
if [ ! -e autohelp.py ]; then
|
|
echo "Execute this script in the autogenerate_config_docs directory."
|
|
exit 1
|
|
fi
|
|
|
|
[ $# != 0 ] && PROJECTS="$*"
|
|
|
|
RELEASE=$(echo $BRANCH | sed 's,^stable.,,')
|
|
|
|
if [ "$FAST" -eq 0 ] ; then
|
|
get_project openstack-manuals
|
|
|
|
for project in $PROJECTS; do
|
|
setup_venv $project
|
|
setup_tools
|
|
if [ -e $MAPPINGS_DIR/$project.requirements ]; then
|
|
pip install -r $MAPPINGS_DIR/$project.requirements \
|
|
--allow-all-external
|
|
fi
|
|
get_project $project
|
|
|
|
(
|
|
pushd $SOURCESDIR/$project
|
|
module=$(echo $project | tr - _ )
|
|
find $module -name "*.pyc" -delete
|
|
GIT_CMD="git show-ref --verify --quiet refs/heads/$BRANCH"
|
|
if $GIT_CMD; then
|
|
git checkout $BRANCH
|
|
else
|
|
git checkout -b $BRANCH remotes/origin/$BRANCH
|
|
fi
|
|
pip install -rrequirements.txt
|
|
[ -e "test-requirements.txt" ] && \
|
|
pip install -rtest-requirements.txt
|
|
python setup.py install
|
|
popd
|
|
|
|
if [ -e $MAPPINGS_DIR/$project.extra_repos ]; then
|
|
while read extra; do
|
|
(
|
|
cd $SOURCESDIR/$extra
|
|
pip install -rrequirements.txt
|
|
[ -e "test-requirements.txt" ] && \
|
|
pip install -rtest-requirements.txt
|
|
python setup.py install
|
|
)
|
|
done < $MAPPINGS_DIR/$project.extra_repos
|
|
fi
|
|
)
|
|
done
|
|
fi
|
|
|
|
for project in $PROJECTS; do
|
|
echo "Working on $project..."
|
|
activate_venv $project
|
|
if [ "$ACTION" = "setup" ]; then
|
|
break
|
|
fi
|
|
|
|
if [ -e $MAPPINGS_DIR/$project.extra_repos ]; then
|
|
extra_flags=
|
|
while read extra; do
|
|
package=$(echo $extra | tr - _)
|
|
if [ $package = "networking_midonet" ]; then
|
|
package="midonet"
|
|
fi
|
|
if [ $package = "networking_hyperv" ]; then
|
|
package="hyperv"
|
|
fi
|
|
if [ $package = "networking_edge_vpn" ]; then
|
|
package="networking-edge-vpn"
|
|
fi
|
|
if [ $package = "networking_zvm" ]; then
|
|
package="neutron"
|
|
cp -r $SOURCESDIR/networking-zvm/neutron/plugins/zvm \
|
|
$SOURCESDIR/neutron/neutron/plugins
|
|
cp -r \
|
|
$SOURCESDIR/networking-zvm/neutron/plugins/ml2/drivers/zvm\
|
|
$SOURCESDIR/neutron/neutron/plugins/ml2/drivers
|
|
fi
|
|
extra_flags="$extra_flags -i $SOURCESDIR/$extra/$package"
|
|
done < $MAPPINGS_DIR/$project.extra_repos
|
|
fi
|
|
|
|
cd $MAPPINGS_DIR
|
|
|
|
case $ACTION in
|
|
update)
|
|
[ "$project" = "swift" ] && continue
|
|
$AUTOHELP update $project -i $SOURCESDIR/$project/$project \
|
|
$extra_flags $AUTOOPT
|
|
mv $project.flagmappings.new $project.flagmappings
|
|
;;
|
|
docbook)
|
|
if [ "$project" = "swift" ]; then
|
|
$EXTRACT_SWIFT docbook -m $MANUALSREPO -s $SOURCESDIR/swift
|
|
else
|
|
$AUTOHELP docbook $project -i $SOURCESDIR/$project/$project \
|
|
$extra_flags $AUTOOPT
|
|
fi
|
|
;;
|
|
rst)
|
|
if [ "$project" = "swift" ]; then
|
|
$EXTRACT_SWIFT rst -m $MANUALSREPO -s $SOURCESDIR/swift
|
|
else
|
|
$AUTOHELP rst $project -i $SOURCESDIR/$project/$project \
|
|
$extra_flags $AUTOOPT
|
|
fi
|
|
;;
|
|
dump)
|
|
if [ $QUIET -eq 1 ]; then
|
|
exec 1>&3
|
|
exec 2>&4
|
|
fi
|
|
if [ "$project" = "swift" ]; then
|
|
$EXTRACT_SWIFT dump -m $MANUALSREPO -s $SOURCESDIR/swift
|
|
else
|
|
$AUTOHELP dump $project -i $SOURCESDIR/$project/$project \
|
|
$extra_flags $AUTOOPT
|
|
fi
|
|
;;
|
|
esac
|
|
done
|