Workaround missing zip snapshot

At the moment, xenserver installation depends on github snapshots.
Unfortunately, git.openstack.org does not have that capability. This
fix includes:

 - Exit with error code, if a download fails
 - create proper urls, even if they are using the git protocol
 - set git base to github - so we are able to do snapshots

Fixes bug: 1259905

Change-Id: I8d0cf8bf8abb16ee0a4b138a6719409c75e7a146
This commit is contained in:
Mate Lakat 2013-12-11 13:41:54 +00:00
parent 085abd8eb7
commit 2781f3bfc3
4 changed files with 38 additions and 7 deletions

View File

@ -70,6 +70,9 @@ the `XENAPI_PASSWORD` must be your dom0 root password.
Of course, use real passwords if this machine is exposed. Of course, use real passwords if this machine is exposed.
cat > ./localrc <<EOF cat > ./localrc <<EOF
# At the moment, we depend on github's snapshot function.
GIT_BASE="http://github.com"
# Passwords # Passwords
# NOTE: these need to be specified, otherwise devstack will try # NOTE: these need to be specified, otherwise devstack will try
# to prompt for these passwords, blocking the install process. # to prompt for these passwords, blocking the install process.

View File

@ -1,5 +1,14 @@
#!/bin/bash #!/bin/bash
function die_with_error {
local err_msg
err_msg="$1"
echo "$err_msg" >&2
exit 1
}
function xapi_plugin_location { function xapi_plugin_location {
for PLUGIN_DIR in "/etc/xapi.d/plugins/" "/usr/lib/xcp/plugins/" "/usr/lib/xapi/plugins"; do for PLUGIN_DIR in "/etc/xapi.d/plugins/" "/usr/lib/xcp/plugins/" "/usr/lib/xapi/plugins"; do
if [ -d $PLUGIN_DIR ]; then if [ -d $PLUGIN_DIR ]; then
@ -11,7 +20,7 @@ function xapi_plugin_location {
} }
function zip_snapshot_location { function zip_snapshot_location {
echo $1 | sed "s:\.git$::;s:$:/zipball/$2:g" echo $1 | sed "s,^git://,http://,g;s:\.git$::;s:$:/zipball/$2:g"
} }
function create_directory_for_kernels { function create_directory_for_kernels {
@ -41,7 +50,9 @@ function extract_remote_zipball {
local EXTRACTED_FILES=$(mktemp -d) local EXTRACTED_FILES=$(mktemp -d)
{ {
wget -nv $ZIPBALL_URL -O $LOCAL_ZIPBALL --no-check-certificate if ! wget -nv $ZIPBALL_URL -O $LOCAL_ZIPBALL --no-check-certificate; then
die_with_error "Failed to download [$ZIPBALL_URL]"
fi
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

View File

@ -35,7 +35,7 @@ function mktemp {
function wget { function wget {
if [[ $@ =~ "failurl" ]]; then if [[ $@ =~ "failurl" ]]; then
exit 1 return 1
fi fi
echo "wget $@" >> $LIST_OF_ACTIONS echo "wget $@" >> $LIST_OF_ACTIONS
} }
@ -77,6 +77,10 @@ function [ {
exit 1 exit 1
} }
function die_with_error {
echo "$1" >> $DEAD_MESSAGES
}
function xe { function xe {
cat $XE_RESPONSE cat $XE_RESPONSE
{ {

View File

@ -29,6 +29,9 @@ function before_each_test {
XE_CALLS=$(mktemp) XE_CALLS=$(mktemp)
truncate -s 0 $XE_CALLS truncate -s 0 $XE_CALLS
DEAD_MESSAGES=$(mktemp)
truncate -s 0 $DEAD_MESSAGES
} }
# Teardown # Teardown
@ -64,6 +67,10 @@ function assert_xe_param {
grep -qe "^$1\$" $XE_CALLS grep -qe "^$1\$" $XE_CALLS
} }
function assert_died_with {
diff -u <(echo "$1") $DEAD_MESSAGES
}
function mock_out { function mock_out {
local FNNAME="$1" local FNNAME="$1"
local OUTPUT="$2" local OUTPUT="$2"
@ -109,10 +116,16 @@ function test_no_plugin_directory_found {
grep "[ -d /usr/lib/xcp/plugins/ ]" $LIST_OF_ACTIONS grep "[ -d /usr/lib/xcp/plugins/ ]" $LIST_OF_ACTIONS
} }
function test_zip_snapshot_location { function test_zip_snapshot_location_http {
diff \ diff \
<(zip_snapshot_location "git://git.openstack.org/openstack/nova.git" "master") \ <(zip_snapshot_location "http://github.com/openstack/nova.git" "master") \
<(echo "git://git.openstack.org/openstack/nova/zipball/master") <(echo "http://github.com/openstack/nova/zipball/master")
}
function test_zip_snapsot_location_git {
diff \
<(zip_snapshot_location "git://github.com/openstack/nova.git" "master") \
<(echo "http://github.com/openstack/nova/zipball/master")
} }
function test_create_directory_for_kernels { function test_create_directory_for_kernels {
@ -179,7 +192,7 @@ function test_extract_remote_zipball_wget_fail {
local IGNORE local IGNORE
IGNORE=$(. mocks && extract_remote_zipball "failurl") IGNORE=$(. mocks && extract_remote_zipball "failurl")
assert_previous_command_failed assert_died_with "Failed to download [failurl]"
} }
function test_find_nova_plugins { function test_find_nova_plugins {