Skip to content

Commit e6aeb59

Browse files
committed
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
1 parent f29569d commit e6aeb59

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

‎lib/trove‎

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,21 @@ function init_trove {
203203
# Initialize the trove database
204204
$TROVE_BIN_DIR/trove-manage db_sync
205205

206-
# Upload the trove-guest image to glance
207-
TROVE_GUEST_IMAGE_ID=$(upload_image $TROVE_GUEST_IMAGE_URL $TOKEN | grep ' id ' | get_field 2)
206+
# If no guest image is specified, skip remaining setup
207+
[ -z "$TROVE_GUEST_IMAGE_URL"] && return 0
208+
209+
# Find the glance id for the trove guest image
210+
# The image is uploaded by stack.sh -- see $IMAGE_URLS handling
211+
GUEST_IMAGE_NAME=$(basename "$TROVE_GUEST_IMAGE_URL")
212+
GUEST_IMAGE_NAME=${GUEST_IMAGE_NAME%.*}
213+
TROVE_GUEST_IMAGE_ID=$(glance --os-auth-token $TOKEN --os-image-url http://$GLANCE_HOSTPORT image-list | grep "${GUEST_IMAGE_NAME}" | get_field 1)
214+
if [ -z "$TROVE_GUEST_IMAGE_ID" ]; then
215+
# If no glance id is found, skip remaining setup
216+
echo "Datastore ${TROVE_DATASTORE_TYPE} will not be created: guest image ${GUEST_IMAGE_NAME} not found."
217+
return 1
218+
fi
208219

209-
# Initialize appropriate datastores / datastore versions
220+
# Now that we have the guest image id, initialize appropriate datastores / datastore versions
210221
$TROVE_BIN_DIR/trove-manage datastore_update "$TROVE_DATASTORE_TYPE" ""
211222
$TROVE_BIN_DIR/trove-manage datastore_version_update "$TROVE_DATASTORE_TYPE" "$TROVE_DATASTORE_VERSION" "$TROVE_DATASTORE_TYPE" \
212223
"$TROVE_GUEST_IMAGE_ID" "$TROVE_DATASTORE_PACKAGE" 1

‎stackrc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ fi
384384
# Trove needs a custom image for it's work
385385
if [[ "$ENABLED_SERVICES" =~ 'tr-api' ]]; then
386386
case "$VIRT_DRIVER" in
387-
libvirt|baremetal|ironic)
387+
libvirt|baremetal|ironic|xenapi)
388388
TROVE_GUEST_IMAGE_URL=${TROVE_GUEST_IMAGE_URL:-"http://tarballs.openstack.org/trove/images/ubuntu_mysql.qcow2/ubuntu_mysql.qcow2"}
389389
IMAGE_URLS+=",${TROVE_GUEST_IMAGE_URL}"
390390
;;

0 commit comments

Comments
 (0)