2af9e4c1b70621d3481e25ebf6065db04faf3e94
[ci-management.git] / scripts / respin-jcloud-images.sh
1 #!/bin/bash
2 # Copyright 2016 The Linux Foundation
3 set -e
4
5 SUPPORTED_PLATFORMS=(
6   'Ubuntu 14.04 amd64'
7   'Ubuntu 16.04 amd64'
8   'CentOS 7 x86_64'
9 )
10
11 CI_MGMT=$(realpath $(dirname $(realpath $0))/..)
12
13 source ${CI_MGMT}/vagrant/lib/respin-functions.sh
14 source ${PVERC}
15
16 echo nova: $(which nova)
17
18 export NETID=${NETID:-$(nova network-list | awk "/${CPPROJECT}/ {print \$2}")}
19
20 for PLATFORM in "${SUPPORTED_PLATFORMS[@]}"
21 do
22     read -ra DVA <<< "${PLATFORM}"
23     DIST="${DVA[0]}"
24     VERSION="${DVA[1]}"
25     ARCH="${DVA[2]}"
26     DTYPE=$(dist_type ${DIST})
27
28     AGE_JSON=$(latest_src_age ${DIST} ${VERSION} ${ARCH});
29
30     # only fetch new base image if our latest one is more than two weeks old
31     if [ $(echo ${AGE_JSON} | jq .week) -ge "3" ]
32     then
33         # Acquire bootstrap images
34         download_${DTYPE}_image "${DIST}" "${VERSION}" "${ARCH}"
35
36         # Push images to openstack via glance
37         create_${DTYPE}_image "${DIST}" "${VERSION}" "${ARCH}"
38     fi
39
40     # Respin images
41     cd ${CI_MGMT}/vagrant/basebuild
42     respin_${DTYPE}_image "${DIST}" "${VERSION}" "${ARCH}"
43 done