From fadb613e7843bb916e7d382c6fe543eab29a19fd Mon Sep 17 00:00:00 2001 From: Derek Higgins Date: Wed, 16 Sep 2015 16:31:27 +0100 Subject: [PATCH] Download a compressed centos cloud images The centos cloud images are both arround a GB in size, and downloading them causes lot of CI timeouts, downloading the compressed version saves 700MB of bandwith and should save a lot of time. Change-Id: I8dcd1db81fe5c4661945638ef3e6344fdf651243 --- elements/centos/root.d/10-centos6-cloud-image | 2 +- elements/centos7/root.d/10-centos7-cloud-image | 2 +- elements/redhat-common/README.rst | 7 +++++++ elements/redhat-common/bin/extract-image | 7 +++++++ 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/elements/centos/root.d/10-centos6-cloud-image b/elements/centos/root.d/10-centos6-cloud-image index e6e1d67e..8ff36493 100755 --- a/elements/centos/root.d/10-centos6-cloud-image +++ b/elements/centos/root.d/10-centos6-cloud-image @@ -24,7 +24,7 @@ if [ -n "$DIB_LOCAL_IMAGE" ]; then BASE_IMAGE_TAR=$BASE_IMAGE_FILE.tgz else 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 IMAGE_LOCATION=$DIB_CLOUD_IMAGES/$BASE_IMAGE_FILE CACHED_IMAGE=$DIB_IMAGE_CACHE/$BASE_IMAGE_FILE diff --git a/elements/centos7/root.d/10-centos7-cloud-image b/elements/centos7/root.d/10-centos7-cloud-image index d1ef4b83..cd79a418 100755 --- a/elements/centos7/root.d/10-centos7-cloud-image +++ b/elements/centos7/root.d/10-centos7-cloud-image @@ -28,7 +28,7 @@ if [ -n "$DIB_LOCAL_IMAGE" ]; then else DIB_RELEASE=${DIB_RELEASE:-GenericCloud} 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 IMAGE_LOCATION=$DIB_CLOUD_IMAGES/$BASE_IMAGE_FILE CACHED_IMAGE=$DIB_IMAGE_CACHE/$BASE_IMAGE_FILE diff --git a/elements/redhat-common/README.rst b/elements/redhat-common/README.rst index 912cc2d6..7b3143c7 100644 --- a/elements/redhat-common/README.rst +++ b/elements/redhat-common/README.rst @@ -3,6 +3,13 @@ redhat-common ============= 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: DIB_LOCAL_IMAGE diff --git a/elements/redhat-common/bin/extract-image b/elements/redhat-common/bin/extract-image index 496db17f..1dec0368 100755 --- a/elements/redhat-common/bin/extract-image +++ b/elements/redhat-common/bin/extract-image @@ -50,6 +50,13 @@ function extract_image() { 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 ROOT_PARTITON=p$(sudo kpartx -l $RAW_FILE | awk "/loop[0-9]+p/"|wc -l)