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
diff --git a/tools/xen/README.md b/tools/xen/README.md
index 06192ed..ee1abcc 100644
--- a/tools/xen/README.md
+++ b/tools/xen/README.md
@@ -70,6 +70,9 @@
Of course, use real passwords if this machine is exposed.
cat > ./localrc <<EOF
+ # At the moment, we depend on github's snapshot function.
+ GIT_BASE="http://github.com"
+
# Passwords
# NOTE: these need to be specified, otherwise devstack will try
# to prompt for these passwords, blocking the install process.
diff --git a/tools/xen/functions b/tools/xen/functions
index 563303d..97c56bc 100644
--- a/tools/xen/functions
+++ b/tools/xen/functions
@@ -1,5 +1,14 @@
#!/bin/bash
+function die_with_error {
+ local err_msg
+
+ err_msg="$1"
+
+ echo "$err_msg" >&2
+ exit 1
+}
+
function xapi_plugin_location {
for PLUGIN_DIR in "/etc/xapi.d/plugins/" "/usr/lib/xcp/plugins/" "/usr/lib/xapi/plugins"; do
if [ -d $PLUGIN_DIR ]; then
@@ -11,7 +20,7 @@
}
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 {
@@ -41,7 +50,9 @@
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
rm -f $LOCAL_ZIPBALL
} >&2
diff --git a/tools/xen/mocks b/tools/xen/mocks
index ec8679e..3b9b05c 100644
--- a/tools/xen/mocks
+++ b/tools/xen/mocks
@@ -35,7 +35,7 @@
function wget {
if [[ $@ =~ "failurl" ]]; then
- exit 1
+ return 1
fi
echo "wget $@" >> $LIST_OF_ACTIONS
}
@@ -77,6 +77,10 @@
exit 1
}
+function die_with_error {
+ echo "$1" >> $DEAD_MESSAGES
+}
+
function xe {
cat $XE_RESPONSE
{
diff --git a/tools/xen/test_functions.sh b/tools/xen/test_functions.sh
index 1455186..373d996 100755
--- a/tools/xen/test_functions.sh
+++ b/tools/xen/test_functions.sh
@@ -29,6 +29,9 @@
XE_CALLS=$(mktemp)
truncate -s 0 $XE_CALLS
+
+ DEAD_MESSAGES=$(mktemp)
+ truncate -s 0 $DEAD_MESSAGES
}
# Teardown
@@ -64,6 +67,10 @@
grep -qe "^$1\$" $XE_CALLS
}
+function assert_died_with {
+ diff -u <(echo "$1") $DEAD_MESSAGES
+}
+
function mock_out {
local FNNAME="$1"
local OUTPUT="$2"
@@ -109,10 +116,16 @@
grep "[ -d /usr/lib/xcp/plugins/ ]" $LIST_OF_ACTIONS
}
-function test_zip_snapshot_location {
+function test_zip_snapshot_location_http {
diff \
- <(zip_snapshot_location "git://git.openstack.org/openstack/nova.git" "master") \
- <(echo "git://git.openstack.org/openstack/nova/zipball/master")
+ <(zip_snapshot_location "http://github.com/openstack/nova.git" "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 {
@@ -179,7 +192,7 @@
local IGNORE
IGNORE=$(. mocks && extract_remote_zipball "failurl")
- assert_previous_command_failed
+ assert_died_with "Failed to download [failurl]"
}
function test_find_nova_plugins {