Merge "Log each test case status in a task"
[yardstick.git] / tools / vsperf-img-finalize.sh
1 #!/bin/bash
2 ##############################################################################
3 # Copyright (c) 2017 Nokia
4 #
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
10
11 # PREREQUISITES
12 # modified image (yardstick-vsperf) must be uploaded to OpenStack
13 # must have a proper flavor (vsperf-flavor) for the image e.g.
14 # nova flavor-create vsperf-flavor auto 8192 80 6
15 # nova flavor-key vsperf-flavor set hw:numa_nodes=1
16 # nova flavor-key vsperf-flavor set hw:mem_page_size=1GB
17 # nova flavor-key vsperf-flavor set hw:cpu_policy=dedicated
18 # nova flavor-key vsperf-flavor set hw:vif_multiqueue_enabled=true
19
20 stackname="vsperf-install-stack"
21 template=vsperf_install.yml
22 new_image_name="yardstick-vsperf-server"
23
24 openstack stack create $stackname -f yaml -t $template
25 progress="WARMING_UP"
26
27 while [ "$progress" != "CREATE_COMPLETE" ]
28 do
29   sleep 10
30   echo "check stack status......."
31   show_output=$(openstack stack show $stackname)
32   progress=$(echo $show_output | sed 's/^.*stack_status . \([^ ]*\).*$/\1/')
33   echo "$progress"
34   if [ "$progress" == "CREATE_FAILED" ];then
35     echo "create $stackname failed"
36     exit 1
37   fi
38 done
39
40 # has to stop the instance before taking the snapshot
41 nova stop $stackname
42 sleep 10
43
44 status=$(nova image-create --poll $stackname $new_image_name)
45 if [[ "$status" =~ "Finished" ]];then
46   echo "$new_image_name finished"
47 fi
48
49 nova delete $stackname
50 sleep 10
51 openstack stack delete --yes $stackname