Skip to content
This repository has been archived by the owner on Apr 23, 2020. It is now read-only.

Commit

Permalink
Merge pull request #6 from hardys/image_url
Browse files Browse the repository at this point in the history
Handle a fully-qualified openstack qcow URL
  • Loading branch information
Steven Hardy authored Jul 24, 2019
2 parents 90e9bf2 + 94db803 commit 948c520
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions get-resource.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,21 @@ if [ -z "$RHCOS_IMAGE_URL" ] ; then
exit 1
fi

RHCOS_IMAGE_FILENAME_OPENSTACK_GZ="$(curl ${RHCOS_IMAGE_URL}/meta.json | jq -r '.images.openstack.path')"
RHCOS_IMAGE_NAME=$(echo $RHCOS_IMAGE_FILENAME_OPENSTACK_GZ | sed -e 's/-openstack.*//')
RHCOS_IMAGE_FILENAME_OPENSTACK="${RHCOS_IMAGE_NAME}-openstack.qcow2"
RHCOS_IMAGE_FILENAME_COMPRESSED="${RHCOS_IMAGE_NAME}-compressed.qcow2"
# When provided by openshift-installer the URL is like
# "https://releases-art-rhcos.svc.ci.openshift.org/art/storage/releases/rhcos-4.2/420.8.20190708.2/rhcos-420.8.20190708.2-openstack.qcow2"
# In this case we use the URL as-is, otherwise for backwards compatibility
# we figure it out from meta.json (when only the baseURI is provided)
# The latter will be removed when
# https://github.com/openshift/installer/issues/2064 and
# https://github.com/openshift/installer/issues/2037 are fully completed
if [[ $RHCOS_IMAGE_URL = *.qcow2 ]]; then
RHCOS_IMAGE_FILENAME_OPENSTACK=$(basename $RHCOS_IMAGE_URL)
IMAGE_URL=$(dirname $RHCOS_IMAGE_URL)
else
RHCOS_IMAGE_FILENAME_OPENSTACK="$(curl ${RHCOS_IMAGE_URL}/meta.json | jq -r '.images.openstack.path')"
IMAGE_URL=${RHCOS_IMAGE_URL}
fi
RHCOS_IMAGE_FILENAME_COMPRESSED=${RHCOS_IMAGE_FILENAME_OPENSTACK/%openstack.qcow2/compressed.qcow2}
FFILENAME="rhcos-ootpa-latest.qcow2"

mkdir -p /shared/html/images
Expand Down Expand Up @@ -41,7 +52,7 @@ if [ "$FILECACHED" == "${RHCOS_IMAGE_FILENAME_OPENSTACK}" ] ; then
curl -O "$CACHEURL/$RHCOS_IMAGE_FILENAME_OPENSTACK/$RHCOS_IMAGE_FILENAME_OPENSTACK"
curl -O "$CACHEURL/$RHCOS_IMAGE_FILENAME_OPENSTACK/$RHCOS_IMAGE_FILENAME_COMPRESSED.md5sum"
else
curl --insecure --compressed -L --dump-header "${RHCOS_IMAGE_FILENAME_OPENSTACK}.headers" -o "${RHCOS_IMAGE_FILENAME_OPENSTACK}" "${RHCOS_IMAGE_URL}/${RHCOS_IMAGE_FILENAME_OPENSTACK}"
curl --insecure --compressed -L --dump-header "${RHCOS_IMAGE_FILENAME_OPENSTACK}.headers" -o "${RHCOS_IMAGE_FILENAME_OPENSTACK}" "${IMAGE_URL}/${RHCOS_IMAGE_FILENAME_OPENSTACK}"
qemu-img convert -O qcow2 -c "$RHCOS_IMAGE_FILENAME_OPENSTACK" "$RHCOS_IMAGE_FILENAME_COMPRESSED"
md5sum "$RHCOS_IMAGE_FILENAME_COMPRESSED" | cut -f 1 -d " " > "$RHCOS_IMAGE_FILENAME_COMPRESSED.md5sum"
fi
Expand Down

0 comments on commit 948c520

Please sign in to comment.