Merge "Virtual environment groundwork"
This commit is contained in:
commit
86b3a920e9
2
clean.sh
2
clean.sh
@ -120,7 +120,7 @@ if [[ -n "$SCREEN_LOGDIR" ]] && [[ -d "$SCREEN_LOGDIR" ]]; then
|
||||
fi
|
||||
|
||||
# Clean up venvs
|
||||
DIRS_TO_CLEAN="$WHEELHOUSE"
|
||||
DIRS_TO_CLEAN="$WHEELHOUSE ${PROJECT_VENV[@]}"
|
||||
rm -rf $DIRS_TO_CLEAN
|
||||
|
||||
# Clean up files
|
||||
|
@ -15,6 +15,13 @@ INC_PY_TRACE=$(set +o | grep xtrace)
|
||||
set +o xtrace
|
||||
|
||||
|
||||
# Global Config Variables
|
||||
|
||||
# PROJECT_VENV contains the name of the virtual enviromnet for each
|
||||
# project. A null value installs to the system Python directories.
|
||||
declare -A PROJECT_VENV
|
||||
|
||||
|
||||
# Python Functions
|
||||
# ================
|
||||
|
||||
@ -105,7 +112,6 @@ function pip_install {
|
||||
-r $test_req
|
||||
fi
|
||||
fi
|
||||
$xtrace
|
||||
}
|
||||
|
||||
# get version of a package from global requirements file
|
||||
|
29
lib/stack
Normal file
29
lib/stack
Normal file
@ -0,0 +1,29 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# lib/stack
|
||||
#
|
||||
# These functions are code snippets pulled out of stack.sh for easier
|
||||
# re-use by Grenade. They can assume the same environment is available
|
||||
# as in the lower part of stack.sh, namely a valid stackrc has been sourced
|
||||
# as well as all of the lib/* files for the services have been sourced.
|
||||
#
|
||||
# For clarity, all functions declared here that came from ``stack.sh``
|
||||
# shall be named with the prefix ``stack_``.
|
||||
|
||||
|
||||
# Generic service install handles venv creation if confgured for service
|
||||
# stack_install_service service
|
||||
function stack_install_service {
|
||||
local service=$1
|
||||
if type install_${service} >/dev/null 2>&1; then
|
||||
if [[ -n ${PROJECT_VENV[$service]:-} ]]; then
|
||||
rm -rf ${PROJECT_VENV[$service]}
|
||||
source tools/build_venv.sh ${PROJECT_VENV[$service]}
|
||||
export PIP_VIRTUAL_ENV=${PROJECT_VENV[$service]:-}
|
||||
fi
|
||||
install_${service}
|
||||
if [[ -n ${PROJECT_VENV[$service]:-} ]]; then
|
||||
unset PIP_VIRTUAL_ENV
|
||||
fi
|
||||
fi
|
||||
}
|
21
stack.sh
21
stack.sh
@ -94,6 +94,9 @@ source $TOP_DIR/functions
|
||||
# Import config functions
|
||||
source $TOP_DIR/lib/config
|
||||
|
||||
# Import 'public' stack.sh functions
|
||||
source $TOP_DIR/lib/stack
|
||||
|
||||
# Determine what system we are running on. This provides ``os_VENDOR``,
|
||||
# ``os_RELEASE``, ``os_UPDATE``, ``os_PACKAGE``, ``os_CODENAME``
|
||||
# and ``DISTRO``
|
||||
@ -742,13 +745,13 @@ fi
|
||||
|
||||
if is_service_enabled keystone; then
|
||||
if [ "$KEYSTONE_AUTH_HOST" == "$SERVICE_HOST" ]; then
|
||||
install_keystone
|
||||
stack_install_service keystone
|
||||
configure_keystone
|
||||
fi
|
||||
fi
|
||||
|
||||
if is_service_enabled s-proxy; then
|
||||
install_swift
|
||||
stack_install_service swift
|
||||
configure_swift
|
||||
|
||||
# swift3 middleware to provide S3 emulation to Swift
|
||||
@ -762,23 +765,23 @@ fi
|
||||
|
||||
if is_service_enabled g-api n-api; then
|
||||
# image catalog service
|
||||
install_glance
|
||||
stack_install_service glance
|
||||
configure_glance
|
||||
fi
|
||||
|
||||
if is_service_enabled cinder; then
|
||||
install_cinder
|
||||
stack_install_service cinder
|
||||
configure_cinder
|
||||
fi
|
||||
|
||||
if is_service_enabled neutron; then
|
||||
install_neutron
|
||||
stack_install_service neutron
|
||||
install_neutron_third_party
|
||||
fi
|
||||
|
||||
if is_service_enabled nova; then
|
||||
# compute service
|
||||
install_nova
|
||||
stack_install_service nova
|
||||
cleanup_nova
|
||||
configure_nova
|
||||
fi
|
||||
@ -787,19 +790,19 @@ if is_service_enabled horizon; then
|
||||
# django openstack_auth
|
||||
install_django_openstack_auth
|
||||
# dashboard
|
||||
install_horizon
|
||||
stack_install_service horizon
|
||||
configure_horizon
|
||||
fi
|
||||
|
||||
if is_service_enabled ceilometer; then
|
||||
install_ceilometerclient
|
||||
install_ceilometer
|
||||
stack_install_service ceilometer
|
||||
echo_summary "Configuring Ceilometer"
|
||||
configure_ceilometer
|
||||
fi
|
||||
|
||||
if is_service_enabled heat; then
|
||||
install_heat
|
||||
stack_install_service heat
|
||||
install_heat_other
|
||||
cleanup_heat
|
||||
configure_heat
|
||||
|
59
tools/build_venv.sh
Executable file
59
tools/build_venv.sh
Executable file
@ -0,0 +1,59 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# **tools/build_venv.sh** - Build a Python Virtual Envirnment
|
||||
#
|
||||
# build_venv.sh venv-path [package [...]]
|
||||
#
|
||||
# Assumes:
|
||||
# - a useful pip is installed
|
||||
# - virtualenv will be installed by pip
|
||||
# - installs basic common prereq packages that require compilation
|
||||
# to allow quick copying of resulting venv as a baseline
|
||||
|
||||
|
||||
VENV_DEST=${1:-.venv}
|
||||
shift
|
||||
|
||||
MORE_PACKAGES="$@"
|
||||
|
||||
# If TOP_DIR is set we're being sourced rather than running stand-alone
|
||||
# or in a sub-shell
|
||||
if [[ -z "$TOP_DIR" ]]; then
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
|
||||
# Keep track of the devstack directory
|
||||
TOP_DIR=$(cd $(dirname "$0")/.. && pwd)
|
||||
FILES=$TOP_DIR/files
|
||||
|
||||
# Import common functions
|
||||
source $TOP_DIR/functions
|
||||
|
||||
GetDistro
|
||||
|
||||
source $TOP_DIR/stackrc
|
||||
|
||||
trap err_trap ERR
|
||||
|
||||
fi
|
||||
|
||||
# Exit on any errors so that errors don't compound
|
||||
function err_trap {
|
||||
local r=$?
|
||||
set +o xtrace
|
||||
|
||||
rm -rf $TMP_VENV_PATH
|
||||
|
||||
exit $r
|
||||
}
|
||||
|
||||
# Build new venv
|
||||
virtualenv $VENV_DEST
|
||||
|
||||
# Install modern pip
|
||||
$VENV_DEST/bin/pip install -U pip
|
||||
|
||||
for pkg in ${MORE_PACKAGES}; do
|
||||
pip_install_venv $VENV_DEST $pkg
|
||||
done
|
Loading…
Reference in New Issue
Block a user