From e6aeb5912bec29eecd18852c75f49ddd868c62f0 Mon Sep 17 00:00:00 2001 From: Greg Lucas Date: Wed, 9 Jul 2014 13:30:38 -0400 Subject: [PATCH] Avoid uploading trove guest image twice When creating the trove datastore, get the guest image id from glance. The trove guest image gets uploaded along with all the other images specified in $IMAGE_URLS. It is not necessary to upload it again in init_trove. Also: add xenapi case to stackrc for trove guest image Closes-Bug: 1339818 Change-Id: I2973af27ab93182fcd674f874daba1036d767d52 --- lib/trove | 17 ++++++++++++++--- stackrc | 2 +- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/lib/trove b/lib/trove index 2552745209..05ee4ef2d8 100644 --- a/lib/trove +++ b/lib/trove @@ -203,10 +203,21 @@ function init_trove { # Initialize the trove database $TROVE_BIN_DIR/trove-manage db_sync - # Upload the trove-guest image to glance - TROVE_GUEST_IMAGE_ID=$(upload_image $TROVE_GUEST_IMAGE_URL $TOKEN | grep ' id ' | get_field 2) + # If no guest image is specified, skip remaining setup + [ -z "$TROVE_GUEST_IMAGE_URL"] && return 0 - # Initialize appropriate datastores / datastore versions + # Find the glance id for the trove guest image + # The image is uploaded by stack.sh -- see $IMAGE_URLS handling + GUEST_IMAGE_NAME=$(basename "$TROVE_GUEST_IMAGE_URL") + GUEST_IMAGE_NAME=${GUEST_IMAGE_NAME%.*} + TROVE_GUEST_IMAGE_ID=$(glance --os-auth-token $TOKEN --os-image-url http://$GLANCE_HOSTPORT image-list | grep "${GUEST_IMAGE_NAME}" | get_field 1) + if [ -z "$TROVE_GUEST_IMAGE_ID" ]; then + # If no glance id is found, skip remaining setup + echo "Datastore ${TROVE_DATASTORE_TYPE} will not be created: guest image ${GUEST_IMAGE_NAME} not found." + return 1 + fi + + # Now that we have the guest image id, initialize appropriate datastores / datastore versions $TROVE_BIN_DIR/trove-manage datastore_update "$TROVE_DATASTORE_TYPE" "" $TROVE_BIN_DIR/trove-manage datastore_version_update "$TROVE_DATASTORE_TYPE" "$TROVE_DATASTORE_VERSION" "$TROVE_DATASTORE_TYPE" \ "$TROVE_GUEST_IMAGE_ID" "$TROVE_DATASTORE_PACKAGE" 1 diff --git a/stackrc b/stackrc index 6af3db782b..ff6c9d25e8 100644 --- a/stackrc +++ b/stackrc @@ -384,7 +384,7 @@ fi # Trove needs a custom image for it's work if [[ "$ENABLED_SERVICES" =~ 'tr-api' ]]; then case "$VIRT_DRIVER" in - libvirt|baremetal|ironic) + libvirt|baremetal|ironic|xenapi) TROVE_GUEST_IMAGE_URL=${TROVE_GUEST_IMAGE_URL:-"http://tarballs.openstack.org/trove/images/ubuntu_mysql.qcow2/ubuntu_mysql.qcow2"} IMAGE_URLS+=",${TROVE_GUEST_IMAGE_URL}" ;;