diff --git a/lib/tempest b/lib/tempest index 25dc171fe2..9e025a1096 100644 --- a/lib/tempest +++ b/lib/tempest @@ -111,34 +111,36 @@ function configure_tempest { # ... Also ensure we only take active images, so we don't get snapshots in process declare -a images - while read -r IMAGE_NAME IMAGE_UUID; do - if [ "$IMAGE_NAME" = "$DEFAULT_IMAGE_NAME" ]; then - image_uuid="$IMAGE_UUID" - image_uuid_alt="$IMAGE_UUID" - fi - images+=($IMAGE_UUID) - # TODO(stevemar): update this command to use openstackclient's `openstack image list` - # when it supports listing by status. - done < <(glance image-list --status=active | awk -F'|' '!/^(+--)|ID|aki|ari/ { print $3,$2 }') + if is_service_enabled glance; then + while read -r IMAGE_NAME IMAGE_UUID; do + if [ "$IMAGE_NAME" = "$DEFAULT_IMAGE_NAME" ]; then + image_uuid="$IMAGE_UUID" + image_uuid_alt="$IMAGE_UUID" + fi + images+=($IMAGE_UUID) + # TODO(stevemar): update this command to use openstackclient's `openstack image list` + # when it supports listing by status. + done < <(glance image-list --status=active | awk -F'|' '!/^(+--)|ID|aki|ari/ { print $3,$2 }') - case "${#images[*]}" in - 0) - echo "Found no valid images to use!" - exit 1 - ;; - 1) - if [ -z "$image_uuid" ]; then - image_uuid=${images[0]} - image_uuid_alt=${images[0]} - fi - ;; - *) - if [ -z "$image_uuid" ]; then - image_uuid=${images[0]} - image_uuid_alt=${images[1]} - fi - ;; - esac + case "${#images[*]}" in + 0) + echo "Found no valid images to use!" + exit 1 + ;; + 1) + if [ -z "$image_uuid" ]; then + image_uuid=${images[0]} + image_uuid_alt=${images[0]} + fi + ;; + *) + if [ -z "$image_uuid" ]; then + image_uuid=${images[0]} + image_uuid_alt=${images[1]} + fi + ;; + esac + fi # Create tempest.conf from tempest.conf.sample # copy every time, because the image UUIDS are going to change @@ -162,63 +164,65 @@ function configure_tempest { ALT_TENANT_NAME=${ALT_TENANT_NAME:-alt_demo} ADMIN_TENANT_ID=$(openstack project list | awk "/ admin / { print \$2 }") - # If the ``DEFAULT_INSTANCE_TYPE`` not declared, use the new behavior - # Tempest creates instane types for himself - if [[ -z "$DEFAULT_INSTANCE_TYPE" ]]; then - available_flavors=$(nova flavor-list) - if [[ ! ( $available_flavors =~ 'm1.nano' ) ]]; then - if is_arch "ppc64"; then - # qemu needs at least 128MB of memory to boot on ppc64 - nova flavor-create m1.nano 42 128 0 1 - else - nova flavor-create m1.nano 42 64 0 1 + if is_service_enabled nova; then + # If the ``DEFAULT_INSTANCE_TYPE`` not declared, use the new behavior + # Tempest creates instane types for himself + if [[ -z "$DEFAULT_INSTANCE_TYPE" ]]; then + available_flavors=$(nova flavor-list) + if [[ ! ( $available_flavors =~ 'm1.nano' ) ]]; then + if is_arch "ppc64"; then + # qemu needs at least 128MB of memory to boot on ppc64 + nova flavor-create m1.nano 42 128 0 1 + else + nova flavor-create m1.nano 42 64 0 1 + fi fi - fi - flavor_ref=42 - boto_instance_type=m1.nano - if [[ ! ( $available_flavors =~ 'm1.micro' ) ]]; then - if is_arch "ppc64"; then - nova flavor-create m1.micro 84 256 0 1 - else - nova flavor-create m1.micro 84 128 0 1 + flavor_ref=42 + boto_instance_type=m1.nano + if [[ ! ( $available_flavors =~ 'm1.micro' ) ]]; then + if is_arch "ppc64"; then + nova flavor-create m1.micro 84 256 0 1 + else + nova flavor-create m1.micro 84 128 0 1 + fi fi - fi - flavor_ref_alt=84 - else - # Check Nova for existing flavors and, if set, look for the - # ``DEFAULT_INSTANCE_TYPE`` and use that. - boto_instance_type=$DEFAULT_INSTANCE_TYPE - flavor_lines=`nova flavor-list` - IFS=$'\r\n' - flavors="" - for line in $flavor_lines; do - f=$(echo $line | awk "/ $DEFAULT_INSTANCE_TYPE / { print \$2 }") - flavors="$flavors $f" - done + flavor_ref_alt=84 + else + # Check Nova for existing flavors and, if set, look for the + # ``DEFAULT_INSTANCE_TYPE`` and use that. + boto_instance_type=$DEFAULT_INSTANCE_TYPE + flavor_lines=`nova flavor-list` + IFS=$'\r\n' + flavors="" + for line in $flavor_lines; do + f=$(echo $line | awk "/ $DEFAULT_INSTANCE_TYPE / { print \$2 }") + flavors="$flavors $f" + done - for line in $flavor_lines; do - flavors="$flavors `echo $line | grep -v "^\(|\s*ID\|+--\)" | cut -d' ' -f2`" - done + for line in $flavor_lines; do + flavors="$flavors `echo $line | grep -v "^\(|\s*ID\|+--\)" | cut -d' ' -f2`" + done - IFS=" " - flavors=($flavors) - num_flavors=${#flavors[*]} - echo "Found $num_flavors flavors" - if [[ $num_flavors -eq 0 ]]; then - echo "Found no valid flavors to use!" - exit 1 - fi - flavor_ref=${flavors[0]} - flavor_ref_alt=$flavor_ref - - # ensure flavor_ref and flavor_ref_alt have different values - # some resize instance in tempest tests depends on this. - for f in ${flavors[@]:1}; do - if [[ $f -ne $flavor_ref ]]; then - flavor_ref_alt=$f - break + IFS=" " + flavors=($flavors) + num_flavors=${#flavors[*]} + echo "Found $num_flavors flavors" + if [[ $num_flavors -eq 0 ]]; then + echo "Found no valid flavors to use!" + exit 1 fi - done + flavor_ref=${flavors[0]} + flavor_ref_alt=$flavor_ref + + # ensure flavor_ref and flavor_ref_alt have different values + # some resize instance in tempest tests depends on this. + for f in ${flavors[@]:1}; do + if [[ $f -ne $flavor_ref ]]; then + flavor_ref_alt=$f + break + fi + done + fi fi if [ "$Q_USE_NAMESPACE" != "False" ]; then @@ -463,20 +467,22 @@ function init_tempest { local kernel="$image_dir/${base_image_name}-vmlinuz" local ramdisk="$image_dir/${base_image_name}-initrd" local disk_image="$image_dir/${base_image_name}-blank.img" - # if the cirros uec downloaded and the system is uec capable - if [ -f "$kernel" -a -f "$ramdisk" -a -f "$disk_image" -a "$VIRT_DRIVER" != "openvz" \ - -a \( "$LIBVIRT_TYPE" != "lxc" -o "$VIRT_DRIVER" != "libvirt" \) ]; then - echo "Prepare aki/ari/ami Images" - mkdir -p $BOTO_MATERIALS_PATH - ( #new namespace - # tenant:demo ; user: demo - source $TOP_DIR/accrc/demo/demo - euca-bundle-image -r ${CIRROS_ARCH} -i "$kernel" --kernel true -d "$BOTO_MATERIALS_PATH" - euca-bundle-image -r ${CIRROS_ARCH} -i "$ramdisk" --ramdisk true -d "$BOTO_MATERIALS_PATH" - euca-bundle-image -r ${CIRROS_ARCH} -i "$disk_image" -d "$BOTO_MATERIALS_PATH" - ) 2>&1 &1