diff options
Diffstat (limited to 'core/modules/run-virt/data/opt/openslx/scripts/includes/detect_legacy.inc')
-rw-r--r-- | core/modules/run-virt/data/opt/openslx/scripts/includes/detect_legacy.inc | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/core/modules/run-virt/data/opt/openslx/scripts/includes/detect_legacy.inc b/core/modules/run-virt/data/opt/openslx/scripts/includes/detect_legacy.inc new file mode 100644 index 00000000..11a21832 --- /dev/null +++ b/core/modules/run-virt/data/opt/openslx/scripts/includes/detect_legacy.inc @@ -0,0 +1,33 @@ +######################################################## +# 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: +IMGUUID=$(grep -io '<uuid param=.*"' "${xmlfile}" | sed -e "s/&.*;/; /g" | awk -F '"' '{ print $2 }') + +writelog "IMGUUID extracted: $IMGUUID" + +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 + # 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." + writelog "Triggering current (non-legacy) mode." + LEGACY= # both strings set: no legacy. + if [ ! -s "$TMPDIR/$IMGUUID" ]; then + LEGACY= # no legacy: server sent 0 byte file. + writelog "Server sent zero byte virtual machine description file. Retriggering legacy mode." + fi + else + writelog "wget ${SLX_VMCHOOSER_BASE_URL}/lecture/${IMGUUID}. Triggering legacy mode." + LEGACY=: + fi +fi + |