Browse code

xenapi: Exit immediately if zipball download fails

If install_os_domU.sh fails to download the Xapi plugins zipball
correctly it ignores the error and continues the installation.
This could damage the hypervisor's filesystem, as it may delete
files or overwrite them with garbage.

Change-Id: I9f6dc31b977592e2818e37b2d310c2a5dc477364
Fixes: bug #1195640

Euan Harris authored on 2013/07/11 00:30:31
Showing 3 changed files
... ...
@@ -40,11 +40,11 @@ function extract_remote_zipball {
40 40
     local LOCAL_ZIPBALL=$(mktemp)
41 41
     local EXTRACTED_FILES=$(mktemp -d)
42 42
 
43
-    (
43
+    {
44 44
         wget -nv $ZIPBALL_URL -O $LOCAL_ZIPBALL --no-check-certificate
45 45
         unzip -q -o $LOCAL_ZIPBALL -d $EXTRACTED_FILES
46 46
         rm -f $LOCAL_ZIPBALL
47
-    ) >&2
47
+    } >&2
48 48
 
49 49
     echo "$EXTRACTED_FILES"
50 50
 }
... ...
@@ -34,6 +34,9 @@ function mktemp {
34 34
 }
35 35
 
36 36
 function wget {
37
+    if [[ $@ =~ "failurl" ]]; then
38
+        exit 1
39
+    fi
37 40
     echo "wget $@" >> $LIST_OF_ACTIONS
38 41
 }
39 42
 
... ...
@@ -173,6 +173,15 @@ EOF
173 173
     [ "$RESULT" = "tempdir" ]
174 174
 }
175 175
 
176
+function test_extract_remote_zipball_wget_fail {
177
+    set +e
178
+
179
+    local IGNORE
180
+    IGNORE=$(. mocks && extract_remote_zipball "failurl")
181
+
182
+    assert_previous_command_failed
183
+}
184
+
176 185
 function test_find_nova_plugins {
177 186
     local tmpdir=$(mktemp -d)
178 187