summaryrefslogtreecommitdiffstats
path: root/scripts/respin-jcloud-images.sh
blob: 2af9e4c1b70621d3481e25ebf6065db04faf3e94 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash
# Copyright 2016 The Linux Foundation
set -e

SUPPORTED_PLATFORMS=(
  'Ubuntu 14.04 amd64'
  'Ubuntu 16.04 amd64'
  'CentOS 7 x86_64'
)

CI_MGMT=$(realpath $(dirname $(realpath $0))/..)

source ${CI_MGMT}/vagrant/lib/respin-functions.sh
source ${PVERC}

echo nova: $(which nova)

export NETID=${NETID:-$(nova network-list | awk "/${CPPROJECT}/ {print \$2}")}

for PLATFORM in "${SUPPORTED_PLATFORMS[@]}"
do
    read -ra DVA <<< "${PLATFORM}"
    DIST="${DVA[0]}"
    VERSION="${DVA[1]}"
    ARCH="${DVA[2]}"
    DTYPE=$(dist_type ${DIST})

    AGE_JSON=$(latest_src_age ${DIST} ${VERSION} ${ARCH});

    # only fetch new base image if our latest one is more than two weeks old
    if [ $(echo ${AGE_JSON} | jq .week) -ge "3" ]
    then
        # Acquire bootstrap images
        download_${DTYPE}_image "${DIST}" "${VERSION}" "${ARCH}"

        # Push images to openstack via glance
        create_${DTYPE}_image "${DIST}" "${VERSION}" "${ARCH}"
    fi

    # Respin images
    cd ${CI_MGMT}/vagrant/basebuild
    respin_${DTYPE}_image "${DIST}" "${VERSION}" "${ARCH}"
done