summaryrefslogtreecommitdiffstats
path: root/remote
diff options
context:
space:
mode:
authorChristian Rößler2015-09-12 15:33:12 +0200
committerChristian Rößler2015-09-12 15:33:12 +0200
commit5c28ac71515cc7d21d3de9b6bade21b38d6f51ea (patch)
tree09a36b5fcb93617e62d38fea89cc5eea37aba5dd /remote
parent[runvirt] Check if UUID-vmx file has zero bytes --> triggers legacy mode. (diff)
downloadtm-scripts-5c28ac71515cc7d21d3de9b6bade21b38d6f51ea.tar.gz
tm-scripts-5c28ac71515cc7d21d3de9b6bade21b38d6f51ea.tar.xz
tm-scripts-5c28ac71515cc7d21d3de9b6bade21b38d6f51ea.zip
[runvirt] Some cosmetics, better error handling in detect_legacy.inc
Diffstat (limited to 'remote')
-rw-r--r--remote/modules/run-virt/data/opt/openslx/scripts/detect_legacy.inc36
-rwxr-xr-xremote/modules/run-virt/data/opt/openslx/scripts/vmchooser-run_virt2
2 files changed, 24 insertions, 14 deletions
diff --git a/remote/modules/run-virt/data/opt/openslx/scripts/detect_legacy.inc b/remote/modules/run-virt/data/opt/openslx/scripts/detect_legacy.inc
index f28b62de..13670bb1 100644
--- a/remote/modules/run-virt/data/opt/openslx/scripts/detect_legacy.inc
+++ b/remote/modules/run-virt/data/opt/openslx/scripts/detect_legacy.inc
@@ -5,26 +5,36 @@
# Legacy mode: As runvirt has been before.
# New mode: uuid in xml _and_ vmx given via http.
-# First, let's try to extract an imguuid from xmlfile:
-IMGUUID=$(grep -io '<uuid param=.*"' "${xmlfile}" | sed -e "s/&.*;/; /g" | awk -F '"' '{ print $2 }')
+writelog "Now in detect_legacy.inc"
-# Temporary directory for run-virt related stuff
TMPDIR=$(mktemp -d -p /tmp/virt)
+ERR=$?
+if "$ERR"; then
+ writelog "Could not mkdir tempdir, using /tmp."
+ TMPDIR=/tmp
+fi
-# Then get a template (vmx) file via http/wget:
-wget -O "$TMPDIR/$IMGUUID" "${SLX_VMCHOOSER_BASE_URL}/lecture/${IMGUUID}"
+# First, let's try to extract an imguuid from xmlfile:
+IMGUUID=$(grep -io '<uuid param=.*"' "${xmlfile}" | sed -e "s/&.*;/; /g" | awk -F '"' '{ print $2 }')
-writelog "IMGUUID: -$IMGUUID- --- TMPDIR: ${TMPDIR}"
+writelog "IMGUUID extracted: $IMGUUID"
-if [ -n "$IMGUUID" ] && [ -n "$TMPDIR/$IMGUUID" ]; then
- LEGACY= # no legacy; both strings set
- writelog "Current (non-legacy) mode detected."
+if [ ! -n "$IMGUUID" ]; then # Keine uuid: Abbruch, Legacy
+ writelog "Could not extract an uuid param from ${xmlfile}. Triggering legacy mode."
+ LEGACY=: # No uuid; legacy.
else
- LEGACY=: # legacy: One or both strings not set
- writelog "Legacy mode detected."
+ writelog "else-Zweig"
+ # Now getting template file:
+ if wget -O "$TMPDIR/$IMGUUID" "${SLX_VMCHOOSER_BASE_URL}/lecture/${IMGUUID}" 1>&2 2>/dev/null; then
+ writelog "wget ${SLX_VMCHOOSER_BASE_URL}/lecture/${IMGUUID} successful."
+ LEGACY= # both strings set: no legacy.
+ else
+ writelog "wget ${SLX_VMCHOOSER_BASE_URL}/lecture/${IMGUUID}: Error code $ERR. Triggering legacy mode."
+ LEGACY=:
+ fi
fi
if [ ! -s "$TMPDIR/$IMGUUID" ]; then
- writelog "Warning: Image.UUID file has zero bytes - triggering legacy mode."
- LEGACY=:
+ LEGACY= # no legacy: server sent 0 byte file.
+ writelog "Server sent zero byte vmx template uuid file. Triggering legacy mode."
fi
diff --git a/remote/modules/run-virt/data/opt/openslx/scripts/vmchooser-run_virt b/remote/modules/run-virt/data/opt/openslx/scripts/vmchooser-run_virt
index 9845ead6..43c21453 100755
--- a/remote/modules/run-virt/data/opt/openslx/scripts/vmchooser-run_virt
+++ b/remote/modules/run-virt/data/opt/openslx/scripts/vmchooser-run_virt
@@ -27,7 +27,7 @@ source ${RUNVIRTINCLUDEDIR}/vmchooser_runvirt_functions.inc && trap cleanexit SI
# Define default dirs / get configs
source ${RUNVIRTINCLUDEDIR}/set_runvirt_variables.inc
# Function to detect whether we can use the new way (vmx via http) or the old way (legacy):
-source ${RUNVIRTINCLUDEDIR}/detect_legacy.inc # This yields IMGUUID, IMGVMX
+source ${RUNVIRTINCLUDEDIR}/detect_legacy.inc # This yields LEGACY, IMGUUID, IMGVMX
if [ "$LEGACY" ]; then
# check for important files used (filecheck()) - vestigial?