#!/bin/bash
# Script to promote qcow images on rdoproject (images.rdoproject.org)
# Usage: promote-images.sh <release> <promoted_hash> <link_name>
# Example: promote-images.sh master f442a3aa35981c3d6d7e312599dde2a1b1d202c9_0468cca4 current-tripleo

set -eux

RELEASE=$1
PROMOTED_HASH=$2
LINK_NAME=$3

image_path="$RELEASE/rdo_trunk/$LINK_NAME"
ssh_cmd='ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null'

# Create local symlink
pushd /tmp/
mkdir -p $PROMOTED_HASH
ln -s $PROMOTED_HASH stable

# Delete old stable symlink and old images
# TODO(gcerami) we are not deleting old images anymore to give time to the downstream server to download and cache the images
#mkdir $LINK_NAME
#rsync -av --delete --exclude $PROMOTED_HASH $LINK_NAME/ uploader@images.rdoproject.org:/var/www/html/images/$image_path/

# push symlink to RDO file server
rsync -av stable uploader@images.rdoproject.org:/var/www/html/images/$image_path/stable
rmdir $PROMOTED_HASH
popd

#!/bin/bash
# Script to promote qcow images on rdoproject (images.rdoproject.org)
# Usage: promote-images.sh <release> <promoted_hash> <link_name>
# Example: promote-images.sh master f442a3aa35981c3d6d7e312599dde2a1b1d202c9_0468cca4 current-tripleo

set -eux

RELEASE=$1
PROMOTED_HASH=$2
LINK_NAME=$3

image_path="$RELEASE/rdo_trunk/$LINK_NAME"
ssh_cmd='ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null'

# Create local symlink
pushd $(mktemp -d)
mkdir -p $PROMOTED_HASH
ln -s $PROMOTED_HASH stable

# Delete old stable symlink and old images
# TODO(gcerami) we are not deleting old images anymore to give time to the downstream server to download and cache the images
#mkdir $LINK_NAME
#rsync -av --delete --exclude $PROMOTED_HASH $LINK_NAME/ uploader@images.rdoproject.org:/var/www/html/images/$image_path/

# push symlink to RDO file server
rsync -av stable uploader@images.rdoproject.org:/var/www/html/images/$image_path/stable
rmdir $PROMOTED_HASH
popd

Use unique temp dir for image promotion
Use unique temp dir for image promotion

If we use just /tmp/ for creating our symlinks we will need to
delete stuff prior to trying to create it. Instead, we can just use
a clean temp dir each time.

Change-Id: I3b3d7b6626b1ed3d0acc7947094f96ff6d833751
Related-Bug: 1722640
