Skip to content

Add image share script #624

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 17, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions dev/image-share.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env bash
# Share images from one project to another
#
# usage:
# share-images SOURCE_PROJECT DEST_PROJECT IMAGE_NAME
#
# NB: This requires a clouds.yaml file which uses project names as cloud keys

set -euo pipefail

SOURCE=$1
DEST=$2
IMAGE_NAME=$3

export OS_CLOUD=$SOURCE
SOURCE_PROJECT=$(openstack project show -c id -f value $SOURCE)
export OS_CLOUD=$DEST
DEST_PROJECT=$(openstack project show -c id -f value $DEST)
export OS_CLOUD=$SOURCE
IMAGE=$(openstack image show -c id -f value $IMAGE_NAME)

echo "Sharing $IMAGE_NAME ($IMAGE) from $SOURCE ($SOURCE_PROJECT) ..."
openstack image set --shared $IMAGE
echo "Adding destination project $DEST ($DEST_PROJECT) ..."
openstack image add project $IMAGE $DEST_PROJECT

export OS_CLOUD=$DEST
echo "Accepting share ..."
openstack image set --accept $IMAGE
echo "Done"