summaryrefslogtreecommitdiffstats
path: root/remote/modules/run-virt
diff options
context:
space:
mode:
authorSimon Rettberg2016-03-24 19:36:54 +0100
committerSimon Rettberg2016-03-24 19:36:54 +0100
commitb8f5d3436bcaa6bb7412f0569f1e42b20073b327 (patch)
tree15144ee9f01184a836825aad3d2dee1a7d1d0826 /remote/modules/run-virt
parentMerge branch 'master' of git://git.openslx.org/openslx-ng/tm-scripts (diff)
downloadtm-scripts-b8f5d3436bcaa6bb7412f0569f1e42b20073b327.tar.gz
tm-scripts-b8f5d3436bcaa6bb7412f0569f1e42b20073b327.tar.xz
tm-scripts-b8f5d3436bcaa6bb7412f0569f1e42b20073b327.zip
[run-virt] Add user feedback (GUI) if things go wrong
Diffstat (limited to 'remote/modules/run-virt')
-rw-r--r--remote/modules/run-virt/data/opt/openslx/scripts/includes/check_lpd.inc2
-rw-r--r--remote/modules/run-virt/data/opt/openslx/scripts/includes/check_runvirt_xml_sanity_legacy.inc5
-rw-r--r--remote/modules/run-virt/data/opt/openslx/scripts/includes/detect_legacy.inc22
-rw-r--r--remote/modules/run-virt/data/opt/openslx/scripts/includes/set_runvirt_hardware_variables.inc2
-rw-r--r--remote/modules/run-virt/data/opt/openslx/scripts/includes/set_runvirt_variables.inc7
-rw-r--r--remote/modules/run-virt/data/opt/openslx/scripts/includes/setup_image_access.inc2
-rw-r--r--remote/modules/run-virt/data/opt/openslx/scripts/includes/setup_virtual_floppy.inc4
-rw-r--r--remote/modules/run-virt/data/opt/openslx/scripts/includes/setup_vm_hypervisor.inc5
-rw-r--r--remote/modules/run-virt/data/opt/openslx/scripts/includes/start_pvs.inc11
-rw-r--r--remote/modules/run-virt/data/opt/openslx/scripts/includes/start_windowmanager.inc7
-rw-r--r--remote/modules/run-virt/data/opt/openslx/scripts/includes/vmchooser_runvirt_functions.inc28
-rwxr-xr-xremote/modules/run-virt/data/opt/openslx/scripts/systemd-run_virt_env6
-rwxr-xr-xremote/modules/run-virt/data/opt/openslx/scripts/vmchooser-run_virt5
13 files changed, 68 insertions, 38 deletions
diff --git a/remote/modules/run-virt/data/opt/openslx/scripts/includes/check_lpd.inc b/remote/modules/run-virt/data/opt/openslx/scripts/includes/check_lpd.inc
index 8286bbaa..cfaf811e 100644
--- a/remote/modules/run-virt/data/opt/openslx/scripts/includes/check_lpd.inc
+++ b/remote/modules/run-virt/data/opt/openslx/scripts/includes/check_lpd.inc
@@ -8,4 +8,6 @@
if ! kill -0 "$PID_LPD"; then
slxlog "virt-lpd" "Could not start tcpsvd/lpd for virtual machine session"
+ notify_user "Durcksystem" "Das Drucksystem konnte nicht initialisiert werden. Druckfunktion nicht verfügbar."
fi
+
diff --git a/remote/modules/run-virt/data/opt/openslx/scripts/includes/check_runvirt_xml_sanity_legacy.inc b/remote/modules/run-virt/data/opt/openslx/scripts/includes/check_runvirt_xml_sanity_legacy.inc
index d331e1af..0e720a06 100644
--- a/remote/modules/run-virt/data/opt/openslx/scripts/includes/check_runvirt_xml_sanity_legacy.inc
+++ b/remote/modules/run-virt/data/opt/openslx/scripts/includes/check_runvirt_xml_sanity_legacy.inc
@@ -6,6 +6,7 @@
if ! [ -r "${xmlfile}" ]; then
writelog "${xmlfile} not a readable XML file!"
slxlog "virt-nonreadable-xml" "XML file not readable: $xmlfile"
+ error_user "Die XML-Datei der gewählten Sitzung ist nicht lesbar oder existiert nicht"
exit 1
fi
@@ -13,11 +14,13 @@ fi
if ! grep -q '<?xml' "${xmlfile}"; then
writelog "Submitted configuration file ${xmlfile} seems to have wrong XML format"
slxlog "virt-invalid-xml" "Malformed XML file: $xmlfile" "$xmlfile"
+ error_user "Die XML-Datei der gewählten Sitzung hat ein ungültiges Format"
exit 1
fi
# check for running in graphical environment otherwise no much use here
if [ -z "$DISPLAY" ]; then
- echo -e "\n\tStart only within a graphical desktop!\n"
+ writelog -e "\n\tStart only within a graphical desktop!\n"
exit 1
fi
+
diff --git a/remote/modules/run-virt/data/opt/openslx/scripts/includes/detect_legacy.inc b/remote/modules/run-virt/data/opt/openslx/scripts/includes/detect_legacy.inc
index 11a21832..fb64d73e 100644
--- a/remote/modules/run-virt/data/opt/openslx/scripts/includes/detect_legacy.inc
+++ b/remote/modules/run-virt/data/opt/openslx/scripts/includes/detect_legacy.inc
@@ -12,22 +12,22 @@ IMGUUID=$(grep -io '<uuid param=.*"' "${xmlfile}" | sed -e "s/&.*;/; /g" | awk -
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.
+# 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 -O "$TMPDIR/$IMGUUID" "${SLX_VMCHOOSER_BASE_URL}/lecture/${IMGUUID}" 1>&2 2>/dev/null; then
+ if ! wget -O "$TMPDIR/$IMGUUID" "${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."
- 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."
+ 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
- else
- writelog "wget ${SLX_VMCHOOSER_BASE_URL}/lecture/${IMGUUID}. Triggering legacy mode."
- LEGACY=:
fi
fi
diff --git a/remote/modules/run-virt/data/opt/openslx/scripts/includes/set_runvirt_hardware_variables.inc b/remote/modules/run-virt/data/opt/openslx/scripts/includes/set_runvirt_hardware_variables.inc
index a93bf62c..1b386092 100644
--- a/remote/modules/run-virt/data/opt/openslx/scripts/includes/set_runvirt_hardware_variables.inc
+++ b/remote/modules/run-virt/data/opt/openslx/scripts/includes/set_runvirt_hardware_variables.inc
@@ -12,7 +12,7 @@ cpu_cores=${cpu_cores:-"1"}
if mount | grep -q '^/dev/sd.*on.*/tmp'; then
reserve=20
min=768
- max=1536
+ max=1800
else
reserve=65
min=768
diff --git a/remote/modules/run-virt/data/opt/openslx/scripts/includes/set_runvirt_variables.inc b/remote/modules/run-virt/data/opt/openslx/scripts/includes/set_runvirt_variables.inc
index 5215eb2d..4c4ccf1d 100644
--- a/remote/modules/run-virt/data/opt/openslx/scripts/includes/set_runvirt_variables.inc
+++ b/remote/modules/run-virt/data/opt/openslx/scripts/includes/set_runvirt_variables.inc
@@ -17,5 +17,10 @@ readonly VMCHOOSER_DIR VMCHOOSER_CONF_DIR LOGFILE TMPDIR USER
# Load general openslx config
[ -f "/opt/openslx/config" ] && . "/opt/openslx/config"
# Create temp dir
-mkdir -p "$TMPDIR" # TODO error out if failed
+if ! mkdir -p "$TMPDIR"; then
+ slxlog "virt-tmpdir" "Could not create temporary directory '$TMPDIR' for session"
+ error_user "Konnte kein temporäres Arbeitsverzeichnis für die VM-Sitzung anlegen. Ein Computer-Neustart könnte das Problem lösen."
+ cleanexit 1
+ exit 1
+fi
diff --git a/remote/modules/run-virt/data/opt/openslx/scripts/includes/setup_image_access.inc b/remote/modules/run-virt/data/opt/openslx/scripts/includes/setup_image_access.inc
index dd408b22..337562dc 100644
--- a/remote/modules/run-virt/data/opt/openslx/scripts/includes/setup_image_access.inc
+++ b/remote/modules/run-virt/data/opt/openslx/scripts/includes/setup_image_access.inc
@@ -64,6 +64,8 @@ fi
if ! [ -e "${vmpath}" ]; then
slxlog "virt-image-missing" "VM image $vmpath not found!"
writelog "Virtual machine image ${vmpath} not found!"
+ error_user "Das Image für die gewählte Virtuelle Maschine konnte nicht gefunden werden.
+Versuchen Sie zunächst, den Computer komplett neu zu starten. Sollte das Problem bestehen bleiben, wenden Sie sich bitte an den Support."
cleanexit 1
fi
diff --git a/remote/modules/run-virt/data/opt/openslx/scripts/includes/setup_virtual_floppy.inc b/remote/modules/run-virt/data/opt/openslx/scripts/includes/setup_virtual_floppy.inc
index f6bcb4da..ddfbacbb 100644
--- a/remote/modules/run-virt/data/opt/openslx/scripts/includes/setup_virtual_floppy.inc
+++ b/remote/modules/run-virt/data/opt/openslx/scripts/includes/setup_virtual_floppy.inc
@@ -51,7 +51,9 @@ HIER
declare -rg SHARES="${TMPDIR}/shares.dat"
touch "${SHARES}"
chmod 0600 "${SHARES}"
-if pwdaemon --query "${TMPHOME}/.pwsocket" > "${SHARES}"; then
+if ! pwdaemon --query "${TMPHOME}/.pwsocket" > "${SHARES}"; then
+ slxlog "virt-pwdaemon" "Could not start pwdaemon"
+else
sed -i 's/^/192.168.101.1\t/' "${SHARES}" # TODO: Depending on nettype (in case we have != nat some day)
if [ "${SHARE_REMAP_MODE}" = 1 -o "${SHARE_REMAP_MODE}" = 2 ] && [ -e "${TMPHOME}/.home" ]; then
NETHOME=$(cat "${TMPHOME}/.home")
diff --git a/remote/modules/run-virt/data/opt/openslx/scripts/includes/setup_vm_hypervisor.inc b/remote/modules/run-virt/data/opt/openslx/scripts/includes/setup_vm_hypervisor.inc
index b7bb8f01..33fd363b 100644
--- a/remote/modules/run-virt/data/opt/openslx/scripts/includes/setup_vm_hypervisor.inc
+++ b/remote/modules/run-virt/data/opt/openslx/scripts/includes/setup_vm_hypervisor.inc
@@ -4,9 +4,10 @@
# Get all virtual machine specific stuff from the respective include file
if [ ! -e "$VMCHOOSER_DIR/$xmlvirt/run-virt.include" ] ; then
- # TODO: Tell user
slxlog "virt-plugin-missing" "Could not find run-virt.include for $xmlvirt ($VMCHOOSER_DIR/$xmlvirt/run-virt.include)"
writelog "Failed because of missing ${xmlvirt} plugin."
+ error_user "Konnte den Virtualisierer '$xmlvirt' nicht finden. Starten der Virtuellen Maschine fehlgeschlagen.
+ Starten Sie den Computer neu und wenden Sie sich an den Support, wenn das Problem weiterhin besteht."
cleanexit 1
fi
@@ -16,4 +17,6 @@ fi
if ! source "$VMCHOOSER_DIR/$xmlvirt/run-virt.include"; then
slxlog "virt-plugin-error" "run-virt.include for $xmlvirt could not be sourced (contains syntax errors?)" "$xmlvirt"
writelog "Erroneous run-virt.include for $xmlvirt"
+ error_user "Das Start-Script für den Virtualisierer '$xmlvirt' ist fehlerhaft.
+ Starten Sie den Computer neu und wenden Sie sich an den Support, wenn das Problem weiterhin besteht."
fi
diff --git a/remote/modules/run-virt/data/opt/openslx/scripts/includes/start_pvs.inc b/remote/modules/run-virt/data/opt/openslx/scripts/includes/start_pvs.inc
deleted file mode 100644
index 90cd237b..00000000
--- a/remote/modules/run-virt/data/opt/openslx/scripts/includes/start_pvs.inc
+++ /dev/null
@@ -1,11 +0,0 @@
-#######################################################
-# Include: Starting PVS (Pool Video switch) if wanted #
-#######################################################
-
-# if [ -e /etc/xdg/autostart/pvsgui.desktop ]; then
-# /usr/local/bin/pvsgui -p 2 -b >/dev/null 2>&1 &
-# fi
-
-if [[ "$DO_PROFILE" -ge "1" ]]; then
- wget "http://132.230.8.113/profile/do.php?action=start" &
-fi
diff --git a/remote/modules/run-virt/data/opt/openslx/scripts/includes/start_windowmanager.inc b/remote/modules/run-virt/data/opt/openslx/scripts/includes/start_windowmanager.inc
index 940f4ff3..da43f341 100644
--- a/remote/modules/run-virt/data/opt/openslx/scripts/includes/start_windowmanager.inc
+++ b/remote/modules/run-virt/data/opt/openslx/scripts/includes/start_windowmanager.inc
@@ -5,6 +5,7 @@
# Some problems may arise with windows opening in background when
# using eg. vmware without a window manager.
+FOUND_WM=
for dm in openbox kwin xfwm4 metacity blackbox twm fvwm2 ; do
if which $dm >/dev/null 2>&1 ; then
if [ "$dm" = "fvwm2" ] ; then
@@ -15,6 +16,12 @@ for dm in openbox kwin xfwm4 metacity blackbox twm fvwm2 ; do
writelog "Starting ${dm}."
$dm >/dev/null 2>&1 &
fi
+ FOUND_WM=1
break
fi
done
+
+if [ -z "$FOUND_WM" ]; then
+ slxlog "virt-windowmanager" "Could not find any window manager to use!"
+ notify_user "Konnte keinen Window Manager finden. (Das ist schlecht!)"
+fi
diff --git a/remote/modules/run-virt/data/opt/openslx/scripts/includes/vmchooser_runvirt_functions.inc b/remote/modules/run-virt/data/opt/openslx/scripts/includes/vmchooser_runvirt_functions.inc
index 1f09b3d2..af9758e2 100644
--- a/remote/modules/run-virt/data/opt/openslx/scripts/includes/vmchooser_runvirt_functions.inc
+++ b/remote/modules/run-virt/data/opt/openslx/scripts/includes/vmchooser_runvirt_functions.inc
@@ -15,6 +15,34 @@ writelog() {
echo -e "$DATE: $@" >> "${LOGFILE}"
}
+notify_user() {
+ local TOPIC="$1"
+ shift
+ notify-send -u normal "$TOPIC" "$@"
+ writelog "Notify: **${TOPIC}**: $*"
+}
+
+error_user() {
+ local TOPIC="$1"
+ shift
+ local MSG TITLE BODY
+ if [ $# -gt 0 ]; then
+ MSG=" $TOPIC
+$*"
+ TITLE="$TOPIC"
+ BODY="$*"
+ else
+ MSG="$TOPIC"
+ TITLE="ERROR"
+ BODY="$TOPIC"
+ fi
+ /opt/openslx/cups/printergui --error "$MSG" && return
+ # printergui might not exist, try fallback here
+ # unfortunately, i can only think of notify+sleep right now
+ notify-send -u critical "$TITLE" "$BODY"
+ sleep 10
+}
+
# Clean exit will be called at the end of vmchooser-run_virt
cleanexit() {
sleep 1
diff --git a/remote/modules/run-virt/data/opt/openslx/scripts/systemd-run_virt_env b/remote/modules/run-virt/data/opt/openslx/scripts/systemd-run_virt_env
index b8236600..5f9036ba 100755
--- a/remote/modules/run-virt/data/opt/openslx/scripts/systemd-run_virt_env
+++ b/remote/modules/run-virt/data/opt/openslx/scripts/systemd-run_virt_env
@@ -44,12 +44,6 @@ chmod 0777 "${VMCHOOSER_DIR}/data/loopimg/fd.img"
mkdosfs "${VMCHOOSER_DIR}/data/loopimg/fd.img"
mount -n -t msdos -o loop,umask=000 "${VMCHOOSER_DIR}/data/loopimg/fd.img" "${VMCHOOSER_DIR}/fd-loop"
-#pvs integration
-#if [ $vmchooser_pvs -ne 0 ]; then
-# sed -i /usr/share/xsessions/default.desktop \
-# -e "s,vmchooser$,vmchooser --pvs,"
-#fi
-
# setup more scratch space for virtual machines, if configured
mkdir -p /tmp/virt /var/log/samba /run/samba
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 1e591389..5353d21a 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
@@ -56,8 +56,6 @@ if [ "$LEGACY" ]; then
source ${RUNVIRTINCLUDEDIR}/setup_vm_hypervisor.inc
# start a windowmanager for easier handling
source ${RUNVIRTINCLUDEDIR}/start_windowmanager.inc
- # Start poolvideoswitch if DO_PROFILE has been set (WARNING: fixed IP!)
- source ${RUNVIRTINCLUDEDIR}/start_pvs.inc
# Check if tcpsvd is running. Do not check immediately after spawning,
# as this could result in success even if it's not really working.
source ${RUNVIRTINCLUDEDIR}/check_lpd.inc
@@ -90,9 +88,6 @@ else
# Try to use dnbd3 to access the image, nfs/cifs fallback
source ${RUNVIRTINCLUDEDIR}/start_windowmanager.inc
- # Start poolvideoswitch if DO_PROFILE has been set (WARNING: fixed IP!)
- source ${RUNVIRTINCLUDEDIR}/start_pvs.inc
-
# Check if tcpsvd is running. Do not check immediately after spawning,
# as this could result in success even if it's not really working.
source ${RUNVIRTINCLUDEDIR}/check_lpd.inc