diff options
| author | Martin André <m.andre@redhat.com> | 2017-08-28 14:38:50 +0200 |
|---|---|---|
| committer | Taeha Kim <kthguru@gmail.com> | 2018-01-18 04:13:18 +0000 |
| commit | 84473bec5f55dea2e059c4bf1c0c66d7e7808f1a (patch) | |
| tree | 41c6e009a9192c627fa21ad30ab42ccf4496062a /tools/init-runonce | |
| parent | 09ca7d66d5f937804f80ea7f547e61f34eff2d1c (diff) | |
| download | kolla-ansible-84473bec5f55dea2e059c4bf1c0c66d7e7808f1a.tar.gz kolla-ansible-84473bec5f55dea2e059c4bf1c0c66d7e7808f1a.zip | |
Use local cirros image if available
Nodepool nodes saves the cirros image in /opt/cache/files/, we can make
use of it to save some time and remove an external dependency on the
cirros website.
Change-Id: I81b431d8659b1da8b36d660f2a8f1cfa42461a14
Diffstat (limited to 'tools/init-runonce')
| -rwxr-xr-x | tools/init-runonce | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/tools/init-runonce b/tools/init-runonce index 0a6222c35..4ef74aaac 100755 --- a/tools/init-runonce +++ b/tools/init-runonce @@ -6,6 +6,7 @@ # to be created. ARCH=$(uname -m) +IMAGE_PATH=/opt/cache/files/ IMAGE_URL=http://download.cirros-cloud.net/0.4.0/ IMAGE=cirros-0.4.0-${ARCH}-disk.img IMAGE_NAME=cirros @@ -45,9 +46,17 @@ if openstack image list | grep -q cirros; then exit fi -echo Downloading glance image. -if ! [ -f "${IMAGE}" ]; then - curl -L -o ./${IMAGE} ${IMAGE_URL}/${IMAGE} +echo Checking for locally available cirros image. +# Let's first try to see if the image is available locally +# nodepool nodes caches them in $IMAGE_PATH +if ! [ -f "${IMAGE_PATH}/${IMAGE}" ]; then + IMAGE_PATH='./' + if ! [ -f "${IMAGE_PATH}/${IMAGE}" ]; then + echo None found, downloading cirros image. + curl -L -o ${IMAGE_PATH}/${IMAGE} ${IMAGE_URL}/${IMAGE} + fi +else + echo Using cached cirros image from the nodepool node. fi EXTRA_PROPERTIES= @@ -57,7 +66,7 @@ fi echo Creating glance image. openstack image create --disk-format qcow2 --container-format bare --public \ - --property os_type=${IMAGE_TYPE} ${EXTRA_PROPERTIES} --file ./${IMAGE} ${IMAGE_NAME} + --property os_type=${IMAGE_TYPE} ${EXTRA_PROPERTIES} --file ${IMAGE_PATH}/${IMAGE} ${IMAGE_NAME} echo Configuring neutron. openstack network create --external --provider-physical-network physnet1 \ |
