diff options
author | Steven Hardy <shardy@redhat.com> | 2013-04-27 14:45:12 +0100 |
---|---|---|
committer | Steven Hardy <shardy@redhat.com> | 2013-04-29 12:53:25 +0100 |
commit | f773a12e3b24ed0e9eb4e0021a24c7f69d3e5bc0 (patch) | |
tree | 124b17e4d46d7ea8333a218c12b212b9218785c9 /tools | |
parent | de67cecf926d660057ad9f72f87ae159829e54bf (diff) | |
download | heat-templates-f773a12e3b24ed0e9eb4e0021a24c7f69d3e5bc0.tar.gz |
Add heat-jeos TDL files and oz wrapper script
Import heat-jeos oz TDL files, and a utility script which wraps the
commands required to process them.
The heat-jeos.sh script is a simple (if not quite as fully featured)
replacement for the heat-jeos tool, meaning we can deprecate it.
fixes bug #1171602
Change-Id: I23416d1e3c7a5329c2076db6fbe6f51d44720766
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/heat-jeos.sh | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/tools/heat-jeos.sh b/tools/heat-jeos.sh new file mode 100755 index 0000000..1c7e66c --- /dev/null +++ b/tools/heat-jeos.sh @@ -0,0 +1,51 @@ +#!/bin/bash +# Build a JEOS image using OZ + +exit_usage(){ + echo "Error : $1" + echo "Usage $0 <tdl file> <image name>" + echo "Note tdl file must be a valid Oz TDL" + echo "Note image name must match the name defined in the TDL" + exit 1 +} + +DISK_FORMAT="qcow2" +LIBVIRT_IMGDIR="/var/lib/libvirt/images" +DEBUG="-d 3" + +if [ $# -ne 2 ]; then + exit_usage "Insufficient arguments" +fi +TDLFILE=$1 +TDLNAME=$2 +LIBVIRT_XMLFILE="/tmp/${TDLNAME}_libvirtxml.$$" + +# Sanity check user input +if [ ! -s "${TDLFILE}" ] +then + exit_usage "${TDLFILE} does not exist or is empty" +fi + +if ! grep -q ${TDLNAME} ${TDLFILE}; then + exit_usage "${TDLNAME} not defined in ${TDLFILE}" +fi + +if [ -e "${LIBVIRT_IMGDIR}/${TDLNAME}.dsk" ]; then + exit_usage "${LIBVIRT_IMGDIR}/${TDLNAME}.dsk already exists, please remove then re-run" +fi + +oz-install -u ${DEBUG} ${TDLFILE} -x ${LIBVIRT_XMLFILE} + +DSKFILE="${LIBVIRT_IMGDIR}/${TDLNAME}.dsk" +FMTFILE="${LIBVIRT_IMGDIR}/${TDLNAME}.${DISK_FORMAT}" +qemu-img convert -c -O ${DISK_FORMAT} ${DSKFILE} ${FMTFILE} + +if [ -f ${FMTFILE} ]; then + echo "Image ${FMTFILE} complete, now add image to glance, e.g:" + GLANCECMD="glance add name=${TDLNAME} is_public=true disk_format=${DISK_FORMAT} container_format=bare" + echo "${GLANCECMD} < ${FMTFILE}" +else + echo "Error creating image file ${FMTFILE}" +fi + +rm -f ${LIBVIRT_XMLFILE} |