blob: 81231be9f39b8148b43e436a2574a9da1bf0a80c [file] [log] [blame]
Sean Dague0936e672014-04-03 14:48:48 -04001#!/bin/bash
2
Monty Taylord8bb2202017-09-03 12:13:59 -05003# Print out a list of image and other files to download for caching.
4# This is mostly used by the OpenStack infrasturucture during daily
5# image builds to save the large images to /opt/cache/files (see [1])
6#
7# The two lists of URL's downloaded are the IMAGE_URLS and
8# EXTRA_CACHE_URLS, which are setup in stackrc
9#
10# [1] project-config:nodepool/elements/cache-devstack/extra-data.d/55-cache-devstack-repos
11
Dean Troyerdc97cb72015-03-28 08:20:50 -050012# Keep track of the DevStack directory
Sean Dague0936e672014-04-03 14:48:48 -040013TOP_DIR=$(cd $(dirname "$0")/.. && pwd)
14
Jens Rosenboomff70dad2015-07-01 15:22:53 +020015# The following "source" implicitly calls get_default_host_ip() in
16# stackrc and will die if the selected default IP happens to lie
17# in the default ranges for FIXED_RANGE or FLOATING_RANGE. Since we
18# do not really need HOST_IP to be properly set in the remainder of
19# this script, just set it to some dummy value and make stackrc happy.
20HOST_IP=SKIP
Sean Dague0936e672014-04-03 14:48:48 -040021source $TOP_DIR/functions
22
23# Possible virt drivers, if we have more, add them here. Always keep
24# dummy in the end position to trigger the fall through case.
Stephen Finucane970891a2021-03-02 16:45:39 +000025DRIVERS="openvz ironic libvirt vsphere dummy"
Sean Dague0936e672014-04-03 14:48:48 -040026
27# Extra variables to trigger getting additional images.
Sean Daguefafb62b2014-06-30 16:49:30 -040028export ENABLED_SERVICES="h-api,tr-api"
Sean Dague0936e672014-04-03 14:48:48 -040029HEAT_FETCHED_TEST_IMAGE="Fedora-i386-20-20131211.1-sda"
Sean Dagueb6238602014-04-17 21:56:53 -040030PRECACHE_IMAGES=True
Sean Dague0936e672014-04-03 14:48:48 -040031
32# Loop over all the virt drivers and collect all the possible images
33ALL_IMAGES=""
34for driver in $DRIVERS; do
Joe Gordon33ba7382015-04-06 10:25:54 -070035 VIRT_DRIVER=$driver
36 URLS=$(source $TOP_DIR/stackrc && echo $IMAGE_URLS)
37 if [[ ! -z "$ALL_IMAGES" ]]; then
38 ALL_IMAGES+=,
39 fi
40 ALL_IMAGES+=$URLS
Sean Dague0936e672014-04-03 14:48:48 -040041done
42
Sean Dague0936e672014-04-03 14:48:48 -040043# Sanity check - ensure we have a minimum number of images
44num=$(echo $ALL_IMAGES | tr ',' '\n' | sort | uniq | wc -l)
Paul Belanger331b3de2017-07-14 13:11:19 -040045if [[ "$num" -lt 4 ]]; then
Sean Dague0936e672014-04-03 14:48:48 -040046 echo "ERROR: We only found $num images in $ALL_IMAGES, which can't be right."
47 exit 1
48fi
Monty Taylord8bb2202017-09-03 12:13:59 -050049
50# This is extra non-image files that we want pre-cached. This is kept
51# in a separate list because devstack loops over the IMAGE_LIST to
52# upload files glance and these aren't images. (This was a bit of an
53# after-thought which is why the naming around this is very
54# image-centric)
55URLS=$(source $TOP_DIR/stackrc && echo $EXTRA_CACHE_URLS)
56ALL_IMAGES+=$URLS
57
58# Make a nice combined list
59echo $ALL_IMAGES | tr ',' '\n' | sort | uniq