blob: bada26f1c2011ebc6d1288dd9b6c18b383b84997 [file] [log] [blame]
Dean Troyer8c2ce6e2015-02-18 14:47:54 -06001#!/bin/bash
2#
3# lib/stack
4#
Dean Troyerdc97cb72015-03-28 08:20:50 -05005# These functions are code snippets pulled out of ``stack.sh`` for easier
Dean Troyer8c2ce6e2015-02-18 14:47:54 -06006# re-use by Grenade. They can assume the same environment is available
Dean Troyerdc97cb72015-03-28 08:20:50 -05007# as in the lower part of ``stack.sh``, namely a valid stackrc has been sourced
8# as well as all of the ``lib/*`` files for the services have been sourced.
Dean Troyer8c2ce6e2015-02-18 14:47:54 -06009#
10# For clarity, all functions declared here that came from ``stack.sh``
11# shall be named with the prefix ``stack_``.
12
13
Dean Troyerdc97cb72015-03-28 08:20:50 -050014# Functions
15# ---------
16
Atsushi SAKAIfe7b56c2015-11-13 17:06:16 +090017# Generic service install handles venv creation if configured for service
Dean Troyer8c2ce6e2015-02-18 14:47:54 -060018# stack_install_service service
19function stack_install_service {
20 local service=$1
21 if type install_${service} >/dev/null 2>&1; then
Doug Hellmannddc38392015-05-07 21:06:24 +000022 # FIXME(dhellmann): Needs to be python3-aware at some point.
Dean Troyer5686dbc2015-03-09 14:27:51 -050023 if [[ ${USE_VENV} = True && -n ${PROJECT_VENV[$service]:-} ]]; then
Dean Troyer8c2ce6e2015-02-18 14:47:54 -060024 rm -rf ${PROJECT_VENV[$service]}
Dean Troyer5686dbc2015-03-09 14:27:51 -050025 source $TOP_DIR/tools/build_venv.sh ${PROJECT_VENV[$service]} ${ADDITIONAL_VENV_PACKAGES//,/ }
Dean Troyer8c2ce6e2015-02-18 14:47:54 -060026 export PIP_VIRTUAL_ENV=${PROJECT_VENV[$service]:-}
Dean Troyer5686dbc2015-03-09 14:27:51 -050027
28 # Install other OpenStack prereqs that might come from source repos
29 install_oslo
30 install_keystonemiddleware
Dean Troyer8c2ce6e2015-02-18 14:47:54 -060031 fi
32 install_${service}
Dean Troyer5686dbc2015-03-09 14:27:51 -050033 if [[ ${USE_VENV} = True && -n ${PROJECT_VENV[$service]:-} ]]; then
Dean Troyer8c2ce6e2015-02-18 14:47:54 -060034 unset PIP_VIRTUAL_ENV
35 fi
Mathieu Mitchellfa55cb52017-01-24 11:32:24 -050036 else
37 echo "No function declared with name 'install_${service}'."
38 exit 1
Dean Troyer8c2ce6e2015-02-18 14:47:54 -060039 fi
40}