X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=blobdiff_plain;f=shell%2Fjenkins-verify-images.sh;h=5db7fec23646a234797f856c6520c7231f65de66;hb=532e97b5b965cab5ace406d8ecc845afc98920ac;hp=d005c52f0873b1c16ed408af3b1daaacf3944b97;hpb=5fe90576c6f500ff92fbe7b76e42aad7d5d35fcd;p=releng%2Fglobal-jjb.git diff --git a/shell/jenkins-verify-images.sh b/shell/jenkins-verify-images.sh index d005c52f..5db7fec2 100755 --- a/shell/jenkins-verify-images.sh +++ b/shell/jenkins-verify-images.sh @@ -14,45 +14,60 @@ echo "---> jenkins-verify-images.sh" set -eux -o pipefail +# shellcheck disable=SC1090 +source ~/lf-env.sh + +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 error=false verify_images() { - echo "Verifying images on $1" - for file in "$1"/*; do - # Set the $IMAGE_NAME variable to the the file's IMAGE_NAME value - export "$(grep ^IMAGE_NAME= "$file")" - # The image should be listed as active - - if ! openstack image list --property name="$IMAGE_NAME" | grep "active"; then - echo "ERROR: No matching image found for $IMAGE_NAME" - error=true - fi - # Set the $HARDWARE_ID variable to the the file's HARDWARE_ID value - export "$(grep ^HARDWARE_ID= "$file")" - # The flavor should be listed. Spaces in grep string ensure complete match. - - if ! openstack flavor list | grep " $HARDWARE_ID "; then - echo "ERROR: No matching flavor found for $HARDWARE_ID" - error=true - fi - done + echo "Verifying images on $1" + for file in "$1"/*; do + # Set the $IMAGE_NAME variable to the the file's IMAGE_NAME value + export "$(grep ^IMAGE_NAME= "$file")" + # The image should be listed as active + + if ! openstack image list --property name="$IMAGE_NAME" | grep "active"; then + echo "ERROR: No matching image found for $IMAGE_NAME" + error=true + fi + # Set the $HARDWARE_ID variable to the the file's HARDWARE_ID value + export "$(grep ^HARDWARE_ID= "$file")" + # The flavor should be listed. Spaces in grep string ensure complete match. + + if ! openstack flavor list | grep " $HARDWARE_ID "; then + echo "ERROR: No matching flavor found for $HARDWARE_ID" + error=true + fi + done } echo "Verifying that cloud has a master configuration file" -for cloud in jenkins-config/clouds/openstack/*; do - if [[ -f $cloud/cloud.cfg ]]; then - # Get the OS_CLOUD variable from cloud config - if ! os_cloud=$(grep -E "^OS_CLOUD=" "$cloud/cloud.cfg" | cut -d'=' -f2); then - os_cloud="vex" - fi - OS_CLOUD=$os_cloud verify_images "$cloud" - else - echo "ERROR: No cloud.cfg for $cloud" - error=true - fi -done +if [[ -d jenkins-config/clouds/openstack ]]; then + for cloud in jenkins-config/clouds/openstack/*; do + if [[ -f $cloud/cloud.cfg ]]; then + # Get the OS_CLOUD variable from cloud config + if ! os_cloud=$(grep -E "^OS_CLOUD=" "$cloud/cloud.cfg" | cut -d'=' -f2); then + os_cloud="vex" + fi + OS_CLOUD=$os_cloud verify_images "$cloud" + else + echo "ERROR: No cloud.cfg for $cloud" + error=true + fi + done +fi if $error; then - exit 1 + exit 1 fi