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
This commit is contained in:
Euan Harris 2013-07-10 16:30:31 +01:00
parent 314ae87a91
commit 6f0017161f
3 changed files with 14 additions and 2 deletions

View File

@ -40,11 +40,11 @@ function extract_remote_zipball {
local LOCAL_ZIPBALL=$(mktemp) local LOCAL_ZIPBALL=$(mktemp)
local EXTRACTED_FILES=$(mktemp -d) local EXTRACTED_FILES=$(mktemp -d)
( {
wget -nv $ZIPBALL_URL -O $LOCAL_ZIPBALL --no-check-certificate wget -nv $ZIPBALL_URL -O $LOCAL_ZIPBALL --no-check-certificate
unzip -q -o $LOCAL_ZIPBALL -d $EXTRACTED_FILES unzip -q -o $LOCAL_ZIPBALL -d $EXTRACTED_FILES
rm -f $LOCAL_ZIPBALL rm -f $LOCAL_ZIPBALL
) >&2 } >&2
echo "$EXTRACTED_FILES" echo "$EXTRACTED_FILES"
} }

View File

@ -34,6 +34,9 @@ function mktemp {
} }
function wget { function wget {
if [[ $@ =~ "failurl" ]]; then
exit 1
fi
echo "wget $@" >> $LIST_OF_ACTIONS echo "wget $@" >> $LIST_OF_ACTIONS
} }

View File

@ -173,6 +173,15 @@ EOF
[ "$RESULT" = "tempdir" ] [ "$RESULT" = "tempdir" ]
} }
function test_extract_remote_zipball_wget_fail {
set +e
local IGNORE
IGNORE=$(. mocks && extract_remote_zipball "failurl")
assert_previous_command_failed
}
function test_find_nova_plugins { function test_find_nova_plugins {
local tmpdir=$(mktemp -d) local tmpdir=$(mktemp -d)