summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryan Sullivan <bryan.sullivan@att.com>2017-02-07 16:14:05 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-02-07 16:14:05 +0000
commit488ac852c3a553bb01db8dce0e70876fda44e5c0 (patch)
tree9caf2d3ef31a21108355a71668cbaaca415e6f75
parent8590eb83b1bdadb72f428c4749ff9c24209ee5de (diff)
parent42c71f2e6fe0c99b9df7ca05d24e51c857d4378b (diff)
Merge "Update vHello_Tacker for Danube/Newton part 2"
-rw-r--r--tests/utils/tacker-setup.sh98
-rw-r--r--tests/vHello_Tacker.sh65
2 files changed, 82 insertions, 81 deletions
diff --git a/tests/utils/tacker-setup.sh b/tests/utils/tacker-setup.sh
index 8970348..48d8f10 100644
--- a/tests/utils/tacker-setup.sh
+++ b/tests/utils/tacker-setup.sh
@@ -14,8 +14,10 @@
# limitations under the License.
#
# What this is: Setup script for the OpenStack Tacker VNF Manager starting from
-# an Unbuntu Xenial docker container. This script is intended to be in an
-# OPNFV environment, or an plain OpenStack environment (e.g. Devstack).
+# an Unbuntu Xenial docker container, on either an Ubuntu Xenial or Centos 7
+# host. This script is intended to be used in an OPNFV environment, or a plain
+# OpenStack environment (e.g. Devstack).
+# This install procedure is intended to deploy Tacker for testing purposes only.
#
# Status: this is a work in progress, under test.
#
@@ -23,7 +25,7 @@
# $ bash tacker-setup.sh [init|setup|clean] [branch]
# init: Initialize docker container
# setup: Setup of Tacker in the docker container
-# clean: Clean
+# clean: Remove the Tacker service, container, and data in /opt/tacker
# branch: OpenStack branch to install (default: master)
trap 'fail' ERR
@@ -47,13 +49,13 @@ fail() {
function setenv () {
echo "$0: $(date) Setup shared virtual folders and save this script there"
- mkdir /tmp/tacker
- cp $0 /tmp/tacker/.
- cp `dirname $0`/tacker/tacker.conf.sample /tmp/tacker/.
- chmod 755 /tmp/tacker/*.sh
+ mkdir /opt/tacker
+ cp $0 /opt/tacker/.
+ cp `dirname $0`/tacker/tacker.conf.sample /opt/tacker/.
+ chmod 755 /opt/tacker/*.sh
echo "$0: $(date) Setup admin-openrc.sh"
- source /tmp/tacker/admin-openrc.sh
+ source /opt/tacker/admin-openrc.sh
}
function get_external_net () {
@@ -79,7 +81,7 @@ function create_container () {
# xenial is needed for python 3.5
sudo docker pull ubuntu:xenial
sudo service docker start
- sudo docker run -it -d -v /tmp/tacker/:/tmp/tacker --name tacker ubuntu:xenial /bin/bash
+ sudo docker run -it -d -v /opt/tacker/:/opt/tacker --name tacker ubuntu:xenial /bin/bash
else
# Centos
echo "Centos-based install"
@@ -95,7 +97,7 @@ EOF
# xenial is needed for python 3.5
sudo service docker start
sudo docker pull ubuntu:xenial
- sudo docker run -i -t -d -v /tmp/tacker/:/tmp/tacker --name tacker ubuntu:xenial /bin/bash
+ sudo docker run -i -t -d -v /opt/tacker/:/opt/tacker --name tacker ubuntu:xenial /bin/bash
fi
}
@@ -115,31 +117,29 @@ function setup () {
echo "$0: $(date) Installing Tacker"
# STEP 2: Install Tacker in the container
# Per http://docs.openstack.org/developer/tacker/install/manual_installation.html
- echo "$0: $(date) Install dependencies - OS specific"
- if [ "$dist" == "Ubuntu" ]; then
- apt-get update
- apt-get install -y python
- apt-get install -y python-dev
- apt-get install -y python-pip
- apt-get install -y wget
- apt-get install -y openssh-server
- apt-get install -y git
- apt-get install -y apg
- apt-get install -y libffi-dev
- apt-get install -y libssl-dev
- # newton: tacker uses ping for monitoring VIM (not in default docker containers)
- apt-get install -y inetutils-ping
- # apt-utils is not installed in xenial container image
- apt-get install -y apt-utils
- export MYSQL_PASSWORD=$(/usr/bin/apg -n 1 -m 16 -c cl_seed)
- echo $MYSQL_PASSWORD >~/mysql
- debconf-set-selections <<< 'mysql-server mysql-server/root_password password '$MYSQL_PASSWORD
- debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password '$MYSQL_PASSWORD
- apt-get -q -y install mysql-server python-mysqldb
- service mysql restart
- fi
-
- cd /tmp/tacker
+ echo "$0: $(date) Install dependencies"
+ apt-get update
+ apt-get install -y python
+ apt-get install -y python-dev
+ apt-get install -y python-pip
+ apt-get install -y wget
+ apt-get install -y openssh-server
+ apt-get install -y git
+ apt-get install -y apg
+ apt-get install -y libffi-dev
+ apt-get install -y libssl-dev
+ # newton: tacker uses ping for monitoring VIM (not in default docker containers)
+ apt-get install -y inetutils-ping
+ # apt-utils is not installed in xenial container image
+ apt-get install -y apt-utils
+ export MYSQL_PASSWORD=$(/usr/bin/apg -n 1 -m 16 -c cl_seed)
+ echo $MYSQL_PASSWORD >~/mysql
+ debconf-set-selections <<< 'mysql-server mysql-server/root_password password '$MYSQL_PASSWORD
+ debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password '$MYSQL_PASSWORD
+ apt-get -q -y install mysql-server python-mysqldb
+ service mysql restart
+
+ cd /opt/tacker
echo "$0: $(date) create Tacker database"
mysql --user=root --password=$MYSQL_PASSWORD -e "CREATE DATABASE tacker; GRANT ALL PRIVILEGES ON tacker.* TO 'root@localhost' IDENTIFIED BY '"$MYSQL_PASSWORD"'; GRANT ALL PRIVILEGES ON tacker.* TO 'tacker'@'%' IDENTIFIED BY '"$MYSQL_PASSWORD"';"
@@ -154,7 +154,7 @@ function setup () {
# pip install --upgrade python-openstackclient python-glanceclient python-neutronclient keystonemiddleware
echo "$0: $(date) Setup admin-openrc.sh"
- source /tmp/tacker/admin-openrc.sh
+ source /opt/tacker/admin-openrc.sh
uid=$(openstack user list | awk "/ tacker / { print \$2 }")
if [[ $uid ]]; then
@@ -176,14 +176,14 @@ function setup () {
echo "$0: $(date) Create Tacker service endpoint in OpenStack"
ip=$(ip addr | awk "/ global eth0/ { print \$2 }" | sed -- 's/\/16//')
- region=$(openstack endpoint list | awk "/ nova / { print \$4 }")
+ region=$(openstack endpoint list | awk "/ nova / { print \$4 }" | head -1)
openstack endpoint create --region $region \
--publicurl "http://$ip:9890/" \
--adminurl "http://$ip:9890/" \
--internalurl "http://$ip:9890/" $sid
echo "$0: $(date) Clone Tacker"
- if [[ -d /tmp/tacker/tacker ]]; then rm -rf /tmp/tacker/tacker; fi
+ if [[ -d /opt/tacker/tacker ]]; then rm -rf /opt/tacker/tacker; fi
git clone git://git.openstack.org/openstack/tacker
cd tacker
git checkout $branch
@@ -202,7 +202,7 @@ function setup () {
echo "$0: $(date) Update tacker.conf values"
mkdir /usr/local/etc/tacker
- cp /tmp/tacker/tacker.conf.sample /usr/local/etc/tacker/tacker.conf
+ cp /opt/tacker/tacker.conf.sample /usr/local/etc/tacker/tacker.conf
# [DEFAULT] section (update)
sed -i -- 's/#auth_strategy = keystone/auth_strategy = keystone/' /usr/local/etc/tacker/tacker.conf
@@ -215,12 +215,11 @@ function setup () {
# Not sure what the effect of the next line is, given that we are running as root in the container
#sed -i -- "s~# root_helper = sudo~root_helper = sudo /usr/local/bin/tacker-rootwrap /usr/local/etc/tacker/rootwrap.conf~" /usr/local/etc/tacker/tacker.conf
- sed -i -- "s~#api_paste_config = api-paste.ini~api_paste_config = /tmp/tacker/tacker/etc/tacker/api-paste.ini~" /usr/local/etc/tacker/tacker.conf
+ sed -i -- "s~#api_paste_config = api-paste.ini~api_paste_config = /opt/tacker/tacker/etc/tacker/api-paste.ini~" /usr/local/etc/tacker/tacker.conf
sed -i -- "s/#bind_host = 0.0.0.0/bind_host = $ip/" /usr/local/etc/tacker/tacker.conf
sed -i -- "s/#bind_port = 8888/bind_port = 9890/" /usr/local/etc/tacker/tacker.conf
# Newton changes, based upon sample newton gate test conf file provided by sridhar_ram on #tacker
- region=$(openstack endpoint list | awk "/ nova / { print \$4 }")
sed -i -- "s/#nova_region_name = <None>/#nova_region_name = $region/" /usr/local/etc/tacker/tacker.conf
sed -i -- "s/#nova_api_insecure = false/nova_api_insecure = False/" /usr/local/etc/tacker/tacker.conf
sed -i -- "s/#nova_ca_certificates_file = <None>/nova_ca_certificates_file =/" /usr/local/etc/tacker/tacker.conf
@@ -274,11 +273,12 @@ EOF
# < heat_uri = http://15.184.66.78:8004/v1
# newton: add [tacker_heat] missing in generated tacker.conf.sample
+ heat_ipport=$(openstack endpoint show heat | awk "/ internalurl / { print \$4 }" | awk -F'[/]' '{print $3}')
cat >>/usr/local/etc/tacker/tacker.conf <<EOF
[tacker_heat]
stack_retry_wait = 10
stack_retries = 60
-heat_uri = http://$HEAT_HOST:8004/v1
+heat_uri = http://$heat_ipport/v1
EOF
# newton: add [database] missing in generated tacker.conf.sample
@@ -305,8 +305,8 @@ EOF
/usr/local/bin/tacker-db-manage --config-file /usr/local/etc/tacker/tacker.conf upgrade head
echo "$0: $(date) Install Tacker Client"
- cd /tmp/tacker
- if [[ -d /tmp/tacker/python-tackerclient ]]; then rm -rf /tmp/tacker/python-tackerclient; fi
+ cd /opt/tacker
+ if [[ -d /opt/tacker/python-tackerclient ]]; then rm -rf /opt/tacker/python-tackerclient; fi
git clone https://github.com/openstack/python-tackerclient
cd python-tackerclient
git checkout $branch
@@ -314,7 +314,7 @@ EOF
# deferred until its determined how to get this to Horizon
#echo "$0: $(date) Install Tacker Horizon plugin"
- #cd /tmp/tacker
+ #cd /opt/tacker
#git clone https://github.com/openstack/tacker-horizon
#cd tacker-horizon
#python setup.py install
@@ -329,12 +329,13 @@ EOF
sleep 30
echo "$0: $(date) Register default VIM"
- cd /tmp/tacker
+ cd /opt/tacker
# TODO: bug in https://github.com/openstack/python-tackerclient/blob/stable/newton/tackerclient/common/utils.py
# expects that there will be a port specified in the auth_url
# TODO: bug: user_domain_name: Default is required even for identity v2
+ keystone_ipport=$(openstack endpoint show keystone | awk "/ internalurl / { print \$4 }" | awk -F'[/]' '{print $3}')
cat <<EOF >vim-config.yaml
-auth_url: http://$KEYSTONE_HOST:5000/identity/v2.0
+auth_url: http://$keystone_ipport/identity/v2.0
username: $OS_USERNAME
password: $OS_PASSWORD
project_name: admin
@@ -395,7 +396,8 @@ function setup_test_environment () {
}
function clean () {
- source /tmp/tacker/admin-openrc.sh
+ source /opt/tacker/admin-openrc.sh
+ eid=($(openstack endpoint list | awk "/tacker/ { print \$2 }")); for id in ${eid[@]}; do openstack endpoint delete ${id}; done
openstack endpoint delete $(openstack endpoint list | awk "/tacker/ { print \$2 }")
openstack user delete $(openstack user list | awk "/tacker/ { print \$2 }")
openstack service delete $(openstack service list | awk "/tacker/ { print \$2 }")
diff --git a/tests/vHello_Tacker.sh b/tests/vHello_Tacker.sh
index 4ae1575..bb96c32 100644
--- a/tests/vHello_Tacker.sh
+++ b/tests/vHello_Tacker.sh
@@ -24,7 +24,7 @@
# Newton.
#
# Pre-State:
-# This test can be run in either an OPNFV environment, or an plain OpenStack
+# This test can be run in either an OPNFV environment, or a plain OpenStack
# environment (e.g. Devstack).
# For Devstack running in a VM on the host, you must first enable the host to
# access the VMs running under Devstack:
@@ -58,7 +58,7 @@
#
# Post-State:
# After step 1, Tacker is installed and active in a docker container, and the
-# test blueprint etc are prepared in a shared virtual folder /tmp/tacker.
+# test blueprint etc are prepared in a shared virtual folder /opt/tacker.
# After step 2, the VNF is running and verified.
# After step 3, the VNF is deleted and the system returned to step 1 post-state.
# After step 4, the system returned to test pre-state.
@@ -68,10 +68,9 @@
# How to use:
# $ git clone https://gerrit.opnfv.org/gerrit/models
# $ cd models/tests
-# $ bash vHello_Tacker.sh [setup|run] [<openrc>] [<heat_host>] [branch]
+# $ bash vHello_Tacker.sh [setup|run] [<openrc>] [branch]
# setup: setup test environment
# <openrc>: location of OpenStack openrc file
-# <heat_host>: IP address of the Heat service
# branch: OpenStack branch to install (default: master)
# $ bash vHello_Tacker.sh [start|stop|clean]
# run: setup test environment and run test
@@ -132,16 +131,16 @@ try () {
}
setup () {
- echo "$0: $(date) Setup temp test folder /tmp/tacker and copy this script there"
- if [ -d /tmp/tacker ]; then sudo rm -rf /tmp/tacker; fi
- mkdir -p /tmp/tacker
- chmod 777 /tmp/tacker/
- cp $0 /tmp/tacker/.
- cp $1 /tmp/tacker/admin-openrc.sh
- source /tmp/tacker/admin-openrc.sh
- echo "export HEAT_HOST=$2" >>/tmp/tacker/admin-openrc.sh
- echo "export KEYSTONE_HOST=$(echo $OS_AUTH_URL | awk -F'[/]' '{print $3}')" >>/tmp/tacker/admin-openrc.sh
- chmod 755 /tmp/tacker/*.sh
+ echo "$0: $(date) Setup temp test folder /opt/tacker and copy this script there"
+ if [ -d /opt/tacker ]; then sudo rm -rf /opt/tacker; fi
+ sudo mkdir -p /opt/tacker
+ sudo chown $USER /opt/tacker
+ chmod 777 /opt/tacker/
+ cp $0 /opt/tacker/.
+ cp $1 /opt/tacker/admin-openrc.sh
+
+ source /opt/tacker/admin-openrc.sh
+ chmod 755 /opt/tacker/*.sh
echo "$0: $(date) tacker-setup part 1"
bash utils/tacker-setup.sh init
@@ -163,44 +162,44 @@ setup () {
fi
echo "$0: $(date) Execute tacker-setup.sh in the container"
- sudo docker exec -it tacker /bin/bash /tmp/tacker/tacker-setup.sh setup $3
+ sudo docker exec -it tacker /bin/bash /opt/tacker/tacker-setup.sh setup $2
if [ $? -eq 1 ]; then fail; fi
else
echo "$0: $(date) Execute tacker-setup.sh in the container"
- sudo docker exec -i -t tacker /bin/bash /tmp/tacker/tacker-setup.sh setup $3
+ sudo docker exec -i -t tacker /bin/bash /opt/tacker/tacker-setup.sh setup $2
if [ $? -eq 1 ]; then fail; fi
fi
assert "models-tacker-001 (Tacker installation in a docker container on the jumphost)" true
echo "$0: $(date) reset blueprints folder"
- if [[ -d /tmp/tacker/blueprints/tosca-vnfd-hello-world-tacker ]]; then rm -rf /tmp/tacker/blueprints/tosca-vnfd-hello-world-tacker; fi
- mkdir -p /tmp/tacker/blueprints/tosca-vnfd-hello-world-tacker
+ if [[ -d /opt/tacker/blueprints/tosca-vnfd-hello-world-tacker ]]; then rm -rf /opt/tacker/blueprints/tosca-vnfd-hello-world-tacker; fi
+ mkdir -p /opt/tacker/blueprints/tosca-vnfd-hello-world-tacker
echo "$0: $(date) copy tosca-vnfd-hello-world-tacker to blueprints folder"
- cp -r blueprints/tosca-vnfd-hello-world-tacker /tmp/tacker/blueprints
+ cp -r blueprints/tosca-vnfd-hello-world-tacker /opt/tacker/blueprints
}
start() {
echo "$0: $(date) setup OpenStack CLI environment"
- source /tmp/tacker/admin-openrc.sh
+ source /opt/tacker/admin-openrc.sh
echo "$0: $(date) Create Nova key pair"
- if [[ -f /tmp/tacker/vHello ]]; then rm /tmp/tacker/vHello; fi
- ssh-keygen -t rsa -N "" -f /tmp/tacker/vHello -C ubuntu@vHello
- chmod 600 /tmp/tacker/vHello
- openstack keypair create --public-key /tmp/tacker/vHello.pub vHello
+ if [[ -f /opt/tacker/vHello ]]; then rm /opt/tacker/vHello; fi
+ ssh-keygen -t rsa -N "" -f /opt/tacker/vHello -C ubuntu@vHello
+ chmod 600 /opt/tacker/vHello
+ openstack keypair create --public-key /opt/tacker/vHello.pub vHello
assert "models-nova-001 (Keypair creation)" true
echo "$0: $(date) Inject public key into blueprint"
- pubkey=$(cat /tmp/tacker/vHello.pub)
- sed -i -- "s~<pubkey>~$pubkey~" /tmp/tacker/blueprints/tosca-vnfd-hello-world-tacker/blueprint.yaml
+ pubkey=$(cat /opt/tacker/vHello.pub)
+ sed -i -- "s~<pubkey>~$pubkey~" /opt/tacker/blueprints/tosca-vnfd-hello-world-tacker/blueprint.yaml
echo "$0: $(date) Get external network for Floating IP allocations"
get_floating_net
echo "$0: $(date) create VNFD"
- cd /tmp/tacker/blueprints/tosca-vnfd-hello-world-tacker
+ cd /opt/tacker/blueprints/tosca-vnfd-hello-world-tacker
# newton: NAME (was "--name") is now a positional parameter
tacker vnfd-create --vnfd-file blueprint.yaml hello-world-tacker
assert "models-tacker-002 (VNFD creation)" [[ $? -eq 0 ]]
@@ -278,7 +277,7 @@ start() {
stop() {
echo "$0: $(date) setup OpenStack CLI environment"
- source /tmp/tacker/admin-openrc.sh
+ source /opt/tacker/admin-openrc.sh
echo "$0: $(date) uninstall vHello blueprint via CLI"
vid=($(tacker vnf-list|grep hello-world-tacker|awk '{print $2}')); for id in ${vid[@]}; do tacker vnf-delete ${id}; done
@@ -302,7 +301,7 @@ stop() {
forward_to_container () {
echo "$0: $(date) pass $1 command to vHello.sh in tacker container"
CONTAINER=$(sudo docker ps -a | awk "/tacker/ { print \$1 }")
- sudo docker exec $CONTAINER /bin/bash /tmp/tacker/vHello_Tacker.sh $1
+ sudo docker exec $CONTAINER /bin/bash /opt/tacker/vHello_Tacker.sh $1
if [ $? -eq 1 ]; then fail; fi
}
@@ -311,12 +310,12 @@ dist=`grep DISTRIB_ID /etc/*-release | awk -F '=' '{print $2}'`
case "$1" in
setup)
- setup $2 $3 $4
+ setup $2 $3
if [ $? -eq 1 ]; then fail; fi
pass
;;
run)
- setup $2 $3 $4
+ setup $2 $3
forward_to_container start
if [ $? -eq 1 ]; then fail; fi
pass
@@ -333,10 +332,10 @@ case "$1" in
clean)
echo "$0: $(date) Uninstall Tacker and test environment"
forward_to_container stop
- sudo docker exec -it tacker /bin/bash /tmp/tacker/tacker-setup.sh clean
+ sudo docker exec -it tacker /bin/bash /opt/tacker/tacker-setup.sh clean
sudo docker stop tacker
sudo docker rm -v tacker
- if [ $? -eq 1 ]; then fail; fi
+ sudo rm -rf /opt/tacker
pass
;;
*)