From: Anil Belur Date: Tue, 6 Sep 2022 21:42:45 +0000 (+1000) Subject: Fix: Update lf-activate-venv X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F98%2F102298%2F8;p=releng%2Fbuilder.git Fix: Update lf-activate-venv Add lf-activate-venv to install lftools, OS deps before using the CLI. This sets the required environment. The change requires the releng/global-jjb CR: 70597 and a updated release of global-jjb. Change-Id: Ic3efbdec3574bec17add3910785af1e503298965 Signed-off-by: Anil Belur --- diff --git a/jjb/integration/copy-common-functions.sh b/jjb/integration/copy-common-functions.sh index 1ff42d091..660dbacaf 100644 --- a/jjb/integration/copy-common-functions.sh +++ b/jjb/integration/copy-common-functions.sh @@ -7,7 +7,14 @@ # script is executing rather than being sourced. When executed the condition # is true and copies the script. In the false path this copy below is skipped # and the sourcing continues so that the appended common-function.sh ends up sourced. -if [ "${BASH_SOURCE[0]}" == "${0}" ]; then +if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then + # shellcheck disable=SC1090 + . ~/lf-env.sh + + lf-activate-venv --python python3 \ + python-heatclient \ + python-openstackclient + echo "Copying common-functions.sh to /tmp" cp "${0}" /tmp/common-functions.sh diff --git a/jjb/integration/integration-get-slave-addresses.sh b/jjb/integration/integration-get-slave-addresses.sh index 2546d31f6..98cd3db7b 100644 --- a/jjb/integration/integration-get-slave-addresses.sh +++ b/jjb/integration/integration-get-slave-addresses.sh @@ -1,4 +1,13 @@ #!/bin/bash -l + +# shellcheck disable=SC1090 +. ~/lf-env.sh + +lf-activate-venv --python python3 \ + python-heatclient \ + python-openstackclient \ + yq + # Get the Controller and Tools VM slave addresses set -x diff --git a/jjb/opendaylight-infra-copy-ssh-keys.sh b/jjb/opendaylight-infra-copy-ssh-keys.sh index d80d9d8c4..c8aa14596 100644 --- a/jjb/opendaylight-infra-copy-ssh-keys.sh +++ b/jjb/opendaylight-infra-copy-ssh-keys.sh @@ -44,21 +44,10 @@ function copy-ssh-keys-to-slave() { # shellcheck disable=SC1090 . ~/lf-env.sh - -# Check if openstack venv was previously created -if [ -f "/tmp/.os_lf_venv" ]; then - os_lf_venv=$(cat "/tmp/.os_lf_venv") -fi - -if [ -d "${os_lf_venv}" ] && [ -f "${os_lf_venv}/bin/openstack" ]; then - echo "Re-use existing venv: ${os_lf_venv}" - PATH=$os_lf_venv/bin:$PATH -else - lf-activate-venv --python python3 \ - python-heatclient \ - python-openstackclient \ - yq -fi +lf-activate-venv --python python3 \ + python-heatclient \ + python-openstackclient \ + yq # Print the Stack outputs parameters so that we can identify which IPs belong # to which VM types. diff --git a/jjb/opendaylight-infra-deploy-maven-site.sh b/jjb/opendaylight-infra-deploy-maven-site.sh index 756349901..bf674187c 100644 --- a/jjb/opendaylight-infra-deploy-maven-site.sh +++ b/jjb/opendaylight-infra-deploy-maven-site.sh @@ -15,17 +15,7 @@ set -eu -o pipefail # shellcheck disable=SC1090 . ~/lf-env.sh -# Check if openstack venv was previously created -if [ -f "/tmp/.os_lf_venv" ]; then - os_lf_venv=$(cat "/tmp/.os_lf_venv") -fi - -if [ -d "${os_lf_venv}" ] && [ -f "${os_lf_venv}/bin/openstack" ]; then - echo "Re-use existing venv: ${os_lf_venv}" - PATH=$os_lf_venv/bin:$PATH -else - lf-activate-venv --python python3 lftools -fi +lf-activate-venv --python python3 lftools MAVEN_GROUP_ID=$(xmlstarlet sel \ -N "x=http://maven.apache.org/POM/4.0.0" \ diff --git a/jjb/opendaylight-infra-stack.sh b/jjb/opendaylight-infra-stack.sh index 58ad38174..2a3e0cee5 100644 --- a/jjb/opendaylight-infra-stack.sh +++ b/jjb/opendaylight-infra-stack.sh @@ -19,22 +19,12 @@ fi # shellcheck disable=SC1090 . ~/lf-env.sh -# Check if openstack venv was previously created -if [ -f "/tmp/.os_lf_venv" ]; then - os_lf_venv=$(cat "/tmp/.os_lf_venv") -fi - -if [ -d "${os_lf_venv}" ] && [ -f "${os_lf_venv}/bin/openstack" ]; then - echo "Re-use existing venv: ${os_lf_venv}" - PATH=$os_lf_venv/bin:$PATH -else - lf-activate-venv --python python3 \ - decorator \ - python-heatclient \ - python-openstackclient \ - python-magnumclient \ - yq -fi +lf-activate-venv --python python3 \ + decorator \ + python-heatclient \ + python-openstackclient \ + python-magnumclient \ + yq JOB_SUM=$(echo "$JOB_NAME" | sum | awk '{{ print $1 }}') VM_NAME="$JOB_SUM-$BUILD_NUMBER" diff --git a/jjb/opendaylight-infra-update-image-list.sh b/jjb/opendaylight-infra-update-image-list.sh index c7ac71731..c72292785 100644 --- a/jjb/opendaylight-infra-update-image-list.sh +++ b/jjb/opendaylight-infra-update-image-list.sh @@ -14,17 +14,7 @@ set -e -o pipefail # shellcheck disable=SC1090 . ~/lf-env.sh -# Check if openstack venv was previously created -if [ -f "/tmp/.os_lf_venv" ]; then - os_lf_venv=$(cat "/tmp/.os_lf_venv") -fi - -if [ -d "${os_lf_venv}" ] && [ -f "${os_lf_venv}/bin/openstack" ]; then - echo "Re-use existing venv: ${os_lf_venv}" - PATH=$os_lf_venv/bin:$PATH -else - lf-activate-venv --python python3 python-openstackclient -fi +lf-activate-venv --python python3 python-openstackclient cat > "$WORKSPACE/docs/cloud-images.rst" << EOF Following are the list of published images available to Jenkins jobs. diff --git a/jjb/packaging/openstack-k8s-cluster-delete.sh b/jjb/packaging/openstack-k8s-cluster-delete.sh index a43a457e3..d638f47d1 100644 --- a/jjb/packaging/openstack-k8s-cluster-delete.sh +++ b/jjb/packaging/openstack-k8s-cluster-delete.sh @@ -12,9 +12,16 @@ echo "---> Delete K8S cluster" set -eux -o pipefail + # shellcheck disable=SC1090 . ~/lf-env.sh +lf-activate-venv --python python3 \ + kubernetes \ + python-heatclient \ + python-openstackclient \ + yq + os_cloud="${OS_CLOUD:-vex}" cluster_name="${CLUSTER_NAME}" diff --git a/jjb/packaging/openstack-k8s-config-export.sh b/jjb/packaging/openstack-k8s-config-export.sh index 5f834c7ab..4d7de8099 100644 --- a/jjb/packaging/openstack-k8s-config-export.sh +++ b/jjb/packaging/openstack-k8s-config-export.sh @@ -15,6 +15,12 @@ set -eux -o pipefail # shellcheck disable=SC1090 . ~/lf-env.sh +lf-activate-venv --python python3 \ + kubernetes \ + python-heatclient \ + python-openstackclient \ + yq + OS_TIMEOUT=5 # Wait time in minutes for OpenStack cluster nodes to come up. CLUSTER_NODE_RETRIES=15 # Number of times to retry waiting for a cluster nodes. CLUSTER_NODE_SUCCESSFUL=false diff --git a/jjb/packaging/openstack-k8s-create-with-template.sh b/jjb/packaging/openstack-k8s-create-with-template.sh index 4adcf8f91..50dd89a36 100644 --- a/jjb/packaging/openstack-k8s-create-with-template.sh +++ b/jjb/packaging/openstack-k8s-create-with-template.sh @@ -12,9 +12,14 @@ echo "---> Create K8S cluster with pre-existing template" set -eux -o pipefail + # shellcheck disable=SC1090 . ~/lf-env.sh -lf-activate-venv python-openstackclient python-magnumclient + +lf-activate-venv --python python3 \ + python-heatclient \ + python-openstackclient \ + yq OS_TIMEOUT=20 # Wait time in minutes for OpenStack cluster to come up. CLUSTER_RETRIES=3 # Number of times to retry creating a cluster.