Working version of cloudify-setup and other scripts 07/18107/1
authorblsaws <bryan.sullivan@att.com>
Sat, 6 Aug 2016 02:26:21 +0000 (19:26 -0700)
committerblsaws <bryan.sullivan@att.com>
Sat, 6 Aug 2016 02:26:21 +0000 (19:26 -0700)
JIRA: MODELS-23

Change-Id: Iaebdac67c2d484f9d09aee53f12f6b8cdff2c4e5
Signed-off-by: blsaws <bryan.sullivan@att.com>
.gitreview [new file with mode: 0644]
tests/utils/cloudify-clean.sh [new file with mode: 0644]
tests/utils/cloudify-setup.sh
tests/vHello.sh [new file with mode: 0644]

diff --git a/.gitreview b/.gitreview
new file mode 100644 (file)
index 0000000..366d059
--- /dev/null
@@ -0,0 +1,5 @@
+[gerrit]
+host=gerrit.opnfv.org
+port=29418
+project=models.git
+
diff --git a/tests/utils/cloudify-clean.sh b/tests/utils/cloudify-clean.sh
new file mode 100644 (file)
index 0000000..594afec
--- /dev/null
@@ -0,0 +1,115 @@
+#!/bin/bash
+# Copyright 2015-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: Cleanup script for the Cloudify Manager running in an
+# Unbuntu Xenial docker container.
+#
+# Status: this is a work in progress, under test.#
+#
+# Prerequisites:
+#   $ bash /tmp/cloudify/cloudify-setup.sh
+#
+# How to use:
+#   $ bash cloudify-clean.sh
+
+function setenv () {
+mkdir /tmp/cloudify
+if [ "$dist" == "Ubuntu" ]; then
+  echo "cloudify-clean.sh: Ubuntu-based install"
+  echo "cloudify-clean.sh: Create the environment file"
+  KEYSTONE_HOST=$(juju status --format=short | awk "/keystone\/0/ { print \$3 }")
+  cat <<EOF >/tmp/cloudify/admin-openrc
+export CONGRESS_HOST=$(juju status --format=short | awk "/openstack-dashboard/ { print \$3 }")
+export HORIZON_HOST=$(juju status --format=short | awk "/openstack-dashboard/ { print \$3 }")
+export KEYSTONE_HOST=$KEYSTONE_HOST
+export CEILOMETER_HOST=$(juju status --format=short | awk "/ceilometer\/0/ { print \$3 }")
+export CINDER_HOST=$(juju status --format=short | awk "/cinder\/0/ { print \$3 }")
+export GLANCE_HOST=$(juju status --format=short | awk "/glance\/0/ { print \$3 }")
+export NEUTRON_HOST=$(juju status --format=short | awk "/neutron-api\/0/ { print \$3 }")
+export NOVA_HOST=$(juju status --format=short | awk "/nova-cloud-controller\/0/ { print \$3 }")
+export OS_USERNAME=admin
+export OS_PASSWORD=openstack
+export OS_TENANT_NAME=admin
+export OS_AUTH_URL=http://$KEYSTONE_HOST:5000/v2.0
+export OS_REGION_NAME=RegionOne
+EOF
+else
+  # Centos
+  echo "cloudify-clean.sh: Centos-based install"
+  echo "cloudify-clean.sh: Setup undercloud environment so we can get overcloud Controller server address"
+  source ~/stackrc
+  echo "cloudify-clean.sh: Get address of Controller node"
+  export CONTROLLER_HOST1=$(openstack server list | awk "/overcloud-controller-0/ { print \$8 }" | sed 's/ctlplane=//g')
+  echo "cloudify-clean.sh: Create the environment file"
+  cat <<EOF >/tmp/cloudify/admin-openrc
+export CONGRESS_HOST=$CONTROLLER_HOST1
+export KEYSTONE_HOST=$CONTROLLER_HOST1
+export CEILOMETER_HOST=$CONTROLLER_HOST1
+export CINDER_HOST=$CONTROLLER_HOST1
+export GLANCE_HOST=$CONTROLLER_HOST1
+export NEUTRON_HOST=$CONTROLLER_HOST1
+export NOVA_HOST=$CONTROLLER_HOST1
+EOF
+  cat ~/overcloudrc >>/tmp/cloudify/admin-openrc
+  source ~/overcloudrc
+  export OS_REGION_NAME=$(openstack endpoint list | awk "/ nova / { print \$4 }")
+  # sed command below is a workaound for a bug - region shows up twice for some reason
+  cat <<EOF | sed '$d' >>/tmp/cloudify/admin-openrc
+export OS_REGION_NAME=$OS_REGION_NAME
+EOF
+fi
+source /tmp/cloudify/admin-openrc
+}
+
+dist=`grep DISTRIB_ID /etc/*-release | awk -F '=' '{print $2}'`
+setenv
+
+echo "cloudify-clean.sh: delete Manager server"
+openstack server delete cloudify-manager-server
+
+echo "cloudify-clean.sh: delete floating IPs"
+flip=($(neutron floatingip-list|grep -v "+"|grep -v id|awk '{print $2}')); for id in ${flip[@]}; do neutron floatingip-delete ${id}; done
+
+echo "cloudify-clean.sh: clear cloudify-management-router gateway"
+neutron router-gateway-clear cloudify-management-router
+
+echo "cloudify-clean.sh: delete cloudify-manager-port"
+neutron port-delete cloudify-manager-port
+
+echo "cloudify-clean.sh: delete other ports"
+port=($(neutron port-list|grep -v "+"|grep -v name|awk '{print $2}')); for id in ${port[@]}; do neutron port-delete ${id}; done
+
+echo "cloudify-clean.sh: delete cloudify securituy groups"
+openstack security group delete cloudify-sg-manager 
+openstack security group delete cloudify-sg-agents 
+
+echo "cloudify-clean.sh: delete cloudify-management-router on cloudify-management-network-subnet"
+neutron router-interface-delete cloudify-management-router cloudify-management-network-subnet
+
+echo "cloudify-clean.sh: delete cloudify-management-router"
+neutron router-delete cloudify-management-router 
+
+echo "cloudify-clean.sh: delete cloudify-management-network-subnet"
+neutron subnet-delete cloudify-management-network-subnet
+
+echo "cloudify-clean.sh: delete cloudify-management-network"
+neutron net-delete cloudify-management-network
+
+echo "cloudify-clean.sh: delete cloudify-manager keypair"
+openstack keypair delete cloudify-manager 
+
+echo "cloudify-clean.sh: delete cloudify-agent keypair"
+openstack keypair delete cloudify-agent
+
index f5385e8..876fe23 100644 (file)
@@ -1,5 +1,5 @@
 #!/bin/bash
-# Copyright 2015-2016 AT&T Intellectual Property, Inc
+# 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.
 # limitations under the License.
 #
 # What this is: Setup script for the Cloudify Manager starting from an
-# Unbuntu Trusty docker container.
+# Unbuntu Xenial docker container.
 #
 # Status: this is a work in progress, under test.
 #
 # How to use:
-#   Save this file in ~/cloudify/cloudify-setup.sh
-#   $ bash ~/cloudify/cloudify-setup.sh [ 1 || 2 ]
+#   Save this file in /tmp/cloudify/cloudify-setup.sh
+#   $ bash /tmp/cloudify/cloudify-setup.sh [ 1 || 2 ]
 #   1: Initial setup of the docker container
 #   2: Setup of the Cloudify Manager in the docker container
 
-# Find external network name
-
 function setenv () {
-
 if [ "$dist" == "Ubuntu" ]; then
-  echo "Create the environment file"
+  echo "cloudify-setup.sh: Ubuntu-based install"
+  echo "cloudify-setup.sh: Create the environment file"
   KEYSTONE_HOST=$(juju status --format=short | awk "/keystone\/0/ { print \$3 }")
-  cat <<EOF >~/admin-openrc
+  cat <<EOF >/tmp/cloudify/admin-openrc
 export CONGRESS_HOST=$(juju status --format=short | awk "/openstack-dashboard/ { print \$3 }")
 export HORIZON_HOST=$(juju status --format=short | awk "/openstack-dashboard/ { print \$3 }")
 export KEYSTONE_HOST=$KEYSTONE_HOST
@@ -48,13 +46,13 @@ export OS_REGION_NAME=RegionOne
 EOF
 else
   # Centos
-  echo "Centos-based install"
-  echo "Setup undercloud environment so we can get overcloud Controller server address"
+  echo "cloudify-setup.sh: Centos-based install"
+  echo "cloudify-setup.sh: Setup undercloud environment so we can get overcloud Controller server address"
   source ~/stackrc
-  echo "Get address of Controller node"
+  echo "cloudify-setup.sh: Get address of Controller node"
   export CONTROLLER_HOST1=$(openstack server list | awk "/overcloud-controller-0/ { print \$8 }" | sed 's/ctlplane=//g')
-  echo "Create the environment file"
-  cat <<EOF >~/admin-openrc
+  echo "cloudify-setup.sh: Create the environment file"
+  cat <<EOF >/tmp/cloudify/admin-openrc
 export CONGRESS_HOST=$CONTROLLER_HOST1
 export KEYSTONE_HOST=$CONTROLLER_HOST1
 export CEILOMETER_HOST=$CONTROLLER_HOST1
@@ -63,15 +61,15 @@ export GLANCE_HOST=$CONTROLLER_HOST1
 export NEUTRON_HOST=$CONTROLLER_HOST1
 export NOVA_HOST=$CONTROLLER_HOST1
 EOF
-  cat ~/overcloudrc >>~/admin-openrc
+  cat ~/overcloudrc >>/tmp/cloudify/admin-openrc
   source ~/overcloudrc
   export OS_REGION_NAME=$(openstack endpoint list | awk "/ nova / { print \$4 }")
   # sed command below is a workaound for a bug - region shows up twice for some reason
-  cat <<EOF | sed '$d' >>~/admin-openrc
+  cat <<EOF | sed '$d' >>/tmp/cloudify/admin-openrc
 export OS_REGION_NAME=$OS_REGION_NAME
 EOF
 fi
-source ~/admin-openrc
+source /tmp/cloudify/admin-openrc
 }
 
 function get_external_net () {
@@ -90,6 +88,11 @@ function get_external_net () {
 
 dist=`grep DISTRIB_ID /etc/*-release | awk -F '=' '{print $2}'`
 if [ "$1" == "1" ]; then
+  echo "cloudify-setup.sh: Copy this script to /tmp/cloudify"
+  if [ -d "/tmp/cloudify" ]; then rm -rf /tmp/cloudify; fi  
+  mkdir /tmp/cloudify
+  cp $0 /tmp/cloudify/.
+
   echo "cloudify-setup.sh: Setup admin-openrc"
   setenv
   echo "cloudify-setup.sh: Setup container"
@@ -97,7 +100,8 @@ if [ "$1" == "1" ]; 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:/root/admin-openrc -v ~/cloudify/cloudify-setup.sh:/root/cloudify-setup.sh ubuntu:xenial /bin/bash
+#    sudo docker run -it  -v ~/git/joid/ci/cloud/admin-openrc:/root/admin-openrc -v ~/cloudify/cloudify-setup.sh:/root/cloudify-setup.sh ubuntu:xenial /bin/bash
+    sudo docker run -it -d -v ~/tmp/cloudify/admin-openrc:/root/admin-openrc -v /tmp/cloudify/cloudify-setup.sh:/root/cloudify-setup.sh ubuntu:xenial /bin/bash
     exit 0
   fi
 else 
@@ -110,6 +114,7 @@ else
       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
@@ -130,12 +135,12 @@ echo "cloudify-setup.sh: Upgrage pip again - needs to be the latest version due
 pip install --upgrade pip
 
 echo "cloudify-setup.sh: install python-openstackclient python-glanceclient"
-pip install python-openstackclient python-glanceclient  python-neutronclient
+pip install --upgrade python-openstackclient python-glanceclient  python-neutronclient
 
 echo "cloudify-setup.sh: cleanup any previous install attempt"
-rm -rf cloudify
-rm -rf cloudify-manager
-rm get-cloudify.py
+if [ -d "~/cloudify" ]; then rm -rf ~/cloudify; fi  
+if [ -d "~/cloudify-manager" ]; then rm -rf ~/cloudify-manager; fi  
+rm ~/get-cloudify.py
 
 echo "cloudify-setup.sh: Create virtualenv"
 virtualenv ~/cloudify/venv
@@ -204,3 +209,8 @@ sed -i -- "s/#management_subnet_dns_nameservers: \[\]/management_subnet_dns_name
 echo "cloudify-setup.sh: Bootstrap the manager"
 cfy bootstrap --install-plugins --keep-up-on-failure -p openstack-manager-blueprint.yaml -i openstack-manager-blueprint-inputs.yaml
 
+echo "cloudify-setup.sh: install needed packages on the manager 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"
+
+
diff --git a/tests/vHello.sh b/tests/vHello.sh
new file mode 100644 (file)
index 0000000..2a98ef5
--- /dev/null
@@ -0,0 +1,106 @@
+#!/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:
+#   Save this file and cloudify-setup.sh in ~/tmp/cloudify/
+#   $ bash /tmp/cloudify/vHello.sh [setup | start | clean]
+#   setup: setup Cloudify Manager
+#   start: run test
+#   clean: cleanup after test
+
+pass() {
+  echo "Hooray!"
+  set +x #echo off
+  exit 0
+}
+
+# Use this to trigger fail() at the right places
+# if [ "$RESULT" == "Test Failed!" ]; then fail; fi
+fail() {
+  echo "Test Failed!"
+  set +x
+  exit 1
+}
+
+if [[ "$1" == "setup" ]]; then
+  echo "vHello.sh: cloudify-setup part 1"
+  bash /tmp/cloudify/cloudify-setup.sh 1
+
+  echo "vHello.sh: cloudify-setup part 2"
+  CONTAINER=$(sudo docker ps -l | awk "/ ubuntu:xenial / { print \$1 }")
+  if [[ $(sudo docker exec $CONTAINER /root/cloudify-setup.sh 2) ]]; then fail; fi
+  pass
+fi
+
+if [[ "$1" == "start" ]]; then
+  echo "vHello.sh: run vHello test in cloudify-setup container"
+  CONTAINER=$(sudo docker ps -l | awk "/ ubuntu:xenial / { print \$1 }")
+  if [[ $(sudo docker exec $CONTAINER /root/vHello.sh) ]]; then fail; fi
+  pass
+fi
+
+echo "vHello.sh: 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
+
+if [[ "$1" == "clean" ]]; then
+  echo "vHello.sh: uninstall vHello blueprint"
+  cfy executions start -w uninstall -d vHello
+
+  echo "vHello.sh: delete vHello blueprint"
+  cfy deployments delete -d vHello
+  if [ $? -eq 1 ]; then fail; fi
+  pass
+fi
+
+echo "vHello.sh: reset blueprints folder"
+cd ~
+rm -rf blueprints
+mkdir blueprints
+
+echo "vHello.sh: clone cloudify-hello-world-example"
+cd blueprints
+git clone https://github.com/cloudify-cosmo/cloudify-hello-world-example.git
+git checkout 3.4.1-build
+
+echo "vHello.sh: create blueprint inputs file"
+# Set host image per Cloudify agent compatibility: http://docs.getcloudify.org/3.4.0/agents/overview/
+cat <<EOF >vHello-inputs.yaml
+  image: CentOS-7-x86_64-GenericCloud-1607
+  flavor: m1.small
+  agent_user: centos
+  webserver_port: 8080
+EOF
+
+echo "vHello.sh: create vHello deployment"
+cfy deployments create --debug -d vHello -i vHello-inputs.yaml -b cloudify-hello-world-example
+if [ $? -eq 1 ]; then fail; fi
+
+echo "vHello.sh: execute 'install' workflow for vHello deployment"
+cfy executions start -w install -d vHello --timeout 1800
+if [ $? -eq 1 ]; then fail; fi
+
+echo "vHello.sh: verify vHello server is running"
+SERVER_IP=$(cfy deployments outputs -d vHello | awk "/ Value: / { print \$2 }")
+apt-get install -y curl
+if [[ $(curl $SERVER_IP | grep -c "Hello, World!") != 1 ]]; then fail; fi
+
+pass
+