aed8d12f11c02b1b7bbaec1a7373d4b6282f2df5
[releng/global-jjb.git] / shell / jenkins-verify-images.sh
1 #!/bin/bash -l
2 # SPDX-License-Identifier: EPL-1.0
3 ##############################################################################
4 # Copyright (c) 2018 The Linux Foundation and others.
5 #
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.
14
15 error=false
16
17 for file in jenkins-config/clouds/openstack/*/*; do
18   # Set the $IMAGE_NAME variable to the the file's IMAGE_NAME value
19   export "$(grep IMAGE_NAME $file)"
20   # The image should be listed as active
21   openstack image list --property name="$IMAGE_NAME" | grep "active"
22   if [ $? -ne 0 ]; then
23     echo "ERROR: No matching image found for $IMAGE_NAME"
24     error=true
25   fi
26 done
27
28 if [ "$error" = true ]; then
29   exit 1
30 fi