Merge "Download a compressed centos cloud images"

This commit is contained in:
Jenkins 2015-09-18 10:18:55 +00:00 committed by Gerrit Code Review
commit a04723e2ae
4 changed files with 16 additions and 2 deletions

View File

@ -24,7 +24,7 @@ if [ -n "$DIB_LOCAL_IMAGE" ]; then
BASE_IMAGE_TAR=$BASE_IMAGE_FILE.tgz BASE_IMAGE_TAR=$BASE_IMAGE_FILE.tgz
else else
DIB_CLOUD_IMAGES=${DIB_CLOUD_IMAGES:-http://cloud.centos.org/centos/6/images} DIB_CLOUD_IMAGES=${DIB_CLOUD_IMAGES:-http://cloud.centos.org/centos/6/images}
BASE_IMAGE_FILE=${BASE_IMAGE_FILE:-CentOS-6-x86_64-$DIB_RELEASE.qcow2} BASE_IMAGE_FILE=${BASE_IMAGE_FILE:-CentOS-6-x86_64-$DIB_RELEASE.qcow2.xz}
BASE_IMAGE_TAR=$BASE_IMAGE_FILE.tgz BASE_IMAGE_TAR=$BASE_IMAGE_FILE.tgz
IMAGE_LOCATION=$DIB_CLOUD_IMAGES/$BASE_IMAGE_FILE IMAGE_LOCATION=$DIB_CLOUD_IMAGES/$BASE_IMAGE_FILE
CACHED_IMAGE=$DIB_IMAGE_CACHE/$BASE_IMAGE_FILE CACHED_IMAGE=$DIB_IMAGE_CACHE/$BASE_IMAGE_FILE

View File

@ -28,7 +28,7 @@ if [ -n "$DIB_LOCAL_IMAGE" ]; then
else else
DIB_RELEASE=${DIB_RELEASE:-GenericCloud} DIB_RELEASE=${DIB_RELEASE:-GenericCloud}
DIB_CLOUD_IMAGES=${DIB_CLOUD_IMAGES:-http://cloud.centos.org/centos/7/images} DIB_CLOUD_IMAGES=${DIB_CLOUD_IMAGES:-http://cloud.centos.org/centos/7/images}
BASE_IMAGE_FILE=${BASE_IMAGE_FILE:-CentOS-7-x86_64-$DIB_RELEASE.qcow2} BASE_IMAGE_FILE=${BASE_IMAGE_FILE:-CentOS-7-x86_64-$DIB_RELEASE.qcow2.xz}
BASE_IMAGE_TAR=$BASE_IMAGE_FILE.tgz BASE_IMAGE_TAR=$BASE_IMAGE_FILE.tgz
IMAGE_LOCATION=$DIB_CLOUD_IMAGES/$BASE_IMAGE_FILE IMAGE_LOCATION=$DIB_CLOUD_IMAGES/$BASE_IMAGE_FILE
CACHED_IMAGE=$DIB_IMAGE_CACHE/$BASE_IMAGE_FILE CACHED_IMAGE=$DIB_IMAGE_CACHE/$BASE_IMAGE_FILE

View File

@ -3,6 +3,13 @@ redhat-common
============= =============
Image installation steps common to RHEL, CentOS, and Fedora. Image installation steps common to RHEL, CentOS, and Fedora.
Requirements:
If used to build an image form a cloud image compress with xz
(the default in centos), this element uses "unxz" to decompress
the image. Depending on your distro you may need to install either
the xz or xz-utils package.
Overrides: Overrides:
DIB_LOCAL_IMAGE DIB_LOCAL_IMAGE

View File

@ -50,6 +50,13 @@ function extract_image() {
RAW_FILE=$(mktemp --tmpdir=$WORKING XXXXXX.raw) RAW_FILE=$(mktemp --tmpdir=$WORKING XXXXXX.raw)
if [ "${CACHED_IMAGE: -3}" == ".xz" ] ; then
QCOW2_FILE=$(mktemp --tmpdir=$WORKING XXXXXX.qcow2)
# This leaves the old image in place so cache-url wont get it again
unxz --stdout $CACHED_IMAGE > $QCOW2_FILE
CACHED_IMAGE=$QCOW2_FILE
fi
qemu-img convert -f qcow2 -O raw $CACHED_IMAGE $RAW_FILE qemu-img convert -f qcow2 -O raw $CACHED_IMAGE $RAW_FILE
ROOT_PARTITON=p$(sudo kpartx -l $RAW_FILE | awk "/loop[0-9]+p/"|wc -l) ROOT_PARTITON=p$(sudo kpartx -l $RAW_FILE | awk "/loop[0-9]+p/"|wc -l)