#!/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

#!/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

function sftp_command {
    echo "$1" | sftp \
        -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
        uploader@images.rdoproject.org
}

sftp_command "rm /var/www/html/images/$RELEASE/rdo_trunk/$LINK_NAME"
sftp_command "ln -s $PROMOTED_HASH /var/www/html/images/$RELEASE/rdo_trunk/$LINK_NAME"

Fix the image promotion to create the proper links
Fix the image promotion to create the proper links

We altered all the release files and mirror scripts to exclude the
'stable' and 'testing' part of the path, but we missed the image
promotion script which is still using it.

This change fixes the the problem while also simplifying the image
promotion process.

Change-Id: I74cdfcbb075614a6c8072fe37b4fccbb7eff4af0
