devstack/tools/xen/mocks
Mate Lakat 2781f3bfc3 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
2014-01-07 10:20:37 +00:00

93 lines
1.7 KiB
Bash

#!/bin/bash
test ! -e "$LIST_OF_ACTIONS" && {
echo "Mocking is not set up properly."
echo "LIST_OF_ACTIONS should point to an existing file."
exit 1
}
test ! -e "$LIST_OF_DIRECTORIES" && {
echo "Mocking is not set up properly."
echo "LIST_OF_DIRECTORIES should point to an existing file."
exit 1
}
test ! -e "$XE_RESPONSE" && {
echo "Mocking is not set up properly."
echo "XE_RESPONSE should point to an existing file."
exit 1
}
test ! -e "$XE_CALLS" && {
echo "Mocking is not set up properly."
echo "XE_CALLS should point to an existing file."
exit 1
}
function mktemp {
if test "${1:-}" = "-d";
then
echo "tempdir"
else
echo "tempfile"
fi
}
function wget {
if [[ $@ =~ "failurl" ]]; then
return 1
fi
echo "wget $@" >> $LIST_OF_ACTIONS
}
function mkdir {
if test "${1:-}" = "-p";
then
echo "$2" >> $LIST_OF_DIRECTORIES
fi
}
function unzip {
echo "Random rubbish from unzip"
echo "unzip $@" >> $LIST_OF_ACTIONS
}
function rm {
echo "rm $@" >> $LIST_OF_ACTIONS
}
function ln {
echo "ln $@" >> $LIST_OF_ACTIONS
}
function [ {
if test "${1:-}" = "-d";
then
echo "[ $@" >> $LIST_OF_ACTIONS
for directory in $(cat $LIST_OF_DIRECTORIES)
do
if test "$directory" = "$2"
then
return 0
fi
done
return 1
fi
echo "Mock test does not implement the requested function: ${1:-}"
exit 1
}
function die_with_error {
echo "$1" >> $DEAD_MESSAGES
}
function xe {
cat $XE_RESPONSE
{
for i in $(seq "$#")
do
eval "echo \"\$$i\""
done
} >> $XE_CALLS
}