summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancisco Redondo Marchena <francisco.marchena@codethink.co.uk>2015-06-04 10:58:02 +0000
committerFrancisco Redondo Marchena <francisco.marchena@codethink.co.uk>2015-06-11 17:04:29 +0000
commitb2d93d136b7d16be374a8a21fccf0555e41eb86a (patch)
tree6601e8cac1ef92c59cc07af406811ee19247a6a0
parente10ad8da85f1dc117d8df7a4c088b98d6335806d (diff)
downloaddefinitions-b2d93d136b7d16be374a8a21fccf0555e41eb86a.tar.gz
OpenStack: Add script to configure images for tempest
This script creates a image for the admin user in the admin tenant and configure some tempest.conf variables in order to run tempest test for compute and other apis and services. Change-Id: I6a9adb990607a3d92a783590a95ee447157de8f4
-rwxr-xr-xinstall-files/openstack/etc/tempest/set_openstack_to_run_tempest.sh100
-rw-r--r--install-files/openstack/manifest1
2 files changed, 101 insertions, 0 deletions
diff --git a/install-files/openstack/etc/tempest/set_openstack_to_run_tempest.sh b/install-files/openstack/etc/tempest/set_openstack_to_run_tempest.sh
new file mode 100755
index 00000000..5a74dfcf
--- /dev/null
+++ b/install-files/openstack/etc/tempest/set_openstack_to_run_tempest.sh
@@ -0,0 +1,100 @@
+#!/bin/bash
+#
+# Copyright ©2015 Codethink Limited
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+
+# This script creates an public image in the admin tenant and
+# sets tempest.conf variables for running tests with images involved.
+# This is the minimal configuration to run tests for compute (api and services
+# tests).
+#
+# NOTE: the test image will be the following cirros image:
+# http://download.cirros-cloud.net/0.3.3/cirros-0.3.3-x86_64-disk.img
+#
+
+
+set -e
+
+# Global variables
+admin_filename="admin_env"
+admin_test_image="cirros64_img_ref"
+image_ref=""
+
+# Openstack admin credentials
+admin_username="admin"
+admin_password="veryinsecure"
+admin_tenant="admin"
+
+# Create a file with the environment variables
+# required for setting a Openstack admin user in the
+# admin tenant.
+create_admin_user_env(){
+ cat > "$admin_filename" <<EOF
+ export OS_USERNAME="$admin_username"
+ export OS_PASSWORD="$admin_password"
+ export OS_TENANT_NAME="$admin_tenant"
+ export OS_AUTH_URL=http://$(hostname):35357/v2.0
+EOF
+}
+
+# Set the image fields in tempest.conf with the UUID of the admin_test_image.
+configure_image_ref(){
+ image_ref="$(glance image-list | grep "$admin_test_image" | tr -d [:space:] | cut -d'|' -f 2)"
+ if [ -z "image_ref" ]; then
+ echo "ERROR: image_ref is empty, please check that $admin_test_image is in the image list."
+ exit 1
+ fi
+ # Configure the UUID (image_ref) for the created image
+ sed -r -i "s/[#]?image_ref =.*/image_ref = $image_ref/" tempest.conf
+ # Configure image_ssh_user for the created image
+ sed -r -i "s/[#]?image_ssh_user =.*/image_ssh_user = cirros/" tempest.conf
+ # Configure image_ssh_password for the created image
+ sed -r -i "s/[#]?image_ssh_password =.*/image_ssh_password = 'cubswin:)'/" tempest.conf
+ # Configure the UUID (image_ref_alt) for the created image
+ sed -r -i "s/[#]?image_ref_alt =.*/image_ref_alt = $image_ref/" tempest.conf
+ # Configure image_alt_ssh_user for the created image
+ sed -r -i "s/[#]?image_alt_ssh_user =.*/image_alt_ssh_user = cirros/" tempest.conf
+}
+
+create_image_for_user(){
+# Create a image in the tenant $user called
+ local user_name="$1"
+ local test_image="$2"
+
+ # Set the credential for $user
+ source "${user_name}_env"
+ # If there is an image with the same name as $test image, remove it.
+ if [ $(glance image-list | grep "$test_image" | wc -l) -gt 0 ]; then
+ declare -a previous_img=$(glance image-list | grep "$test_image" | awk -F "|" '{ print $2 }')
+ for index in ${previous_img[@]}; do
+ glance image-delete "$index"
+ done
+ fi
+ glance image-create --name "$test_image" \
+ --location http://download.cirros-cloud.net/0.3.3/cirros-0.3.3-x86_64-disk.img \
+ --is-public true --disk-format qcow2 --container-format bare --progress
+ if [[ $? -eq 0 ]] \
+ || [[ "$(glance image-list | grep "$test_image" | wc -l)" == "1" ]]; then
+ configure_image_ref
+ else
+ echo "ERROR: glance image-create failed."
+ exit 1
+ fi
+}
+
+# Configure Openstack for running tempest tests.
+create_admin_user_env
+create_image_for_user "$admin_username" "$admin_test_image"
diff --git a/install-files/openstack/manifest b/install-files/openstack/manifest
index da38a638..8a5b47c1 100644
--- a/install-files/openstack/manifest
+++ b/install-files/openstack/manifest
@@ -1,6 +1,7 @@
0040755 0 0 /etc/horizon
0100644 0 0 /etc/horizon/apache-horizon.conf
template 0100644 0 0 /etc/tempest/tempest.conf
+0100755 0 0 /etc/tempest/set_openstack_to_run_tempest.sh
0040755 0 0 /usr/share/openstack
0100644 0 0 /usr/share/openstack/hosts
0040755 0 0 /usr/share/openstack/ceilometer