xci: Install the ARA callback plugin 13/54113/6
authorMarkos Chandras <mchandras@suse.de>
Mon, 19 Mar 2018 14:15:00 +0000 (14:15 +0000)
committerMarkos Chandras <mchandras@suse.de>
Wed, 21 Mar 2018 17:28:55 +0000 (17:28 +0000)
The ARA Ansible plugin can be used to visualize the entire XCI run so
lets install it by default and generate a report at the end of the
execution.

Change-Id: I66c3230b371001c110e81755c5f0dad4b1756606
Link: https://github.com/openstack/ara
Signed-off-by: Markos Chandras <mchandras@suse.de>
xci/files/install-lib.sh
xci/xci-deploy.sh

index 0ea6f18..ce52ff4 100644 (file)
 function install_ansible() {
     set -eu
 
+    # Use the upper-constraints file from the pinned requirements repository.
+    local requirements_sha=$(awk '/requirements_git_install_branch:/ {print $2}' ${XCI_PATH}/xci/installer/osa/files/openstack_services.yml)
+    local uc="https://raw.githubusercontent.com/openstack/requirements/${requirements_sha}/upper-constraints.txt"
+
     declare -A PKG_MAP
 
     # workaround: for latest bindep to work, it needs to use en_US local
@@ -163,7 +167,20 @@ function install_ansible() {
 
     PIP=$(which pip)
     echo "Using pip: $(${PIP} --version)"
-    ${PIP} -q install --user --upgrade virtualenv pip setuptools ansible==$XCI_ANSIBLE_PIP_VERSION
+    ${PIP} -q install --user --upgrade -c $uc ara virtualenv pip setuptools ansible==$XCI_ANSIBLE_PIP_VERSION
+
+    ara_location=$(${PYTHON} -c "import os,ara; print(os.path.dirname(ara.__file__))")
+    export ANSIBLE_CALLBACK_PLUGINS="/etc/ansible/roles/plugins/callback:${ara_location}/plugins/callbacks"
+}
+
+collect_xci_logs() {
+    echo "----------------------------------"
+    echo "Info: Collecting XCI logs"
+    echo "----------------------------------"
+
+    # Create the ARA log directory and store the sqlite source database
+    mkdir -p ${LOG_PATH}/ara/
+    rsync -q -a "${HOME}/.ara/ansible.sqlite" "${LOG_PATH}/ara/"
 }
 
 # vim: set ts=4 sw=4 expandtab:
index 19ae7c0..fa9f335 100755 (executable)
@@ -25,10 +25,15 @@ submit_bug_report() {
     echo "xci installer: $INSTALLER_TYPE"
     echo "xci scenario: $DEPLOY_SCENARIO"
     echo "Environment variables:"
-    env | grep --color=never '\(OPNFV\|XCI\|INSTALLER_TYPE\|OPENSTACK\|SCENARIO\)'
+    env | grep --color=never '\(OPNFV\|XCI\|INSTALLER_TYPE\|OPENSTACK\|SCENARIO\|ANSIBLE\)'
     echo "-------------------------------------------------------------------------"
 }
 
+exit_trap() {
+    submit_bug_report
+    collect_xci_logs
+}
+
 #-------------------------------------------------------------------------------
 # This script should not be run as root
 #-------------------------------------------------------------------------------
@@ -86,7 +91,7 @@ done
 unset user_local_dev_vars local_user_var
 
 # register our handler
-trap submit_bug_report ERR
+trap exit_trap ERR
 
 # We are using sudo so we need to make sure that env_reset is not present
 sudo sed -i "s/^Defaults.*env_reset/#&/" /etc/sudoers
@@ -151,10 +156,15 @@ echo "Info: Deploying '${INSTALLER_TYPE}' installer"
 echo "-----------------------------------------------------------------------"
 source ${XCI_PATH}/xci/installer/${INSTALLER_TYPE}/deploy.sh
 
+# Reset trap
+trap ERR
+
 # Deployment time
 xci_deploy_time=$SECONDS
 echo "-------------------------------------------------------------------------------------------------------------"
 echo "Info: xci_deploy.sh deployment took $(($xci_deploy_time / 60)) minutes and $(($xci_deploy_time % 60)) seconds"
 echo "-------------------------------------------------------------------------------------------------------------"
 
+collect_xci_logs
+
 # vim: set ts=4 sw=4 expandtab: