Merge "lib/tempest: add wait for Glance image import"
This commit is contained in:
commit
2f889954ce
73
lib/tempest
73
lib/tempest
@ -71,6 +71,17 @@ TEMPEST_VOLUME_VENDOR=${TEMPEST_VOLUME_VENDOR:-$TEMPEST_DEFAULT_VOLUME_VENDOR}
|
|||||||
TEMPEST_DEFAULT_STORAGE_PROTOCOL="iSCSI"
|
TEMPEST_DEFAULT_STORAGE_PROTOCOL="iSCSI"
|
||||||
TEMPEST_STORAGE_PROTOCOL=${TEMPEST_STORAGE_PROTOCOL:-$TEMPEST_DEFAULT_STORAGE_PROTOCOL}
|
TEMPEST_STORAGE_PROTOCOL=${TEMPEST_STORAGE_PROTOCOL:-$TEMPEST_DEFAULT_STORAGE_PROTOCOL}
|
||||||
|
|
||||||
|
# Glance/Image variables
|
||||||
|
# When Glance image import is enabled, image creation is asynchronous and images
|
||||||
|
# may not yet be active when tempest looks for them. In that case, we poll
|
||||||
|
# Glance every TEMPEST_GLANCE_IMPORT_POLL_INTERVAL seconds for the number of
|
||||||
|
# times specified by TEMPEST_GLANCE_IMPORT_POLL_LIMIT. If you are importing
|
||||||
|
# multiple images, set TEMPEST_GLANCE_IMAGE_COUNT so the poller does not quit
|
||||||
|
# too early (though it will not exceed the polling limit).
|
||||||
|
TEMPEST_GLANCE_IMPORT_POLL_INTERVAL=${TEMPEST_GLANCE_IMPORT_POLL_INTERVAL:-1}
|
||||||
|
TEMPEST_GLANCE_IMPORT_POLL_LIMIT=${TEMPEST_GLANCE_IMPORT_POLL_LIMIT:-12}
|
||||||
|
TEMPEST_GLANCE_IMAGE_COUNT=${TEMPEST_GLANCE_IMAGE_COUNT:-1}
|
||||||
|
|
||||||
# Neutron/Network variables
|
# Neutron/Network variables
|
||||||
IPV6_ENABLED=$(trueorfalse True IPV6_ENABLED)
|
IPV6_ENABLED=$(trueorfalse True IPV6_ENABLED)
|
||||||
IPV6_SUBNET_ATTRIBUTES_ENABLED=$(trueorfalse True IPV6_SUBNET_ATTRIBUTES_ENABLED)
|
IPV6_SUBNET_ATTRIBUTES_ENABLED=$(trueorfalse True IPV6_SUBNET_ATTRIBUTES_ENABLED)
|
||||||
@ -127,6 +138,48 @@ function set_tempest_venv_constraints {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Makes a call to glance to get a list of active images, ignoring
|
||||||
|
# ramdisk and kernel images. Takes 3 arguments, an array and two
|
||||||
|
# variables. The array will contain the list of active image UUIDs;
|
||||||
|
# if an image with ``DEFAULT_IMAGE_NAME`` is found, its UUID will be
|
||||||
|
# set as the value of *both* other parameters.
|
||||||
|
function get_active_images {
|
||||||
|
declare -n img_array=$1
|
||||||
|
declare -n img_id=$2
|
||||||
|
declare -n img_id_alt=$3
|
||||||
|
|
||||||
|
# start with a fresh array in case we are called multiple times
|
||||||
|
img_array=()
|
||||||
|
|
||||||
|
while read -r IMAGE_NAME IMAGE_UUID; do
|
||||||
|
if [ "$IMAGE_NAME" = "$DEFAULT_IMAGE_NAME" ]; then
|
||||||
|
img_id="$IMAGE_UUID"
|
||||||
|
img_id_alt="$IMAGE_UUID"
|
||||||
|
fi
|
||||||
|
img_array+=($IMAGE_UUID)
|
||||||
|
done < <(openstack --os-cloud devstack-admin image list --property status=active | awk -F'|' '!/^(+--)|ID|aki|ari/ { print $3,$2 }')
|
||||||
|
}
|
||||||
|
|
||||||
|
function poll_glance_images {
|
||||||
|
declare -n image_array=$1
|
||||||
|
declare -n image_id=$2
|
||||||
|
declare -n image_id_alt=$3
|
||||||
|
local -i poll_count
|
||||||
|
|
||||||
|
poll_count=$TEMPEST_GLANCE_IMPORT_POLL_LIMIT
|
||||||
|
while (( poll_count-- > 0 )) ; do
|
||||||
|
sleep $TEMPEST_GLANCE_IMPORT_POLL_INTERVAL
|
||||||
|
get_active_images image_array image_id image_id_alt
|
||||||
|
if (( ${#image_array[*]} >= $TEMPEST_GLANCE_IMAGE_COUNT )) ; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
local msg
|
||||||
|
msg="Polling limit of $TEMPEST_GLANCE_IMPORT_POLL_LIMIT exceeded; "
|
||||||
|
msg+="poll interval was $TEMPEST_GLANCE_IMPORT_POLL_INTERVAL sec"
|
||||||
|
warn $LINENO "$msg"
|
||||||
|
}
|
||||||
|
|
||||||
# configure_tempest() - Set config files, create data dirs, etc
|
# configure_tempest() - Set config files, create data dirs, etc
|
||||||
function configure_tempest {
|
function configure_tempest {
|
||||||
if [[ "$INSTALL_TEMPEST" == "True" ]]; then
|
if [[ "$INSTALL_TEMPEST" == "True" ]]; then
|
||||||
@ -168,13 +221,21 @@ function configure_tempest {
|
|||||||
declare -a images
|
declare -a images
|
||||||
|
|
||||||
if is_service_enabled glance; then
|
if is_service_enabled glance; then
|
||||||
while read -r IMAGE_NAME IMAGE_UUID; do
|
get_active_images images image_uuid image_uuid_alt
|
||||||
if [ "$IMAGE_NAME" = "$DEFAULT_IMAGE_NAME" ]; then
|
|
||||||
image_uuid="$IMAGE_UUID"
|
if (( ${#images[*]} < $TEMPEST_GLANCE_IMAGE_COUNT )); then
|
||||||
image_uuid_alt="$IMAGE_UUID"
|
# Glance image import is asynchronous and may be configured
|
||||||
|
# to do image conversion. If image import is being used,
|
||||||
|
# it's possible that this code is being executed before the
|
||||||
|
# import has completed and there may be no active images yet.
|
||||||
|
if [[ "$GLANCE_USE_IMPORT_WORKFLOW" == "True" ]]; then
|
||||||
|
poll_glance_images images image_uuid image_uuid_alt
|
||||||
|
if (( ${#images[*]} < $TEMPEST_GLANCE_IMAGE_COUNT )); then
|
||||||
|
echo "Only found ${#images[*]} image(s), was looking for $TEMPEST_GLANCE_IMAGE_COUNT"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
images+=($IMAGE_UUID)
|
|
||||||
done < <(openstack --os-cloud devstack-admin image list --property status=active | awk -F'|' '!/^(+--)|ID|aki|ari/ { print $3,$2 }')
|
|
||||||
|
|
||||||
case "${#images[*]}" in
|
case "${#images[*]}" in
|
||||||
0)
|
0)
|
||||||
|
Loading…
Reference in New Issue
Block a user