From f773a12e3b24ed0e9eb4e0021a24c7f69d3e5bc0 Mon Sep 17 00:00:00 2001 From: Steven Hardy Date: Sat, 27 Apr 2013 14:45:12 +0100 Subject: 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 --- tools/heat-jeos.sh | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100755 tools/heat-jeos.sh (limited to 'tools') 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 " + 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} -- cgit v1.2.1