From 3b440fba4ca0781bcf1283baaa5c44704d745017 Mon Sep 17 00:00:00 2001 From: zhihui wu Date: Wed, 9 Aug 2017 16:34:30 +0800 Subject: refactor: run storperf scripts in qtip container The preious storperf scripts can only be run based on the host. This patch will make them run in qtip container. JIRA: QTIP-248 README.md will tell you how to use these scripts. Change-Id: I4d2d51f859499e6e56ae8692d880cbde27297b82 Signed-off-by: zhihui wu --- integration/storperf/prepare.sh | 74 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100755 integration/storperf/prepare.sh (limited to 'integration/storperf/prepare.sh') diff --git a/integration/storperf/prepare.sh b/integration/storperf/prepare.sh new file mode 100755 index 00000000..345a80bc --- /dev/null +++ b/integration/storperf/prepare.sh @@ -0,0 +1,74 @@ +#! /bin/bash +############################################################################## +# Copyright (c) 2017 ZTE and others. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +# See https://stackoverflow.com/questions/59895/getting-the-source-directory-of-a-bash-script-from-within +script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +pip install -r $script_dir/storperf_requirements.txt + +if [[ -z $WORKSPACE ]];then + WORKSPACE=`pwd` +fi + + +delete_storperf_stack() +{ + echo "Checking for an existing stack" + STACK_ID=`openstack stack list | grep StorPerfAgentGroup | awk '{print $2}'` + if [[ ! -z $STACK_ID ]];then + openstack stack delete --yes --wait StorPerfAgentGroup + fi +} + + +load_ubuntu_image() +{ + echo "Checking for Ubuntu 16.04 image in Glance" + IMAGE=`openstack image list | grep "Ubuntu 16.04 x86_64"` + if [[ -z "$IMAGE" ]];then + cd $WORKSPACE + if [[ ! -f ubuntu-16.04-server-cloudimg-amd64-disk1.img ]];then + echo "download Ubuntu 16.04 image" + wget -q https://cloud-images.ubuntu.com/releases/16.04/release/ubuntu-16.04-server-cloudimg-amd64-disk1.img + wget -q https://cloud-images.ubuntu.com/releases/16.04/release/MD5SUMS + checksum=$(cat ./MD5SUMS |grep ubuntu-16.04-server-cloudimg-amd64-disk1.img | md5sum -c) + if [[ $checksum =~ 'FAILED' ]];then + echo "Check image md5sum failed. Exit!" + exit 1 + fi + fi + + echo "Create openstack image Ubuntu 16.04" + openstack image create "Ubuntu 16.04 x86_64" --disk-format qcow2 --public \ + --container-format bare --file $WORKSPACE/ubuntu-16.04-server-cloudimg-amd64-disk1.img + fi + + openstack image show "Ubuntu 16.04 x86_64" +} + + +create_storperf_flavor() +{ + echo "Checking for StorPerf flavor" + openstack flavor delete storperf + FLAVOR=`openstack flavor list | grep "storperf"` + if [[ -z "$FLAVOR" ]];then + openstack flavor create storperf \ + --id auto \ + --ram 2048 \ + --disk 4 \ + --vcpus 2 + fi + openstack flavor show storperf +} + + +delete_storperf_stack +load_ubuntu_image +create_storperf_flavor -- cgit 1.2.3-korg