Merge "Migrate snbi to global-jjb Maven jobs"
[releng/builder.git] / jjb / opendaylight-infra-check-image-visibility.sh
1 #!/bin/bash -x
2 # SPDX-License-Identifier: EPL-1.0
3 ##############################################################################
4 # Copyright (c) 2015, 2016 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
12 # Checks the image visibility and set "public" marker
13 #
14 # The script is involked by 'builder-verify-image-visibility', searches
15 # the jjb source code for the images presently uesd and verifies visibility
16 # on RS private cloud. If the image visibility is not "public", set the
17 # image visibility to "public" to prevent the image from getting purged
18 # by the cleanup old images job.
19
20 virtualenv "/tmp/v/openstack"
21 # shellcheck source=/tmp/v/openstack/bin/activate disable=SC1091
22 source "/tmp/v/openstack/bin/activate"
23 pip install --upgrade pip
24 pip install --upgrade python-openstackclient
25 pip install --upgrade pipdeptree
26 pipdeptree
27
28 declare -a images
29 readarray -t images <<< "$(grep -r _system_image: --include \*.yaml | awk -F": " -e '{print $3}' | sed "s:'::;s:'$::;/^$/d")"
30
31 for image in "${images[@]}"; do
32     os_image_visibility=$(openstack --os-cloud $OS_CLOUD image show "$image" -f json -c "visibility" | jq -r '.[]')
33     echo "Visibility for $image: $os_image_visibility"
34     if [[ $os_image_visibility != public ]]; then
35         echo "Image: $image NOT set as public, changing the visibility"
36         openstack --os-cloud $OS_CLOUD image set --public "$image"
37     fi
38 done