diff options
author | Simon Rettberg | 2022-07-06 16:42:21 +0200 |
---|---|---|
committer | Simon Rettberg | 2022-07-06 16:42:21 +0200 |
commit | 7313fad5445e1bb136ddb13c6b337b67a314049f (patch) | |
tree | 7d3727f6648f773b2f2bfffea4bf92a5ccb92ebf /core/modules/speedcheck | |
parent | [speedcheck] Add automatic mode for dnbd3 (diff) | |
download | mltk-7313fad5445e1bb136ddb13c6b337b67a314049f.tar.gz mltk-7313fad5445e1bb136ddb13c6b337b67a314049f.tar.xz mltk-7313fad5445e1bb136ddb13c6b337b67a314049f.zip |
[speedcheck] More tweaks and error checks to do the right thing
Diffstat (limited to 'core/modules/speedcheck')
-rwxr-xr-x | core/modules/speedcheck/data/opt/openslx/bin/image_speedcheck | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/core/modules/speedcheck/data/opt/openslx/bin/image_speedcheck b/core/modules/speedcheck/data/opt/openslx/bin/image_speedcheck index 8d66c929..7cfe9c80 100755 --- a/core/modules/speedcheck/data/opt/openslx/bin/image_speedcheck +++ b/core/modules/speedcheck/data/opt/openslx/bin/image_speedcheck @@ -47,29 +47,50 @@ if [ -z "$file" ]; then . /opt/openslx/config if mountpoint /mnt/vmstore; then file=$( find /mnt/vmstore -type f -printf "%s\t%p\n" | sort -n | tail -n 1 | awk '{print $2}' ) - nfs=1 + [ -z "$SLX_VM_DNBD3" ] && nfs=1 elif [ -s "/tmp/vmchooser-benchmark" ] || [ -s "/tmp/vmchooser2/vmchooser2.xml" ] \ - || curl -m 5 -L "$SLX_VMCHOOSER_BASE_URL/list" > "/tmp/vmchooser-benchmark"; then - xml="/tmp/vmchooser-benchmark" - [ -s "$xml" ] || xml="/tmp/vmchooser2/vmchooser2.xml" - file="$( xmlstarlet sel -T -t -v "//settings/eintrag/image_name/@param" "$xml" | head -n 1 )" - nfs= + || curl -m 5 -L "$SLX_VMCHOOSER_BASE_URL/list" > "/tmp/vmchooser-benchmark"; then + xml="/tmp/vmchooser-benchmark" + [ -s "$xml" ] || xml="/tmp/vmchooser2/vmchooser2.xml" + file="$( xmlstarlet sel -T -t -v "//settings/eintrag/image_name/@param" "$xml" | head -n 1 )" + if [ -n "$nfs" ]; then + showmsg "--nfs given, but NFS not enabled/mounted." + exit 1 + fi else showmsg "Could not automatically determine any image name, specify one via --file as relative path" exit 1 fi + rid=0 else + # Extract rid from name:rid format (if any), then remove from $file + rid="${file##*:}" + if [ "$rid" = "$file" ] || ! [ "$rid" -gt 0 ]; then + # No rid in filename + rid=0 + else + # Found rid, remove from $file + file="${file%:*}" + fi if [ -n "$nfs" ]; then file="$( find /mnt/vmstore/"$file"* -type f -printf "%s\t%p\n" | sort -n | tail -n 1 | awk '{print $2}' )" fi fi +# Common intermediate format; relative to mount point (if any), get rid of any ./ prefix +file="${file#/mnt/vmstore/}" +file="${file#/}" +file="${file#.}" +file="${file#/}" + if [ -z "$file" ]; then showmsg "Cannot test, no image found" exit 1 fi if [ -n "$nfs" ]; then + # For NFS, make absolute again + file="/mnt/vmstore/${file}" if ! [ -s "$file" ]; then showmsg "Cannot access '$file'" exit 1 @@ -91,11 +112,6 @@ else fi mountpoint="/tmp/speedtest-$$-$RANDOM" mkdir "$mountpoint" - rid="${file##*:}" - if [ "$rid" = "$file" ] || ! [ "$rid" -gt 0 ]; then - rid=0 - fi - file="${file%:*}" if ! dnbd3-fuse $sticky -h "$servers" -i "$file" -r "$rid" "$mountpoint"; then showmsg "Cannot start dnbd3-fuse from $servers" exit 1 |