diff options
author | Simon Rettberg | 2016-10-19 15:07:25 +0200 |
---|---|---|
committer | Simon Rettberg | 2016-10-19 15:07:25 +0200 |
commit | 7c70ebde186c9589bd6e56f04d9f9bab682a3c14 (patch) | |
tree | a50105db62d13275dfacb774a15c51cdea76bcfc /remote/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/detect_legacy.inc | |
parent | [vmware/run-virt] Try to rename includes to what they actually do (diff) | |
download | tm-scripts-7c70ebde186c9589bd6e56f04d9f9bab682a3c14.tar.gz tm-scripts-7c70ebde186c9589bd6e56f04d9f9bab682a3c14.tar.xz tm-scripts-7c70ebde186c9589bd6e56f04d9f9bab682a3c14.zip |
[run-virt] More cleanup; kill legacy support, rename and move includes, kill dead code
Diffstat (limited to 'remote/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/detect_legacy.inc')
-rw-r--r-- | remote/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/detect_legacy.inc | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/remote/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/detect_legacy.inc b/remote/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/detect_legacy.inc new file mode 100644 index 00000000..8bdfd8b1 --- /dev/null +++ b/remote/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/detect_legacy.inc @@ -0,0 +1,34 @@ +######################################################## +# Include: Detect, whether runvirt runs in legacy mode # +######################################################## + +# Legacy mode: As runvirt has been before. +# New mode: uuid in xml _and_ vmx given via http. + +writelog "Detecting current/legacy mode ..." + +# First, let's try to extract an imguuid from xmlfile: +declare -rg IMGUUID=$(grep -i -o '<uuid param=.*"' "${xmlfile}" | sed -e "s/&.*;/; /g" | awk -F '"' '{ print $2 }') +declare -rg TMPCONFIG="$TMPDIR/vmconfig.tmp" + +writelog "IMGUUID extracted: $IMGUUID" + +# Assume legacy mode by default, only trigger "current" mode if everything else below worked +LEGACY=yes +if [ -z "$IMGUUID" ]; then # Keine uuid: Abbruch, Legacy + writelog "Could not extract a uuid param from ${xmlfile}. Triggering legacy mode." +else + # Now getting template file: + if ! wget -T 6 -O "$TMPCONFIG" "${SLX_VMCHOOSER_BASE_URL}/lecture/${IMGUUID}" 2>/dev/null >&2; then + writelog "wget ${SLX_VMCHOOSER_BASE_URL}/lecture/${IMGUUID}. Triggering legacy mode." + else + writelog "wget ${SLX_VMCHOOSER_BASE_URL}/lecture/${IMGUUID} successful." + if [ ! -s "$TMPCONFIG" ]; then + writelog "Server sent zero byte virtual machine description file. Triggering legacy mode." + else + writelog "Triggering current (non-legacy) mode." + LEGACY= # everything worked - clear legacy mode variable (so we use the "current" mode) + fi + fi +fi + |