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 # shellcheck source=/tmp/v/openstack/bin/activate disable=SC1091
21 source "/tmp/v/openstack/bin/activate"
24 readarray -t images <<< "$(grep -r _system_image: --include \*.yaml \
25 | awk -F": " -e '{print $3}' | sed "s:'::;s:'$::;/^$/d" | sort | uniq)"
27 for image in "${images[@]}"; do
28 os_image_protected=$(openstack --os-cloud "$OS_CLOUD" image show "$image" -f value -c protected)
29 echo "Protected setting for $image: $os_image_protected"
30 if [[ $os_image_protected != True ]]; then
31 echo "Image: $image NOT set as protected, changing the protected value."
32 openstack --os-cloud "$OS_CLOUD" image set --protected "$image"