From a14c5ce2e711c88297b6e6bd3d77295a5d226b87 Mon Sep 17 00:00:00 2001 From: Peter Stachowski Date: Mon, 15 Aug 2016 17:01:43 +0000 Subject: [PATCH] Speed up creation of flavors When creating the flavors necessary for redstack int-tests 'nova flavor-list' is executed for each flavor. This adds over a minute to the kick-start process, even if all the flavors already exists. This change caches the list of flavors and passes it into the add_flavor routine to avoid the overhead of multiple flavor-list calls. Change-Id: Ib70efd4eeb6f6808360d9baaac14edd5a6e84934 --- scripts/redstack | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/scripts/redstack b/scripts/redstack index 7ac423a8..0b5dbccb 100755 --- a/scripts/redstack +++ b/scripts/redstack @@ -200,12 +200,15 @@ function ip_chunk() { # Add a flavor and a corresponding flavor.resize # (flavor.resize adds 16 to the memory and one more vcpu) function add_flavor() { - FLAVOR_NAME=$1 - FLAVOR_ID=$2 - FLAVOR_MEMORY_MB=$3 - FLAVOR_ROOT_GB=$4 - FLAVOR_VCPUS=$5 + local FLAVOR_NAME=$1 + local FLAVOR_ID=$2 + local FLAVOR_MEMORY_MB=$3 + local FLAVOR_ROOT_GB=$4 + local FLAVOR_VCPUS=$5 + if [[ -z "$FLAVOR_LIST_FOR_ADD" ]]; then + FLAVOR_LIST_FOR_ADD=$(nova $credentials flavor-list | cut -d'|' -f3 | sed -e's/ /,/g') + fi credentials="--os-username=admin --os-password=$ADMIN_PASSWORD --os-tenant-name=admin --os-auth-url=$TROVE_AUTH_ENDPOINT" base_id=${FLAVOR_ID} @@ -238,7 +241,7 @@ function add_flavor() { memory=$((${FLAVOR_MEMORY_MB} + 16)) vcpus=$((${FLAVOR_VCPUS} + 1)) fi - if [[ -z $(nova $credentials flavor-list | grep "| $name[ ]* |") ]]; then + if [[ $FLAVOR_LIST_FOR_ADD != *",$name,"* ]]; then nova $credentials flavor-create $name $id $memory $FLAVOR_ROOT_GB $vcpus --ephemeral $ephemeral fi done