Sean Dague | 0936e67 | 2014-04-03 14:48:48 -0400 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
Monty Taylor | d8bb220 | 2017-09-03 12:13:59 -0500 | [diff] [blame] | 3 | # 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 Troyer | dc97cb7 | 2015-03-28 08:20:50 -0500 | [diff] [blame] | 12 | # Keep track of the DevStack directory |
Sean Dague | 0936e67 | 2014-04-03 14:48:48 -0400 | [diff] [blame] | 13 | TOP_DIR=$(cd $(dirname "$0")/.. && pwd) |
| 14 | |
Jens Rosenboom | ff70dad | 2015-07-01 15:22:53 +0200 | [diff] [blame] | 15 | # 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. |
| 20 | HOST_IP=SKIP |
Sean Dague | 0936e67 | 2014-04-03 14:48:48 -0400 | [diff] [blame] | 21 | source $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 Finucane | 970891a | 2021-03-02 16:45:39 +0000 | [diff] [blame] | 25 | DRIVERS="openvz ironic libvirt vsphere dummy" |
Sean Dague | 0936e67 | 2014-04-03 14:48:48 -0400 | [diff] [blame] | 26 | |
| 27 | # Extra variables to trigger getting additional images. |
Sean Dague | fafb62b | 2014-06-30 16:49:30 -0400 | [diff] [blame] | 28 | export ENABLED_SERVICES="h-api,tr-api" |
Sean Dague | 0936e67 | 2014-04-03 14:48:48 -0400 | [diff] [blame] | 29 | HEAT_FETCHED_TEST_IMAGE="Fedora-i386-20-20131211.1-sda" |
Sean Dague | b623860 | 2014-04-17 21:56:53 -0400 | [diff] [blame] | 30 | PRECACHE_IMAGES=True |
Sean Dague | 0936e67 | 2014-04-03 14:48:48 -0400 | [diff] [blame] | 31 | |
| 32 | # Loop over all the virt drivers and collect all the possible images |
| 33 | ALL_IMAGES="" |
| 34 | for driver in $DRIVERS; do |
Joe Gordon | 33ba738 | 2015-04-06 10:25:54 -0700 | [diff] [blame] | 35 | 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 Dague | 0936e67 | 2014-04-03 14:48:48 -0400 | [diff] [blame] | 41 | done |
| 42 | |
Sean Dague | 0936e67 | 2014-04-03 14:48:48 -0400 | [diff] [blame] | 43 | # Sanity check - ensure we have a minimum number of images |
| 44 | num=$(echo $ALL_IMAGES | tr ',' '\n' | sort | uniq | wc -l) |
Paul Belanger | 331b3de | 2017-07-14 13:11:19 -0400 | [diff] [blame] | 45 | if [[ "$num" -lt 4 ]]; then |
Sean Dague | 0936e67 | 2014-04-03 14:48:48 -0400 | [diff] [blame] | 46 | echo "ERROR: We only found $num images in $ALL_IMAGES, which can't be right." |
| 47 | exit 1 |
| 48 | fi |
Monty Taylor | d8bb220 | 2017-09-03 12:13:59 -0500 | [diff] [blame] | 49 | |
| 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) |
| 55 | URLS=$(source $TOP_DIR/stackrc && echo $EXTRA_CACHE_URLS) |
| 56 | ALL_IMAGES+=$URLS |
| 57 | |
| 58 | # Make a nice combined list |
| 59 | echo $ALL_IMAGES | tr ',' '\n' | sort | uniq |