summaryrefslogtreecommitdiffstats
path: root/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/vmchooser_runvirt_functions.inc
diff options
context:
space:
mode:
authorJonathan Bauer2018-12-12 14:27:04 +0100
committerJonathan Bauer2018-12-12 14:27:04 +0100
commit227dc993f09592b57320130a0d6231fc2b60550b (patch)
tree4dc9057f7d5be4d02c28197725a39c7cd4ba2d9b /core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/vmchooser_runvirt_functions.inc
parent[vmchooser] respect new urls params from resource_urls.conf (diff)
downloadmltk-227dc993f09592b57320130a0d6231fc2b60550b.tar.gz
mltk-227dc993f09592b57320130a0d6231fc2b60550b.tar.xz
mltk-227dc993f09592b57320130a0d6231fc2b60550b.zip
[run-virt] rework resource management
Diffstat (limited to 'core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/vmchooser_runvirt_functions.inc')
-rw-r--r--core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/vmchooser_runvirt_functions.inc19
1 files changed, 19 insertions, 0 deletions
diff --git a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/vmchooser_runvirt_functions.inc b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/vmchooser_runvirt_functions.inc
index 54aceee5..b4f87d11 100644
--- a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/vmchooser_runvirt_functions.inc
+++ b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/vmchooser_runvirt_functions.inc
@@ -501,3 +501,22 @@ detect_cpu_flag() {
done
grep -m1 -qE '^flags\s*:.*\b('"${flags}"')\b' /proc/cpuinfo
}
+
+# downloads the given URL to given file
+download_file() {
+ [ $# -ne 2 ] && writelog "Usage: $0 <url> <path>." && return 1
+ local _url="$1"
+ local _path="$2"
+ echo "Downloading '$_url' to '$_path'..."
+ if ! wget -T 6 -O "$_path" "$_url" 2> /dev/null >&2; then
+ writelog "Downloading '$_url' failed."
+ return 1
+ fi
+ if [ ! -s "$_path" ]; then
+ # zero bytes, log and ignore
+ writelog "Downloaded resource from '$_url' has zero bytes."
+ return 1
+ fi
+ return 0
+}
+