diff --git a/labs/config/openstack b/labs/config/openstack index 1070668c..704afcff 100644 --- a/labs/config/openstack +++ b/labs/config/openstack @@ -4,6 +4,9 @@ # one of: folsom, grizzly, havana, icehouse : ${OPENSTACK_RELEASE:=icehouse} +# CirrOS image URL +CIRROS_URL="http://download.cirros-cloud.net/0.3.3/cirros-0.3.3-x86_64-disk.img" + # Networks used by OpenStack training-labs setup : ${MGMT_NET:=10.10.10.1} : ${DATA_NET:=10.20.20.1} diff --git a/labs/scripts/apt_pre-download.sh b/labs/scripts/apt_pre-download.sh index 95e9b272..1b5b1a33 100755 --- a/labs/scripts/apt_pre-download.sh +++ b/labs/scripts/apt_pre-download.sh @@ -9,10 +9,34 @@ exec_logfile indicate_current_auto # Download CirrOS image -CIRROS_URL="http://download.cirros-cloud.net/0.3.3/cirros-0.3.3-x86_64-disk.img" -if [ ! -f "$IMG_DIR/$(basename "$CIRROS_URL")" ]; then - wget --directory-prefix="$IMG_DIR" "$CIRROS_URL" -fi +function get_cirros { + local file_name=$(basename $CIRROS_URL) + local remote_dir=$(dirname $CIRROS_URL) + local md5_f=$file_name.md5sum + + mkdir -p "$IMG_DIR" + + # Download to IMG_DIR to cache the data if the directory is shared + # with the host computer. + if [ ! -f "$IMG_DIR/$md5_f" ]; then + wget -O - "$remote_dir/MD5SUMS"|grep "$file_name" > "$IMG_DIR/$md5_f" + fi + + if [ ! -f "$IMG_DIR/$file_name" ]; then + wget --directory-prefix="$IMG_DIR" "$CIRROS_URL" + fi + + # Make sure we have image and MD5SUM on the basedisk. + if [ "$IMG_DIR" != "$HOME/img" ]; then + mkdir -p "$HOME/img" + cp -a "$IMG_DIR/$file_name" "$IMG_DIR/$md5_f" "$HOME/img" + fi + + cd "$HOME/img" + md5sum -c "$HOME/img/$md5_f" + cd - +} +get_cirros function apt_download { diff --git a/labs/scripts/setup_glance.sh b/labs/scripts/setup_glance.sh index d3a07297..af67bdc8 100755 --- a/labs/scripts/setup_glance.sh +++ b/labs/scripts/setup_glance.sh @@ -108,7 +108,7 @@ glance image-create \ --name Cirros_x86_64 \ --is-public true \ --container-format bare \ - --disk-format qcow2 < "$IMG_DIR/cirros-0.3.3-x86_64-disk.img" + --disk-format qcow2 < "$HOME/img/$(basename $CIRROS_URL)" #------------------------------------------------------------------------------ # Verify the Image Service installation