Pass multiple pattern args in logs-deploy.sh
[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 set -eux -o pipefail
16
17 error=false
18
19 for file in jenkins-config/clouds/openstack/*/*; do
20   # Set the $IMAGE_NAME variable to the the file's IMAGE_NAME value
21   export "$(grep ^IMAGE_NAME= $file)"
22   # The image should be listed as active
23
24   if ! openstack image list --property name="$IMAGE_NAME" | grep "active"; then
25     echo "ERROR: No matching image found for $IMAGE_NAME"
26     error=true
27   fi
28   # Set the $HARDWARE_ID variable to the the file's HARDWARE_ID value
29   export "$(grep ^HARDWARE_ID= $file)"
30   # The flavor should be listed. Spaces in grep string ensure complete match.
31
32   if ! openstack flavor list | grep " $HARDWARE_ID "; then
33     echo "ERROR: No matching flavor found for $HARDWARE_ID"
34     error=true
35   fi
36 done
37
38 if $error; then
39   exit 1
40 fi