tobiko/tools/ci/os
Federico Ressi 1c1234ec1b Add tobiko-fixture CLI wrapper to CI tools
Change-Id: Ic56585cd05271488e8fba61871e792ea6ebd3914
2019-06-25 14:32:31 +02:00

52 lines
754 B
Bash
Executable File

#!/bin/bash
set -eu
source $(dirname "$0")/activate
OS_VIRTUAL_ENV=$(realpath "${OS_VIRTUAL_ENV:-.tox/scenario}")
function os {
os_setup
openstack "$@"
}
function os_setup {
if ! os_activate; then
# Cleanup and create virtualenv directory
tox -r -e venv --notest
os_activate
fi
}
function os_activate {
local venv_script=${OS_VIRTUAL_ENV}/bin/activate
if ! [ -r "${venv_script}" ]; then
return 1
fi
if ! os_is_active; then
# Activate only once
set +eu
source "${venv_script}"
set -eu
os_is_active
fi
}
function os_is_active {
[ "$(python_prefix)" == "${OS_VIRTUAL_ENV}" ]
}
if [ $(basename "$0") == os ]; then
os "$@"
fi