2 # SPDX-License-Identifier: EPL-1.0
3 ##############################################################################
4 # Copyright (c) 2018 The Linux Foundation and others.
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Eclipse Public License v1.0
8 # which accompanies this distribution, and is available at
9 # http://www.eclipse.org/legal/epl-v10.html
10 ##############################################################################
11 echo "---> jenkins-verify-images.sh"
12 # Verifies that openstack contains an image for each config file defined in the
13 # jenkins-config/clouds/openstack directory.
17 # shellcheck disable=SC1090
20 if [ -f "/tmp/.os_lf_venv" ]; then
21 os_lf_venv=$(cat "/tmp/.os_lf_venv")
24 if [ -d "${os_lf_venv}" ] && [ -f "${os_lf_venv}/bin/openstack" ]; then
25 echo "Re-use existing venv: ${os_lf_venv}"
26 PATH=$os_lf_venv/bin:$PATH
28 lf-activate-venv --python python3 python-openstackclient
34 echo "Verifying images on $1"
35 for file in "$1"/*; do
36 # Set the $IMAGE_NAME variable to the the file's IMAGE_NAME value
37 export "$(grep ^IMAGE_NAME= "$file")"
38 # The image should be listed as active
40 if ! openstack image list --property name="$IMAGE_NAME" | grep "active"; then
41 echo "ERROR: No matching image found for $IMAGE_NAME"
44 # Set the $HARDWARE_ID variable to the the file's HARDWARE_ID value
45 export "$(grep ^HARDWARE_ID= "$file")"
46 # The flavor should be listed. Spaces in grep string ensure complete match.
48 if ! openstack flavor list | grep " $HARDWARE_ID "; then
49 echo "ERROR: No matching flavor found for $HARDWARE_ID"
55 echo "Verifying that cloud has a master configuration file"
56 if [[ -d jenkins-config/clouds/openstack ]]; then
57 for cloud in jenkins-config/clouds/openstack/*; do
58 if [[ -f $cloud/cloud.cfg ]]; then
59 # Get the OS_CLOUD variable from cloud config
60 if ! os_cloud=$(grep -E "^OS_CLOUD=" "$cloud/cloud.cfg" | cut -d'=' -f2); then
63 OS_CLOUD=$os_cloud verify_images "$cloud"
65 echo "ERROR: No cloud.cfg for $cloud"