2 # SPDX-License-Identifier: EPL-1.0
3 ##############################################################################
4 # Copyright (c) 2017 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 # Checks the image "protected" value and set "True" marker
13 # The script is involked by 'builder-verify-image-protection', searches
14 # the jjb source code for the images presently used and verifies protection
15 # setting. If the image protect setting is not "True", sets the
16 # image protect setting to "True" to prevent the image from getting purged
17 # by the cleanup old images job.
18 echo "---> Check image protection"
20 declare -a yaml_images
21 readarray -t yaml_images <<< "$(grep -r _system_image: --include \*.yaml \
22 | awk -F": " -e '{print $3}' | sed "s:'::;s:'$::;/^$/d" | sort -u)"
24 readarray -t cfg_images <<< "$(grep -r IMAGE_NAME --include \*.cfg \
25 | awk -F'=' -e '{print $2}' | sort -u)"
26 combined=("${yaml_images[@]}" "${cfg_images[@]}")
28 readarray -t images <<< "$(printf '%s\n' "${combined[@]}" | sort -u)"
30 for image in "${images[@]}"; do
31 os_image_protected=$(openstack --os-cloud "$OS_CLOUD" image show "$image" -f value -c protected)
32 echo "Protected setting for $image: $os_image_protected"
33 if [[ $os_image_protected != True ]]; then
34 echo "Image: $image NOT set as protected, changing the protected value."
35 openstack --os-cloud "$OS_CLOUD" image set --protected "$image"