set -e
echo ======== UPLOAD CLOUD IMAGES
source /tmp/hash_info.sh

# If I try to build images as upstream ( in /home/jenkins ) something will go wrong
# we leave quickstart build in the default location. it proved to work
pushd /var/lib/oooq-images/$RELEASE

ls *.tar
chmod 600 $SSH_KEY
export RSYNC_RSH="ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i $SSH_KEY"
rsync_cmd="rsync --verbose --archive --delay-updates --relative"
UPLOAD_URL=uploader@images.rdoproject.org:/var/www/html/images/$RELEASE/delorean/tripleo-upstream
mkdir $FULL_HASH
mv overcloud-full.tar overcloud-full.tar.md5 $FULL_HASH
mv ironic-python-agent.tar $FULL_HASH/ipa_images.tar
mv ironic-python-agent.tar.md5 $FULL_HASH/ipa_images.tar.md5

$rsync_cmd $FULL_HASH $UPLOAD_URL
$rsync_cmd --delete --include 'testing**' --exclude '*' ./ $UPLOAD_URL/
# push testing symlink so sub-jobs know what to test
# but only after all images are uploaded
ln -s $FULL_HASH testing
rsync -av testing $UPLOAD_URL/

popd
echo ======== UPLOAD CLOUD IMAGES COMPLETE

set -e
echo ======== UPLOAD CLOUD IMAGES

export FULL_HASH=$(grep -o -E '[0-9a-f]{40}_[0-9a-f]{8}' < /etc/yum.repos.d/delorean.repo)

# If I try to build images as upstream ( in /home/jenkins ) something will go wrong
# we leave quickstart build in the default location. it proved to work
pushd /var/lib/oooq-images/$RELEASE

ls *.tar
chmod 600 $SSH_KEY
export RSYNC_RSH="ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i $SSH_KEY"
rsync_cmd="rsync --verbose --archive --delay-updates --relative"
UPLOAD_URL=uploader@images.rdoproject.org:/var/www/html/images/$RELEASE/delorean/tripleo-upstream
mkdir $FULL_HASH
mv overcloud-full.tar overcloud-full.tar.md5 $FULL_HASH
mv ironic-python-agent.tar $FULL_HASH/ipa_images.tar
mv ironic-python-agent.tar.md5 $FULL_HASH/ipa_images.tar.md5

$rsync_cmd $FULL_HASH $UPLOAD_URL
$rsync_cmd --delete --include 'testing**' --exclude '*' ./ $UPLOAD_URL/
# push testing symlink so sub-jobs know what to test
# but only after all images are uploaded
ln -s $FULL_HASH testing
rsync -av testing $UPLOAD_URL/

popd
echo ======== UPLOAD CLOUD IMAGES COMPLETE

Fix image upload script to not depend on /tmp/hash_info.sh
Fix image upload script to not depend on /tmp/hash_info.sh

Since we moved image upload into a job that is not creating
/tmp/hash_info.sh we can not rely on that to get the FULL_HASH
var.

However, since that is the only var which we need from that script,
we can just get it from the delorean repo on the host.

Change-Id: Iea404381b3a092f82438b152a9fd189fab2ab5f7
