summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorblsaws <bryan.sullivan@att.com>2016-09-14 11:11:52 -0700
committerblsaws <bryan.sullivan@att.com>2016-09-14 11:11:52 -0700
commit34080cb1c9c05aaeeb13d34bfbf9fd54bbaf25f9 (patch)
tree5ff13bd83c3908131dde33c99c635eed4d682b6f
parent2cd06c9bff01b6a9d8755132b8c7798ff1f72053 (diff)
Align design of Cloudify and Tacker test scripts
JIRA: MODELS-23 Change-Id: Iaa4efef6b5c993381ad6d7e5583859e860a52d0f Signed-off-by: blsaws <bryan.sullivan@att.com>
-rw-r--r--tests/utils/cloudify-setup.sh349
-rw-r--r--tests/utils/tacker-setup.sh156
-rw-r--r--tests/vHello_Cloudify.sh263
-rw-r--r--tests/vHello_Tacker.sh26
4 files changed, 547 insertions, 247 deletions
diff --git a/tests/utils/cloudify-setup.sh b/tests/utils/cloudify-setup.sh
index baf41fa..c011181 100644
--- a/tests/utils/cloudify-setup.sh
+++ b/tests/utils/cloudify-setup.sh
@@ -26,6 +26,18 @@
# setup: Setup of Cloudify in the docker container
# clean: Clean
+pass() {
+ echo "$0: Hooray!"
+ set +x #echo off
+ exit 0
+}
+
+fail() {
+ echo "$0: Failed!"
+ set +x
+ exit 1
+}
+
function setenv () {
if [ "$dist" == "Ubuntu" ]; then
echo "$0: Ubuntu-based install"
@@ -88,29 +100,27 @@ function get_external_net () {
fi
}
-dist=`grep DISTRIB_ID /etc/*-release | awk -F '=' '{print $2}'`
-case "$2" in
- "init")
- # STEP 1: Create the container and launch it
- echo "$0: Copy this script to /tmp/cloudify"
- mkdir /tmp/cloudify
- cp $0 /tmp/cloudify/.
- chmod 755 /tmp/cloudify/*.sh
-
- echo "$0: Setup admin-openrc.sh"
- setenv
- echo "$0: Setup container"
- if [ "$dist" == "Ubuntu" ]; then
- # xenial is needed for python 3.5
- sudo docker pull ubuntu:xenial
- sudo service docker start
-# sudo docker run -it -v ~/git/joid/ci/cloud/admin-openrc.sh:/root/admin-openrc.sh -v ~/cloudify/cloudify-setup.sh:/root/cloudify-setup.sh ubuntu:xenial /bin/bash
- sudo docker run -it -d -v /tmp/cloudify/:/tmp/cloudify --name cloudify ubuntu:xenial /bin/bash
- exit 0
- else
- # Centos
- echo "Centos-based install"
- sudo tee /etc/yum.repos.d/docker.repo <<-'EOF'
+function create_container () {
+ # STEP 1: Create the container and launch it
+ echo "$0: Copy this script to /tmp/cloudify"
+ mkdir /tmp/cloudify
+ cp $0 /tmp/cloudify/.
+ chmod 755 /tmp/cloudify/*.sh
+
+ echo "$0: Setup admin-openrc.sh"
+ setenv
+ echo "$0: Setup container"
+ if [ "$dist" == "Ubuntu" ]; then
+ # xenial is needed for python 3.5
+ sudo docker pull ubuntu:xenial
+ sudo service docker start
+# sudo docker run -it -v ~/git/joid/ci/cloud/admin-openrc.sh:/root/admin-openrc.sh -v ~/cloudify/cloudify-setup.sh:/root/cloudify-setup.sh ubuntu:xenial /bin/bash
+ sudo docker run -it -d -v /tmp/cloudify/:/tmp/cloudify --name cloudify ubuntu:xenial /bin/bash
+ exit 0
+ else
+ # Centos
+ echo "Centos-based install"
+ sudo tee /etc/yum.repos.d/docker.repo <<-'EOF'
[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/7/
@@ -118,174 +128,181 @@ enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg
EOF
- sudo yum install -y docker-engine
- # xenial is needed for python 3.5
- sudo docker pull ubuntu:xenial
- sudo service docker start
-# sudo docker run -it -v ~/git/joid/ci/cloud/admin-openrc.sh:/root/admin-openrc.sh -v ~/cloudify/cloudify-setup.sh:/root/cloudify-setup.sh ubuntu:xenial /bin/bash
- sudo docker run -i -t -d -v /tmp/cloudify/:/tmp/cloudify ubuntu:xenial /bin/bash
- fi
- exit 0
- ;;
- "setup")
- ;;
- "clean")
- source /tmp/cloudify/admin-openrc.sh
- openstack router show vnf_mgmt_router
- neutron router-gateway-clear vnf_mgmt_router
- pid=($(neutron router-port-list vnf_mgmt_router|grep -v name|awk '{print $2}')); for id in ${pid[@]}; do neutron router-interface-delete vnf_mgmt_router vnf_mgmt; done
- neutron router-delete vnf_mgmt_router
- neutron net-delete vnf_mgmt
- sudo docker stop $(sudo docker ps -a | awk "/cloudify/ { print \$1 }")
- sudo docker rm -v $(sudo docker ps -a | awk "/cloudify/ { print \$1 }")
- exit 0
- ;;
- *)
- echo "usage: $ bash cloudify-setup.sh [cloudify-cli|cloudify-manager] [init|setup|clean]"
- echo "cloudify-cli: use Cloudify CLI"
- echo "cloudify-manager: use Cloudify Manager"
- echo "init: Initialize docker container"
- echo "setup: Setup of Cloudify in the docker container"
- echo "clean: Clean"
- exit 1
-esac
+ sudo yum install -y docker-engine
+ # xenial is needed for python 3.5
+ sudo docker pull ubuntu:xenial
+ sudo service docker start
+ # sudo docker run -it -v ~/git/joid/ci/cloud/admin-openrc.sh:/root/admin-openrc.sh -v ~/cloudify/cloudify-setup.sh:/root/cloudify-setup.sh ubuntu:xenial /bin/bash
+ sudo docker run -i -t -d -v /tmp/cloudify/:/tmp/cloudify ubuntu:xenial /bin/bash
+ fi
+}
-echo "$0: 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 git gcc python-dev libxml2 libxslt1-dev libzip-dev
-# pip install --upgrade pip virtualenv setuptools pbr tox
-fi
+function setup () {
+ echo "$0: 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 git gcc python-dev libxml2 libxslt1-dev libzip-dev
+ # pip install --upgrade pip virtualenv setuptools pbr tox
+ fi
-cd ~
+ cd ~
-echo "$0: Install dependencies - generic"
-pip install --upgrade pip setuptools
+ echo "$0: Install dependencies - generic"
+ pip install --upgrade pip setuptools
-echo "$0: install python-openstackclient python-glanceclient"
-pip install --upgrade python-openstackclient python-glanceclient python-neutronclient
-pip install --upgrade python-neutronclient
+ echo "$0: install python-openstackclient python-glanceclient"
+ pip install --upgrade python-openstackclient python-glanceclient python-neutronclient
+ pip install --upgrade python-neutronclient
-echo "$0: cleanup any previous install attempt"
-if [ -d "~/cloudify" ]; then rm -rf ~/cloudify; fi
-if [ -d "~/cloudify-manager" ]; then rm -rf ~/cloudify-manager; fi
-rm ~/get-cloudify.py
+ echo "$0: cleanup any previous install attempt"
+ if [ -d "~/cloudify" ]; then rm -rf ~/cloudify; fi
+ if [ -d "~/cloudify-manager" ]; then rm -rf ~/cloudify-manager; fi
+ rm ~/get-cloudify.py
-echo "$0: Get Cloudify"
-wget http://gigaspaces-repository-eu.s3.amazonaws.com/org/cloudify3/get-cloudify.py
-python get-cloudify.py --upgrade
+ echo "$0: Get Cloudify"
+ wget http://gigaspaces-repository-eu.s3.amazonaws.com/org/cloudify3/get-cloudify.py
+ python get-cloudify.py --upgrade
-echo "$0: Initialize Cloudify"
-cfy init
+ echo "$0: Initialize Cloudify"
+ cfy init
-echo "$0: Setup admin-openrc.sh"
-source /tmp/cloudify/admin-openrc.sh
+ echo "$0: Setup admin-openrc.sh"
+ source /tmp/cloudify/admin-openrc.sh
-get_external_net
+ get_external_net
-if [ "$1" == "cloudify-manager" ]; then
- echo "$0: Prepare the Cloudify Manager prerequisites and data"
- mkdir -p ~/cloudify-manager
- cd ~/cloudify-manager
- wget https://github.com/cloudify-cosmo/cloudify-manager-blueprints/archive/3.4.tar.gz
- mv 3.4.tar.gz cloudify-manager-blueprints.tar.gz
- tar -xzvf cloudify-manager-blueprints.tar.gz
- cd cloudify-manager-blueprints-3.4
+ if [ "$1" == "cloudify-manager" ]; then
+ echo "$0: Prepare the Cloudify Manager prerequisites and data"
+ mkdir -p ~/cloudify-manager
+ cd ~/cloudify-manager
+ wget https://github.com/cloudify-cosmo/cloudify-manager-blueprints/archive/3.4.tar.gz
+ mv 3.4.tar.gz cloudify-manager-blueprints.tar.gz
+ tar -xzvf cloudify-manager-blueprints.tar.gz
+ cd cloudify-manager-blueprints-3.4
- echo "$0: Setup keystone_username"
- sed -i -- "s/keystone_username: ''/keystone_username: '$OS_USERNAME'/g" openstack-manager-blueprint-inputs.yaml
+ echo "$0: Setup keystone_username"
+ sed -i -- "s/keystone_username: ''/keystone_username: '$OS_USERNAME'/g" openstack-manager-blueprint-inputs.yaml
- echo "$0: Setup keystone_password"
- sed -i -- "s/keystone_password: ''/keystone_password: '$OS_PASSWORD'/g" openstack-manager-blueprint-inputs.yaml
+ echo "$0: Setup keystone_password"
+ sed -i -- "s/keystone_password: ''/keystone_password: '$OS_PASSWORD'/g" openstack-manager-blueprint-inputs.yaml
- echo "$0: Setup keystone_tenant_name"
- sed -i -- "s/keystone_tenant_name: ''/keystone_tenant_name: '$OS_TENANT_NAME'/g" openstack-manager-blueprint-inputs.yaml
+ echo "$0: Setup keystone_tenant_name"
+ sed -i -- "s/keystone_tenant_name: ''/keystone_tenant_name: '$OS_TENANT_NAME'/g" openstack-manager-blueprint-inputs.yaml
- echo "$0: Setup keystone_url"
- # Use ~ instead of / as regex delimeter, since this variable contains slashes
- sed -i -- "s~keystone_url: ''~keystone_url: '$OS_AUTH_URL'~g" openstack-manager-blueprint-inputs.yaml
+ echo "$0: Setup keystone_url"
+ # Use ~ instead of / as regex delimeter, since this variable contains slashes
+ sed -i -- "s~keystone_url: ''~keystone_url: '$OS_AUTH_URL'~g" openstack-manager-blueprint-inputs.yaml
- echo "$0: Setup region"
- sed -i -- "s/region: ''/region: '$OS_REGION_NAME'/g" openstack-manager-blueprint-inputs.yaml
+ echo "$0: Setup region"
+ sed -i -- "s/region: ''/region: '$OS_REGION_NAME'/g" openstack-manager-blueprint-inputs.yaml
- echo "$0: Setup manager_public_key_name"
- sed -i -- "s/#manager_public_key_name: ''/manager_public_key_name: 'cloudify-manager'/g" openstack-manager-blueprint-inputs.yaml
+ echo "$0: Setup manager_public_key_name"
+ sed -i -- "s/#manager_public_key_name: ''/manager_public_key_name: 'cloudify-manager'/g" openstack-manager-blueprint-inputs.yaml
- echo "$0: Setup agent_public_key_name"
- sed -i -- "s/#agent_public_key_name: ''/agent_public_key_name: 'cloudify-agent'/g" openstack-manager-blueprint-inputs.yaml
+ echo "$0: Setup agent_public_key_name"
+ sed -i -- "s/#agent_public_key_name: ''/agent_public_key_name: 'cloudify-agent'/g" openstack-manager-blueprint-inputs.yaml
- echo "$0: Setup image_id"
- # CentOS-7-x86_64-GenericCloud.qcow2 failed to be routable (?), so changed to 1607 version
- image=$(openstack image list | awk "/ CentOS-7-x86_64-GenericCloud-1607 / { print \$2 }")
- if [ -z $image ]; then
- glance --os-image-api-version 1 image-create --name CentOS-7-x86_64-GenericCloud-1607 --disk-format qcow2 --location http://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud-1607.qcow2 --container-format bare
- fi
- image=$(openstack image list | awk "/ CentOS-7-x86_64-GenericCloud-1607 / { print \$2 }")
- sed -i -- "s/image_id: ''/image_id: '$image'/g" openstack-manager-blueprint-inputs.yaml
+ echo "$0: Setup image_id"
+ # CentOS-7-x86_64-GenericCloud.qcow2 failed to be routable (?), so changed to 1607 version
+ image=$(openstack image list | awk "/ CentOS-7-x86_64-GenericCloud-1607 / { print \$2 }")
+ if [ -z $image ]; then
+ glance --os-image-api-version 1 image-create --name CentOS-7-x86_64-GenericCloud-1607 --disk-format qcow2 --location http://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud-1607.qcow2 --container-format bare
+ fi
+ image=$(openstack image list | awk "/ CentOS-7-x86_64-GenericCloud-1607 / { print \$2 }")
+ sed -i -- "s/image_id: ''/image_id: '$image'/g" openstack-manager-blueprint-inputs.yaml
- echo "$0: Setup flavor_id"
- flavor=$(nova flavor-show m1.large | awk "/ id / { print \$4 }")
- sed -i -- "s/flavor_id: ''/flavor_id: '$flavor'/g" openstack-manager-blueprint-inputs.yaml
+ echo "$0: Setup flavor_id"
+ flavor=$(nova flavor-show m1.large | awk "/ id / { print \$4 }")
+ sed -i -- "s/flavor_id: ''/flavor_id: '$flavor'/g" openstack-manager-blueprint-inputs.yaml
- echo "$0: Setup external_network_name"
- sed -i -- "s/external_network_name: ''/external_network_name: '$EXTERNAL_NETWORK_NAME'/g" openstack-manager-blueprint-inputs.yaml
+ echo "$0: Setup external_network_name"
+ sed -i -- "s/external_network_name: ''/external_network_name: '$EXTERNAL_NETWORK_NAME'/g" openstack-manager-blueprint-inputs.yaml
- # By default, only the cloudify-management-router is setup as DNS server, and it was failing to resolve internet domain names, which was blocking download of needed resources
- echo "$0: Add nameservers"
- sed -i -- "s/#management_subnet_dns_nameservers: \[\]/management_subnet_dns_nameservers: \[8.8.8.8\]/g" openstack-manager-blueprint-inputs.yaml
+ # By default, only the cloudify-management-router is setup as DNS server, and it was failing to resolve internet domain names, which was blocking download of needed resources
+ echo "$0: Add nameservers"
+ sed -i -- "s/#management_subnet_dns_nameservers: \[\]/management_subnet_dns_nameservers: \[8.8.8.8\]/g" openstack-manager-blueprint-inputs.yaml
- echo "$0: Bootstrap the manager"
- cfy bootstrap --install-plugins --keep-up-on-failure --task-retries=10 -p openstack-manager-blueprint.yaml -i openstack-manager-blueprint-inputs.yaml
+ echo "$0: Bootstrap the manager"
+ cfy bootstrap --install-plugins --keep-up-on-failure --task-retries=10 -p openstack-manager-blueprint.yaml -i openstack-manager-blueprint-inputs.yaml
- echo "$0: install needed packages to support blueprints 'not using managed plugins'"
- # See https://cloudifysource.atlassian.net/browse/CFY-5050
- cfy ssh -c "sudo yum install -y gcc gcc-c++ python-devel"
-else
- echo "$0: Prepare the Cloudify CLI prerequisites and data"
+ echo "$0: install needed packages to support blueprints 'not using managed plugins'"
+ # See https://cloudifysource.atlassian.net/browse/CFY-5050
+ cfy ssh -c "sudo yum install -y gcc gcc-c++ python-devel"
- echo "Create management network"
- if [ $(neutron net-list | awk "/ vnf_mgmt / { print \$2 }") ]; then
- echo "$0: vnf_mgmt network exists"
+ # Note setup_test_environment is not needed since the Manager sets up the
+ # needed networks etc
else
- neutron net-create vnf_mgmt
- echo "$0: Create management subnet"
- neutron subnet-create vnf_mgmt 10.0.0.0/24 --name vnf_mgmt --gateway 10.0.0.1 --enable-dhcp --allocation-pool start=10.0.0.2,end=10.0.0.254 --dns-nameserver 8.8.8.8
- fi
+ echo "$0: Prepare the Cloudify CLI prerequisites and data"
+
+ echo "Create management network"
+ if [ $(neutron net-list | awk "/ vnf_mgmt / { print \$2 }") ]; then
+ echo "$0: vnf_mgmt network exists"
+ else
+ neutron net-create vnf_mgmt
+ echo "$0: Create management subnet"
+ neutron subnet-create vnf_mgmt 10.0.0.0/24 --name vnf_mgmt --gateway 10.0.0.1 --enable-dhcp --allocation-pool start=10.0.0.2,end=10.0.0.254 --dns-nameserver 8.8.8.8
+ fi
- echo "$0: Create router for vnf_mgmt network"
- neutron router-create vnf_mgmt_router
+ setup_test_environment
+
+ echo "$0: Install Cloudify OpenStack Plugin"
+ # pip install https://github.com/cloudify-cosmo/cloudify-openstack-plugin/archive/1.4.zip
+ cd /tmp/cloudify
+ if [ -d "cloudify-openstack-plugin" ]; then rm -rf cloudify-openstack-plugin; fi
+ git clone https://github.com/cloudify-cosmo/cloudify-openstack-plugin.git
+ git checkout 1.4
+ echo "$0: Patch plugin.yaml to reference management network"
+ sed -i -- ":a;N;\$!ba;s/management_network_name:\n default: ''/management_network_name:\n default: 'vnf_mgmt'/" /tmp/cloudify/cloudify-openstack-plugin/plugin.yaml
+ cd cloudify-openstack-plugin
+ python setup.py build
+ python setup.py install
+
+ echo "$0: Install Cloudify Fabric (SSH) Plugin"
+ cd /tmp/cloudify
+ if [ -d "cloudify-fabric-plugin" ]; then rm -rf cloudify-fabric-plugin; fi
+ git clone https://github.com/cloudify-cosmo/cloudify-fabric-plugin.git
+ cd cloudify-fabric-plugin
+ git checkout 1.4
+ python setup.py build
+ python setup.py install
+ cd ..
+ fi
+}
- echo "$0: Create router gateway for vnf_mgmt network"
- neutron router-gateway-set vnf_mgmt_router $EXTERNAL_NETWORK_NAME
+dist=`grep DISTRIB_ID /etc/*-release | awk -F '=' '{print $2}'`
+case "$2" in
+ "init")
+ create_container
+ pass
+ ;;
+ "setup")
+ setup
+ pass
+ ;;
+ "clean")
+ source /tmp/cloudify/admin-openrc.sh
+ openstack router show vnf_mgmt_router
+ neutron router-gateway-clear vnf_mgmt_router
+ pid=($(neutron router-port-list vnf_mgmt_router|grep -v name|awk '{print $2}')); for id in ${pid[@]}; do neutron router-interface-delete vnf_mgmt_router vnf_mgmt; done
+ neutron router-delete vnf_mgmt_router
+ neutron net-delete vnf_mgmt
+ sudo docker stop $(sudo docker ps -a | awk "/cloudify/ { print \$1 }")
+ sudo docker rm -v $(sudo docker ps -a | awk "/cloudify/ { print \$1 }")
+ pass
+ ;;
+ *)
+ echo "usage: $ bash cloudify-setup.sh [cloudify-cli|cloudify-manager] [init|setup|clean]"
+ echo "cloudify-cli: use Cloudify CLI"
+ echo "cloudify-manager: use Cloudify Manager"
+ echo "init: Initialize docker container"
+ echo "setup: Setup of Cloudify in the docker container"
+ echo "clean: Clean"
+ exit 1
+esac
- echo "$0: Add router interface for vnf_mgmt network"
- neutron router-interface-add vnf_mgmt_router subnet=vnf_mgmt
-
- echo "$0: Install Cloudify OpenStack Plugin"
-# pip install https://github.com/cloudify-cosmo/cloudify-openstack-plugin/archive/1.4.zip
- cd /tmp/cloudify
- if [ -d "cloudify-openstack-plugin" ]; then rm -rf cloudify-openstack-plugin; fi
- git clone https://github.com/cloudify-cosmo/cloudify-openstack-plugin.git
- git checkout 1.4
- echo "$0: Patch plugin.yaml to reference management network"
- sed -i -- ":a;N;\$!ba;s/management_network_name:\n default: ''/management_network_name:\n default: 'vnf_mgmt'/" /tmp/cloudify/cloudify-openstack-plugin/plugin.yaml
- cd cloudify-openstack-plugin
- python setup.py build
- python setup.py install
-
- echo "$0: Install Cloudify Fabric (SSH) Plugin"
- cd /tmp/cloudify
- if [ -d "cloudify-fabric-plugin" ]; then rm -rf cloudify-fabric-plugin; fi
- git clone https://github.com/cloudify-cosmo/cloudify-fabric-plugin.git
- cd cloudify-fabric-plugin
- git checkout 1.4
- python setup.py build
- python setup.py install
- cd ..
-fi
diff --git a/tests/utils/tacker-setup.sh b/tests/utils/tacker-setup.sh
index c939419..aad1019 100644
--- a/tests/utils/tacker-setup.sh
+++ b/tests/utils/tacker-setup.sh
@@ -102,51 +102,7 @@ function get_external_net () {
fi
}
-function setup_test_environment () {
- echo "Create management network"
- if [ $(neutron net-list | awk "/ vnf_mgmt / { print \$2 }") ]; then
- echo "$0: vnf_mgmt network exists"
- else
- neutron net-create vnf_mgmt
- echo "$0: Create management subnet"
- neutron subnet-create vnf_mgmt 192.168.200.0/24 --name vnf_mgmt --gateway 192.168.200.1 --enable-dhcp --allocation-pool start=192.168.200.2,end=192.168.200.254 --dns-nameserver 8.8.8.8
- fi
-
- echo "$0: Create router for vnf_mgmt network"
- if [ $(neutron router-list | awk "/ vnf_mgmt / { print \$2 }") ]; then
- echo "$0: vnf_mgmt router exists"
- else
- neutron router-create vnf_mgmt_router
- echo "$0: Create router gateway for vnf_mgmt network"
- get_external_net
- neutron router-gateway-set vnf_mgmt_router $EXTERNAL_NETWORK_NAME
- echo "$0: Add router interface for vnf_mgmt network"
- neutron router-interface-add vnf_mgmt_router subnet=vnf_mgmt
- fi
-
- echo "Create private network"
- if [ $(neutron net-list | awk "/ vnf_private / { print \$2 }") ]; then
- echo "$0: vnf_private network exists"
- else
- neutron net-create vnf_private
- echo "$0: Create private subnet"
- neutron subnet-create vnf_private 192.168.201.0/24 --name vnf_private --gateway 192.168.201.1 --enable-dhcp --allocation-pool start=192.168.201.2,end=192.168.201.254 --dns-nameserver 8.8.8.8
- fi
-
- echo "$0: Create router for vnf_private network"
- if [ $(neutron router-list | awk "/ vnf_private / { print \$2 }") ]; then
- echo "$0: vnf_private router exists"
- else
- neutron router-create vnf_private_router
- echo "$0: Create router gateway for vnf_private network"
- get_external_net
- neutron router-gateway-set vnf_private_router $EXTERNAL_NETWORK_NAME
- echo "$0: Add router interface for vnf_private network"
- neutron router-interface-add vnf_private_router subnet=vnf_private
- fi
-}
-
-function create_tacker_container () {
+function create_container () {
echo "$0: Creating docker container for Tacker installation"
# STEP 1: Create the Tacker container and launch it
echo "$0: Copy this script to /tmp/tacker"
@@ -182,7 +138,7 @@ EOF
fi
}
-function install_tacker () {
+function setup () {
echo "$0: Installing Tacker"
# STEP 2: Install Tacker in the container
# Per http://docs.openstack.org/developer/tacker/install/manual_installation.html
@@ -314,39 +270,93 @@ project_name: admin
EOF
tacker vim-register --config-file vim-config.yaml --description OpenStack --name VIM0
+
+ setup_test_environment
+}
+
+function setup_test_environment () {
+ echo "Create management network"
+ if [ $(neutron net-list | awk "/ vnf_mgmt / { print \$2 }") ]; then
+ echo "$0: vnf_mgmt network exists"
+ else
+ neutron net-create vnf_mgmt
+ echo "$0: Create management subnet"
+ neutron subnet-create vnf_mgmt 192.168.200.0/24 --name vnf_mgmt --gateway 192.168.200.1 --enable-dhcp --allocation-pool start=192.168.200.2,end=192.168.200.254 --dns-nameserver 8.8.8.8
+ fi
+
+ echo "$0: Create router for vnf_mgmt network"
+ if [ $(neutron router-list | awk "/ vnf_mgmt / { print \$2 }") ]; then
+ echo "$0: vnf_mgmt router exists"
+ else
+ neutron router-create vnf_mgmt_router
+ echo "$0: Create router gateway for vnf_mgmt network"
+ get_external_net
+ neutron router-gateway-set vnf_mgmt_router $EXTERNAL_NETWORK_NAME
+ echo "$0: Add router interface for vnf_mgmt network"
+ neutron router-interface-add vnf_mgmt_router subnet=vnf_mgmt
+ fi
+
+ echo "Create private network"
+ if [ $(neutron net-list | awk "/ vnf_private / { print \$2 }") ]; then
+ echo "$0: vnf_private network exists"
+ else
+ neutron net-create vnf_private
+ echo "$0: Create private subnet"
+ neutron subnet-create vnf_private 192.168.201.0/24 --name vnf_private --gateway 192.168.201.1 --enable-dhcp --allocation-pool start=192.168.201.2,end=192.168.201.254 --dns-nameserver 8.8.8.8
+ fi
+
+ echo "$0: Create router for vnf_private network"
+ if [ $(neutron router-list | awk "/ vnf_private / { print \$2 }") ]; then
+ echo "$0: vnf_private router exists"
+ else
+ neutron router-create vnf_private_router
+ echo "$0: Create router gateway for vnf_private network"
+ get_external_net
+ neutron router-gateway-set vnf_private_router $EXTERNAL_NETWORK_NAME
+ echo "$0: Add router interface for vnf_private network"
+ neutron router-interface-add vnf_private_router subnet=vnf_private
+ fi
+}
+
+function clean () {
+ source /tmp/tacker/admin-openrc.sh
+ 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 }")
+ pid=($(neutron port-list|grep -v "+"|grep -v id|awk '{print $2}')); for id in ${pid[@]}; do neutron port-delete ${id}; done
+ sid=($(openstack stack list|grep -v "+"|grep -v id|awk '{print $2}')); for id in ${sid[@]}; do openstack stack delete ${id}; done
+ sid=($(openstack security group list|grep security_group_local_security_group|awk '{print $2}')); for id in ${sid[@]}; do openstack security group delete ${id}; done
+ neutron router-gateway-clear vnf_mgmt_router
+ pid=($(neutron router-port-list vnf_mgmt_router|grep -v name|awk '{print $2}')); for id in ${pid[@]}; do neutron router-interface-delete vnf_mgmt_router vnf_mgmt; done
+ neutron router-delete vnf_mgmt_router
+ neutron net-delete vnf_mgmt
+ neutron router-gateway-clear vnf_private_router
+ pid=($(neutron router-port-list vnf_private_router|grep -v name|awk '{print $2}')); for id in ${pid[@]}; do neutron router-interface-delete vnf_private_router vnf_private; done
+ neutron router-delete vnf_private_router
+ neutron net-delete vnf_private
+ sudo docker stop $(sudo docker ps -a | awk "/tacker/ { print \$1 }")
+ sudo docker rm -v $(sudo docker ps -a | awk "/tacker/ { print \$1 }")
}
dist=`grep DISTRIB_ID /etc/*-release | awk -F '=' '{print $2}'`
case "$2" in
"init")
- uid=$(openstack user list | awk "/ tacker / { print \$2 }")
- if [[ $uid ]]; then
- echo "$0: Tacker user exists, assuming Tacker service is already installed"
- else
- create_tacker_container
- fi
+ uid=$(openstack user list | awk "/ tacker / { print \$2 }")
+ if [[ $uid ]]; then
+ echo "$0: Remove prior Tacker user etc"
+ openstack user delete tacker
+ openstack service delete tacker
+ # Note: deleting the service deletes the endpoint
+ fi
+ create_container
pass
;;
"setup")
+ setup
+ pass
;;
"clean")
- source /tmp/tacker/admin-openrc.sh
- 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 }")
- pid=($(neutron port-list|grep -v "+"|grep -v id|awk '{print $2}')); for id in ${pid[@]}; do neutron port-delete ${id}; done
- sid=($(openstack stack list|grep -v "+"|grep -v id|awk '{print $2}')); for id in ${sid[@]}; do openstack stack delete ${id}; done
- sid=($(openstack security group list|grep security_group_local_security_group|awk '{print $2}')); for id in ${sid[@]}; do openstack security group delete ${id}; done
- neutron router-gateway-clear vnf_mgmt_router
- pid=($(neutron router-port-list vnf_mgmt_router|grep -v name|awk '{print $2}')); for id in ${pid[@]}; do neutron router-interface-delete vnf_mgmt_router vnf_mgmt; done
- neutron router-delete vnf_mgmt_router
- neutron net-delete vnf_mgmt
- neutron router-gateway-clear vnf_private_router
- pid=($(neutron router-port-list vnf_private_router|grep -v name|awk '{print $2}')); for id in ${pid[@]}; do neutron router-interface-delete vnf_private_router vnf_private; done
- neutron router-delete vnf_private_router
- neutron net-delete vnf_private
- sudo docker stop $(sudo docker ps -a | awk "/tacker/ { print \$1 }")
- sudo docker rm -v $(sudo docker ps -a | awk "/tacker/ { print \$1 }")
+ clean
pass
;;
*)
@@ -356,11 +366,3 @@ case "$2" in
echo "clean: remove Tacker service"
fail
esac
-
-echo "$0: Install Tacker and prerequisites"
-install_tacker
-
-echo "$0: Prepare Tacker test network environment"
-setup_test_environment
-cd /tmp/tacker
-pass
diff --git a/tests/vHello_Cloudify.sh b/tests/vHello_Cloudify.sh
new file mode 100644
index 0000000..831eab2
--- /dev/null
+++ b/tests/vHello_Cloudify.sh
@@ -0,0 +1,263 @@
+#!/bin/bash
+# Copyright 2016 AT&T Intellectual Property, Inc
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# What this is: Deployment test for the Cloudify Hello World blueprint.
+#
+# Status: this is a work in progress, under test.
+#
+# How to use:
+# $ wget https://git.opnfv.org/cgit/models/plain/tests/vHello.sh
+# $ bash vHello_Cloudify.sh [cloudify-cli|cloudify-manager] [setup|start|run|stop|clean]
+# cloudify-cli: use Cloudify CLI
+# cloudify-manager: use Cloudify Manager
+# setup: setup test environment
+# start: install blueprint and run test
+# run: setup test environment and run test
+# stop: stop test and uninstall blueprint
+# clean: cleanup after test
+
+set -x
+
+trap 'fail' ERR
+
+pass() {
+ echo "$0: Hooray!"
+ set +x #echo off
+ exit 0
+}
+
+fail() {
+ echo "$0: Test Failed!"
+ set +x
+ exit 1
+}
+
+function get_floating_net () {
+ network_ids=($(neutron net-list|grep -v "+"|grep -v name|awk '{print $2}'))
+ for id in ${network_ids[@]}; do
+ [[ $(neutron net-show ${id}|grep 'router:external'|grep -i "true") != "" ]] && floating_network_id=${id}
+ done
+ if [[ $floating_network_id ]]; then
+ floating_network_name=$(openstack network show $floating_network_id | awk "/ name / { print \$4 }")
+ else
+ echo "$0: Floating network not found"
+ fail
+ fi
+}
+
+try () {
+ count=$1
+ $3
+ while [[ $? -eq 1 && $count -gt 0 ]]
+ do
+ sleep $2
+ let count=$count-1
+ $3
+ done
+ if [[ $count -eq 0 ]]; then echo "$0: Command \"$3\" was not successful after $1 tries"; fi
+}
+
+select_manager() {
+ echo "$0: select manager to use"
+ MANAGER_IP=$(openstack server list | awk "/ cloudify-manager-server / { print \$9 }")
+ cfy use -t $MANAGER_IP
+ if [ $? -eq 1 ]; then fail; fi
+}
+
+setup() {
+ echo "$0: Setup temp test folder /tmp/cloudify and copy this script there"
+ mkdir /tmp/cloudify
+ chmod 777 /tmp/cloudify/
+ cp $0 /tmp/cloudify/.
+ chmod 755 /tmp/cloudify/*.sh
+
+ echo "$0: cloudify-setup part 1"
+ bash utils/cloudify-setup.sh $1 init
+
+ echo "$0: cloudify-setup part 2"
+ CONTAINER=$(sudo docker ps -l | awk "/cloudify/ { print \$1 }")
+ sudo docker exec $CONTAINER /bin/bash /tmp/cloudify/cloudify-setup.sh $1 setup
+ if [ $? -eq 1 ]; then fail; fi
+ pass
+}
+
+start() {
+ echo "$0: reset blueprints folder"
+ if [[ -d /tmp/cloudify/blueprints ]]; then rm -rf /tmp/cloudify/blueprints; fi
+ mkdir -p /tmp/cloudify/blueprints
+ cd /tmp/cloudify/blueprints
+
+ echo "$0: clone cloudify-hello-world-example"
+ if [[ "$1" == "cloudify-manager" ]]; then
+ git clone https://github.com/cloudify-cosmo/cloudify-hello-world-example.git
+ cd cloudify-hello-world-example
+ git checkout 3.4.1-build
+ else
+ git clone https://github.com/blsaws/cloudify-cli-hello-world-example.git
+ cd cloudify-cli-hello-world-example
+ fi
+
+ cd /tmp/cloudify/blueprints
+
+ echo "$0: setup OpenStack CLI environment"
+ source /tmp/cloudify/admin-openrc.sh
+
+ echo "$0: Setup image_id"
+# image=$(openstack image list | awk "/ CentOS-7-x86_64-GenericCloud-1607 / { print \$2 }")
+ image=$(openstack image list | awk "/ xenial-server / { print \$2 }")
+ if [ -z $image ]; then
+# glance --os-image-api-version 1 image-create --name CentOS-7-x86_64-GenericCloud-1607 --disk-format qcow2 --location http://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud-1607.qcow2 --container-format bare
+ glance --os-image-api-version 1 image-create --name xenial-server --disk-format qcow2 --location http://cloud-images.ubuntu.com/xenial/current/xenial-server-cloudimg-amd64-disk1.img --container-format bare
+ fi
+# image=$(openstack image list | awk "/ CentOS-7-x86_64-GenericCloud-1607 / { print \$2 }")
+ image=$(openstack image list | awk "/ xenial-server / { print \$2 }")
+
+ if [[ "$1" == "cloudify-manager" ]]; then
+ echo "$0: create Cloudify Manager blueprint inputs file"
+ # Set host image per Cloudify agent compatibility: http://docs.getcloudify.org/3.4.0/agents/overview/
+ cd /tmp/cloudify/blueprints
+ cat <<EOF >vHello-inputs.yaml
+image: xenial-server
+flavor: m1.small
+agent_user: ubuntu
+webserver_port: 8080
+EOF
+ else
+ # Cloudify CLI use
+ echo "$0: Get external network for Floating IP allocations"
+ get_floating_net
+
+ echo "$0: Create Nova key pair"
+ mkdir -p ~/.ssh
+ nova keypair-delete vHello
+ nova keypair-add vHello > ~/.ssh/vHello.pem
+ chmod 600 ~/.ssh/vHello.pem
+
+ echo "$0: create Cloudify CLI blueprint inputs file"
+ cat <<EOF >vHello-inputs.yaml
+image: xenial-server
+flavor: m1.small
+external_network_name: $floating_network_name
+webserver_port: 8080
+key_name: vHello
+ssh_key_filename: /root/.ssh/vHello.pem
+ssh_user: ubuntu
+ssh_port: 22
+EOF
+ fi
+
+ echo "$0: initialize cloudify environment"
+ cd /tmp/cloudify/blueprints
+ cfy init -r
+
+ if [[ "$1" == "cloudify-manager" ]]; then
+ select_manager
+ echo "$0: upload blueprint via manager"
+ cfy blueprints delete -b cloudify-hello-world-example
+ cfy blueprints upload -p cloudify-hello-world-example/blueprint.yaml -b cloudify-hello-world-example
+ if [ $? -eq 1 ]; then fail; fi
+
+ echo "$0: create vHello deployment via manager"
+ cfy deployments create --debug -d vHello -i vHello-inputs.yaml -b cloudify-hello-world-example
+ if [ $? -eq 1 ]; then fail; fi
+
+ echo "$0: execute 'install' workflow for vHello deployment via manager"
+ cfy executions start -w install -d vHello --timeout 1800
+ if [ $? -eq 1 ]; then fail; fi
+
+ echo "$0: get vHello server address"
+ SERVER_URL=$(cfy deployments outputs -d vHello | awk "/ Value: / { print \$2 }")
+ else
+ echo "$0: install local blueprint"
+ # don't use --install-plugins, causes openstack plugin 1.4.1 to be rolled back to 1.4 and then an error
+ cfy local install -i vHello-inputs.yaml -p cloudify-cli-hello-world-example/blueprint.yaml --allow-custom-parameters --parameters="floating_network_name=$floating_network_name" --task-retries=10 --task-retry-interval=30
+ if [ $? -eq 1 ]; then fail; fi
+
+ echo "$0: get vHello server address"
+ SERVER_URL=$(cfy local outputs | awk "/http_endpoint/ { print \$2 }" | sed -- 's/"//g')
+ fi
+
+ echo "$0: verify vHello server is running"
+ apt-get install -y curl
+ if [[ $(curl $SERVER_URL | grep -c "Hello, World!") != 1 ]]; then fail; fi
+
+ pass
+}
+
+stop() {
+ echo "$0: setup OpenStack CLI environment"
+ source /tmp/cloudify/admin-openrc.sh
+
+ echo "$0: initialize cloudify environment"
+ cd /tmp/cloudify/blueprints
+
+ if [[ "$1" == "cloudify-manager" ]]; then
+ select_manager
+ echo "$0: uninstall vHello blueprint via manager"
+ cfy executions start -w uninstall -d vHello
+ if [ $? -eq 1 ]; then fail; fi
+
+ echo "$0: delete vHello blueprint"
+ cfy deployments delete -d vHello
+ if [ $? -eq 1 ]; then fail; fi
+ else
+ echo "$0: uninstall vHello blueprint via CLI"
+ cfy local uninstall
+ if [ $? -eq 1 ]; then fail; fi
+ fi
+ pass
+}
+
+forward_to_container () {
+ echo "$0: pass $2 command to vHello.sh in cloudify container"
+ CONTAINER=$(sudo docker ps -a | awk "/cloudify/ { print \$1 }")
+ sudo docker exec $CONTAINER /bin/bash /tmp/cloudify/vHello_Cloudify.sh $1 $2 $2
+ if [ $? -eq 1 ]; then fail; fi
+}
+
+dist=`grep DISTRIB_ID /etc/*-release | awk -F '=' '{print $2}'`
+case "$2" in
+ setup)
+ setup $1
+ pass
+ ;;
+ run)
+ setup $1
+ forward_to_container $1 start
+ pass
+ ;;
+ start|stop)
+ if [[ $# -eq 2 ]]; then forward_to_container $1 $2
+ else
+ # running inside the cloudify container, ready to go
+ $2 $1
+ fi
+ pass
+ ;;
+ clean)
+ clean $1
+ pass
+ ;;
+ *)
+ echo "usage: bash vHello_cloudify.sh [cloudify-cli|cloudify-api] [setup|start|run|clean]"
+ echo "cloudify-cli: use Cloudify CLI"
+ echo "cloudify-manager: use Cloudify Manager"
+ echo "setup: setup test environment"
+ echo "start: install blueprint and run test"
+ echo "run: setup test environment and run test"
+ echo "stop: stop test and uninstall blueprint"
+ echo "clean: cleanup after test"
+ fail
+esac
diff --git a/tests/vHello_Tacker.sh b/tests/vHello_Tacker.sh
index 6541aa2..4868db6 100644
--- a/tests/vHello_Tacker.sh
+++ b/tests/vHello_Tacker.sh
@@ -45,7 +45,7 @@ fail() {
exit 1
}
-function get_floating_net () {
+get_floating_net () {
network_ids=($(neutron net-list|grep -v "+"|grep -v name|awk '{print $2}'))
for id in ${network_ids[@]}; do
[[ $(neutron net-show ${id}|grep 'router:external'|grep -i "true") != "" ]] && floating_network_id=${id}
@@ -58,7 +58,19 @@ function get_floating_net () {
fi
}
-function setup () {
+try () {
+ count=$1
+ $3
+ while [[ $? -eq 1 && $count -gt 0 ]]
+ do
+ sleep $2
+ let count=$count-1
+ $3
+ done
+ if [[ $count -eq 0 ]]; then echo "$0: Command \"$3\" was not successful after $1 tries"; fi
+}
+
+setup () {
echo "$0: 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
@@ -73,8 +85,13 @@ function setup () {
CONTAINER=$(sudo docker ps -l | awk "/tacker/ { print \$1 }")
dist=`grep DISTRIB_ID /etc/*-release | awk -F '=' '{print $2}'`
if [ "$dist" == "Ubuntu" ]; then
+ echo "$0: JOID workaround for Colorado - enable ML2 port security"
+ juju set neutron-api enable-ml2-port-security=true
+
+ echo "$0: Execute tacker-setup.sh in the container"
sudo docker exec -it $CONTAINER /bin/bash /tmp/tacker/tacker-setup.sh $1 setup
else
+ echo "$0: Execute tacker-setup.sh in the container"
sudo docker exec -i -t $CONTAINER /bin/bash /tmp/tacker/tacker-setup.sh $1 setup
fi
@@ -113,7 +130,7 @@ function setup () {
# Using pre-key-injected image for now, vHello.pem as provided in the blueprint
if [ ! -f /tmp/xenial-server-cloudimg-amd64-disk1.img ]; then
- wget -O /tmp/xenial-server-cloudimg-amd64-disk1.img http://bkaj.net/opnfv/xenial-server-cloudimg-amd64-disk1.img
+ wget -O /tmp/xenial-server-cloudimg-amd64-disk1.img http://artifacts.opnfv.org/models/images/xenial-server-cloudimg-amd64-disk1.img
fi
cp blueprints/tosca-vnfd-hello-world-tacker/vHello.pem /tmp/tacker
chmod 600 /tmp/tacker/vHello.pem
@@ -224,7 +241,8 @@ stop() {
vid=($(tacker vnf-list|grep hello-world-tacker|awk '{print $2}')); for id in ${vid[@]}; do tacker vnf-delete ${id}; done
vid=($(tacker vnfd-list|grep hello-world-tacker|awk '{print $2}')); for id in ${vid[@]}; do tacker vnfd-delete ${id}; done
fip=($(neutron floatingip-list|grep -v "+"|grep -v id|awk '{print $2}')); for id in ${fip[@]}; do neutron floatingip-delete ${id}; done
- sg=($(openstack security group list|grep vHello|awk '{print $2}')); for id in ${sg[@]}; do openstack security group delete ${id}; done
+ sg=($(openstack security group list|grep vHello|awk '{print $2}'))
+ for id in ${sg[@]}; do try 5 5 "openstack security group delete ${id}"; done
fi
}