Move ara to scripts-library

Deployment jobs may wish to install the ARA callback using the same
methods we use in the gate without using the test-oriented script
gate-check-commit.sh. We can solve this by moving the ARA setup to
a scripts-library function, and then call the function inside
gate-check-commit. This will allow downstream users to source
scripts-library and call the setup_ara function to install ARA
as well.

Change-Id: I789fb68be3f372757a4267e1cd7f8cd3b5cf8101
This commit is contained in:
Logan V 2018-09-13 15:19:05 -06:00
parent 7af917268d
commit b35949b303
3 changed files with 26 additions and 20 deletions

View File

@ -129,7 +129,6 @@ export UPPER_CONSTRAINTS_FILE=${UPPER_CONSTRAINTS_FILE:-"$UPPER_CONSTRAINTS_PROT
virtualenv --python=${PYTHON_EXEC_PATH} --clear /opt/ansible-runtime virtualenv --python=${PYTHON_EXEC_PATH} --clear /opt/ansible-runtime
# The vars used to prepare the Ansible runtime venv # The vars used to prepare the Ansible runtime venv
PIP_COMMAND="/opt/ansible-runtime/bin/pip"
PIP_OPTS+=" --constraint global-requirement-pins.txt" PIP_OPTS+=" --constraint global-requirement-pins.txt"
PIP_OPTS+=" --constraint ${UPPER_CONSTRAINTS_FILE}" PIP_OPTS+=" --constraint ${UPPER_CONSTRAINTS_FILE}"

View File

@ -101,26 +101,9 @@ fi
# Bootstrap Ansible # Bootstrap Ansible
source "${OSA_CLONE_DIR}/scripts/bootstrap-ansible.sh" source "${OSA_CLONE_DIR}/scripts/bootstrap-ansible.sh"
# PIP_COMMAND is now set within the ansible venv and PIP_OPTS is now set with constraints/proxy.
# Install ARA and add it to the callback path provided by bootstrap-ansible.sh/openstack-ansible.rc # Install and export the ARA callback plugin
# This is added *here* instead of bootstrap-ansible so it's used for CI purposes only. setup_ara
ARA_SRC_HOME="${HOME}/src/git.openstack.org/openstack/ara"
if [[ -d "${ARA_SRC_HOME}" ]]; then
# This installs from a git checkout
# PIP_COMMAND and PIP_OPTS are exported by the bootstrap-ansible script.
# PIP_OPTS contains the whole set of constraints that need to be applied.
${PIP_COMMAND} install --isolated ${PIP_OPTS} ${ARA_SRC_HOME} "${ANSIBLE_PACKAGE:-ansible}"
else
# This installs from pypi
# PIP_COMMAND and PIP_OPTS are exported by the bootstrap-ansible script.
# PIP_OPTS contains the whole set of constraints that need to be applied.
${PIP_COMMAND} install --isolated ${PIP_OPTS} ara "${ANSIBLE_PACKAGE:-ansible}"
fi
# Dynamically retrieve the location of the ARA callback so we are able to find
# it on both py2 and py3
ara_location=$(/opt/ansible-runtime/bin/python -c "import os,ara; print(os.path.dirname(ara.__file__))")
export ANSIBLE_CALLBACK_PLUGINS="/etc/ansible/roles/plugins/callback:${ara_location}/plugins/callbacks"
# Log some data about the instance and the rest of the system # Log some data about the instance and the rest of the system
log_instance_info log_instance_info

View File

@ -22,6 +22,9 @@ ANSIBLE_PARAMETERS=${ANSIBLE_PARAMETERS:-""}
STARTTIME="${STARTTIME:-$(date +%s)}" STARTTIME="${STARTTIME:-$(date +%s)}"
COMMAND_LOGS=${COMMAND_LOGS:-"/openstack/log/ansible_cmd_logs"} COMMAND_LOGS=${COMMAND_LOGS:-"/openstack/log/ansible_cmd_logs"}
# The vars used to prepare the Ansible runtime venv
PIP_COMMAND="/opt/ansible-runtime/bin/pip"
ZUUL_PROJECT="${ZUUL_PROJECT:-}" ZUUL_PROJECT="${ZUUL_PROJECT:-}"
GATE_EXIT_LOG_COPY="${GATE_EXIT_LOG_COPY:-false}" GATE_EXIT_LOG_COPY="${GATE_EXIT_LOG_COPY:-false}"
GATE_EXIT_LOG_GZIP="${GATE_EXIT_LOG_GZIP:-true}" GATE_EXIT_LOG_GZIP="${GATE_EXIT_LOG_GZIP:-true}"
@ -217,6 +220,27 @@ function gate_job_exit_tasks {
fi fi
} }
function setup_ara {
# Install ARA and add it to the callback path provided by bootstrap-ansible.sh/openstack-ansible.rc
# This is added *here* instead of bootstrap-ansible so it's used for CI purposes only.
ARA_SRC_HOME="${HOME}/src/git.openstack.org/openstack/ara"
if [[ -d "${ARA_SRC_HOME}" ]]; then
# This installs from a git checkout
# PIP_COMMAND and PIP_OPTS are exported by the bootstrap-ansible script.
# PIP_OPTS contains the whole set of constraints that need to be applied.
${PIP_COMMAND} install --isolated ${PIP_OPTS} ${ARA_SRC_HOME} "${ANSIBLE_PACKAGE:-ansible}"
else
# This installs from pypi
# PIP_COMMAND and PIP_OPTS are exported by the bootstrap-ansible script.
# PIP_OPTS contains the whole set of constraints that need to be applied.
${PIP_COMMAND} install --isolated ${PIP_OPTS} ara "${ANSIBLE_PACKAGE:-ansible}"
fi
# Dynamically retrieve the location of the ARA callback so we are able to find
# it on both py2 and py3
ara_location=$(/opt/ansible-runtime/bin/python -c "import os,ara; print(os.path.dirname(ara.__file__))")
export ANSIBLE_CALLBACK_PLUGINS="/etc/ansible/roles/plugins/callback:${ara_location}/plugins/callbacks"
}
function run_dstat { function run_dstat {
if [ "$GATE_EXIT_RUN_DSTAT" == true ]; then if [ "$GATE_EXIT_RUN_DSTAT" == true ]; then
case ${DISTRO_ID} in case ${DISTRO_ID} in