From c44fbcbbe3b6d88e9393503e92ac670f9e811148 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Evrard Date: Tue, 29 Jan 2019 16:39:51 +0100 Subject: [PATCH] Mark OSA version in the wrapper script By doing that, we compute (every bootstrap ansible) the version of OSA, which can then be used in playbooks using a lookup. This would be faster than doing the lookup in the variable, as this would be computed once, gaining around 0.4s per playbook. Change-Id: Idd3a842f94eb30dec2afa6da84615a8605ef9e78 --- scripts/bootstrap-ansible.sh | 5 +++++ scripts/openstack-ansible.sh | 1 + 2 files changed, 6 insertions(+) diff --git a/scripts/bootstrap-ansible.sh b/scripts/bootstrap-ansible.sh index fdc8d7e981..22930a661b 100755 --- a/scripts/bootstrap-ansible.sh +++ b/scripts/bootstrap-ansible.sh @@ -113,6 +113,9 @@ fi PYTHON_EXEC_PATH="${PYTHON_EXEC_PATH:-$(which python2 || which python)}" PYTHON_VERSION="$($PYTHON_EXEC_PATH -c 'import sys; print(".".join(map(str, sys.version_info[:3])))')" +# Get current code version (this runs at the root of OSA clone) +CURRENT_OSA_VERSION=$(cd ${OSA_CLONE_DIR}; ${PYTHON_EXEC_PATH} setup.py --version) + # Use https when Python with native SNI support is available UPPER_CONSTRAINTS_PROTO=$([ "$PYTHON_VERSION" == $(echo -e "$PYTHON_VERSION\n2.7.9" | sort -V | tail -1) ] && echo "https" || echo "http") @@ -177,6 +180,8 @@ sed -i "s|OSA_PLAYBOOK_PATH|${OSA_PLAYBOOK_PATH}|g" /usr/local/bin/openstack-ans # Create openstack ansible wrapper tool cp -v ${OSA_WRAPPER_BIN} /usr/local/bin/openstack-ansible sed -i "s|OSA_CLONE_DIR|${OSA_CLONE_DIR}|g" /usr/local/bin/openstack-ansible +# Mark the current OSA version in the wrapper, so we don't need to compute it everytime. +sed -i "s|CURRENT_OSA_VERSION|${CURRENT_OSA_VERSION}|g" /usr/local/bin/openstack-ansible # Ensure wrapper tool is executable chmod +x /usr/local/bin/openstack-ansible diff --git a/scripts/openstack-ansible.sh b/scripts/openstack-ansible.sh index dd3d823a71..cbe677bd12 100644 --- a/scripts/openstack-ansible.sh +++ b/scripts/openstack-ansible.sh @@ -18,6 +18,7 @@ # OpenStack wrapper tool to ease the use of ansible with multiple variable files. export PATH="/opt/ansible-runtime/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:${PATH}" +export OSA_VERSION="CURRENT_OSA_VERSION" function info { if [ "${ANSIBLE_NOCOLOR:-0}" -eq "1" ]; then