Merge "update lxd image disk format for openstack CLI"
[yardstick.git] / tools / yardstick-img-dpdk-finalize.sh
1 #!/bin/bash
2 ##############################################################################
3 # Copyright (c) 2017 ZTE corporation and others.
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
12 # installs dpdk and pktgen packages on modified image
13
14 # PREREQUISITES
15 # modified image (yardstick-wily-server) must be uploaded to OpenStack
16 # heat must be installed: apt-get install python-heatclient, python-glanceclient, python-nova
17 # must have a public yardstick-key uploaded in openstack
18 # must have a proper flavor for the image (i.e. m1.small)
19
20
21 stackname="yardstick-modify-stack"
22 template=dpdk_install.yml
23 new_image_name="yardstick-image-pktgen-ready"
24
25 openstack stack create $stackname -f yaml -t $template
26 progress="WARMING_UP"
27
28 while [ "$progress" != "CREATE_COMPLETE" ]
29 do
30   sleep 10
31   echo "check stack status......."
32   show_output=$(openstack stack show $stackname)
33   progress=$(echo $show_output | sed 's/^.*stack_status . \([^ ]*\).*$/\1/')
34   echo "$progress"
35   if [ "$progress" == "CREATE_FAILED" ];then
36     echo "create $stackname failed"
37     exit 1
38   fi
39 done
40
41 # workaround: Without wait time, the file size of pktgen is zero in the snapshot.
42 sleep 60
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