From 3f0e3bb3cf85c94791c20ba0dc13532fc4f5a5ff Mon Sep 17 00:00:00 2001 From: blsaws Date: Sun, 22 May 2016 12:01:53 -0700 Subject: Merge JOID and Apex installs. JIRA: COPPER-2 Change-Id: I805644ff08d7a61a67469186890cd9920344025e Signed-off-by: blsaws --- .../congress/install/bash/centos/clean_congress.sh | 59 ------ .../install/bash/centos/install_congress_1.sh | 179 ----------------- .../install/bash/centos/install_congress_2.sh | 153 -------------- components/congress/install/bash/clean_congress.sh | 71 +++++++ .../congress/install/bash/install_congress_1.sh | 221 +++++++++++++++++++++ .../congress/install/bash/install_congress_2.sh | 202 +++++++++++++++++++ .../setup/install_congress_testserver_1.sh | 127 ------------ .../setup/install_congress_testserver_2.sh | 137 ------------- 8 files changed, 494 insertions(+), 655 deletions(-) delete mode 100644 components/congress/install/bash/centos/clean_congress.sh delete mode 100644 components/congress/install/bash/centos/install_congress_1.sh delete mode 100644 components/congress/install/bash/centos/install_congress_2.sh create mode 100644 components/congress/install/bash/clean_congress.sh create mode 100644 components/congress/install/bash/install_congress_1.sh create mode 100644 components/congress/install/bash/install_congress_2.sh delete mode 100644 components/congress/test-webapp/setup/install_congress_testserver_1.sh delete mode 100644 components/congress/test-webapp/setup/install_congress_testserver_2.sh (limited to 'components') diff --git a/components/congress/install/bash/centos/clean_congress.sh b/components/congress/install/bash/centos/clean_congress.sh deleted file mode 100644 index 27d6193..0000000 --- a/components/congress/install/bash/centos/clean_congress.sh +++ /dev/null @@ -1,59 +0,0 @@ -#!/bin/bash -# CCopyright 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. -# -# This is a cleanup script for installation of Congress on the Centos 7 based -# OPNFV Controller node as installed per the OPNFV Apex project. -# Prequisites: -# Presumably something has failed, and any record of the Congress feature -# in OpenStack needs to be removed, so you can try the install again. -# -# Prequisite: -# OPFNV install per https://wiki.opnfv.org/display/copper/Apex -# How to use: -# cd ~/git/copper/ -# source /components/congress/install/bash/centos/clean_congress.sh - -cd ~ -# Setup undercloud environment so we can get overcloud Controller server address -source ~/stackrc - -# Get addresses of Controller node(s) -export CONTROLLER_HOST1=$(openstack server list | awk "/overcloud-controller-0/ { print \$8 }" | sed 's/ctlplane=//g') -export CONTROLLER_HOST2=$(openstack server list | awk "/overcloud-controller-1/ { print \$8 }" | sed 's/ctlplane=//g') - -echo "Stop the Congress service" -ssh -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no heat-admin@$CONGRESS_HOST "pkill congress-server; exit" - -echo "Remove the Congress virtualenv and code" -ssh -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no heat-admin@$CONGRESS_HOST "rm -rf ~/congress; exit" - -# Setup env for overcloud API access -source ~/overcloudrc - -# Delete Congress user -export CONGRESS_USER=$(openstack user list | awk "/ congress / { print \$2 }") -if [ "$CONGRESS_USER" != "" ]; then - openstack user delete $CONGRESS_USER -fi - -# Delete Congress service -export CONGRESS_SERVICE=$(openstack service list | awk "/ congress / { print \$2 }") -if [ "$CONGRESS_SERVICE" != "" ]; then - openstack service delete $CONGRESS_SERVICE -fi - -# Delete Congress and other installed code in virtualenv -rm -rf ~/congress - diff --git a/components/congress/install/bash/centos/install_congress_1.sh b/components/congress/install/bash/centos/install_congress_1.sh deleted file mode 100644 index 166f475..0000000 --- a/components/congress/install/bash/centos/install_congress_1.sh +++ /dev/null @@ -1,179 +0,0 @@ -#!/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. -# -# This is script 1 of 2 for installation of Congress on the Centos 7 based -# OPNFV Controller node as installed per the OPNFV Apex project. -# Prequisites: -# OPFNV install per https://wiki.opnfv.org/display/copper/Apex -# On the jumphost, logged in as stack on the undercloud VM: -# su stack -# Clone the Copper repo and run the install script: -# mkdir ~/git; cd git; git clone https://gerrit.opnfv.org/gerrit/copper -# cd copper -# source components/congress/install/bash/centos/install_congress_1.sh - -if [ $# -gt 1 ] && [ $2 == "debug" ]; then set -x #echo on -fi - -cd ~ -# Setup undercloud environment so we can get overcloud Controller server address -source ~/stackrc - -# Get addresses of Controller node(s) -export CONTROLLER_HOST1=$(openstack server list | awk "/overcloud-controller-0/ { print \$8 }" | sed 's/ctlplane=//g') -export CONTROLLER_HOST2=$(openstack server list | awk "/overcloud-controller-1/ { print \$8 }" | sed 's/ctlplane=//g') - -echo "Create the environment file and copy to the congress server" -mkdir ~/congress -cat <~/congress/env.sh -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 -source ~/congress/env.sh -scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ~/congress/env.sh heat-admin@$CONTROLLER_HOST1:/home/heat-admin - -# Setup env for overcloud API access and copy to congress server -source ~/overcloudrc -export OS_REGION_NAME=$(openstack endpoint list | awk "/ nova / { print \$4 }") -cp ~/overcloudrc ~/congress/admin-openrc.sh -# sed command below is a workaound for a bug - region shows up twice for some reason -cat <>~/congress/admin-openrc.sh -export OS_REGION_NAME=$OS_REGION_NAME -EOF -ssh -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no heat-admin@$CONTROLLER_HOST1 "mkdir ~/congress; exit" -scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ~/congress/admin-openrc.sh heat-admin@$CONTROLLER_HOST1:/home/heat-admin/congress - -echo "Copy install_congress_2.sh to the congress server and execute" -scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ~/git/copper/components/congress/install/bash/centos/install_congress_2.sh heat-admin@$CONTROLLER_HOST1:/home/heat-admin/congress -ssh -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no heat-admin@$CONTROLLER_HOST1 "source ~/congress/install_congress_2.sh; exit" - -echo "Install jumphost dependencies" - -echo "install pip" -sudo yum install python-pip -y - -echo "install other dependencies" -sudo yum install apg git gcc libxml2 python-devel libzip-devel libxslt-devel -y -sudo pip install --upgrade pip virtualenv setuptools pbr tox - -echo "Clone congress" -cd ~/congress -git clone https://github.com/openstack/congress.git -cd congress -git checkout stable/liberty - -echo "Create virtualenv" -virtualenv ~/congress/congress -source bin/activate - -echo "Setup overcloud OpenStack API" -source ~/congress/admin-openrc.sh - -echo "Install OpenStack client" -cd ~/congress -git clone https://github.com/openstack/python-openstackclient.git -cd python-openstackclient -git checkout stable/liberty -~/congress/congress/bin/pip install -r requirements.txt -~/congress/congress/bin/pip install . -openstack service list - -echo "Install Congress client" -cd ~/congress -git clone https://github.com/openstack/python-congressclient.git -cd python-congressclient -git checkout stable/liberty -~/congress/congress/bin/pip install -r requirements.txt -~/congress/congress/bin/pip install . - -echo "Install Keystone client" -cd ~/congress -git clone https://github.com/openstack/python-keystoneclient.git -cd python-keystoneclient -git checkout stable/liberty -~/congress/congress/bin/pip install -r requirements.txt -~/congress/congress/bin/pip install . - -echo "setup Congress user. TODO: needs update in http://congress.readthedocs.org/en/latest/readme.html#installing-congress" -pip install cliff --upgrade -export ADMIN_ROLE=$(openstack role list | awk "/ admin / { print \$2 }") -export SERVICE_TENANT=$(openstack project list | awk "/ admin / { print \$2 }") -openstack user create --password congress --project admin --email "congress@example.com" congress -export CONGRESS_USER=$(openstack user list | awk "/ congress / { print \$2 }") -openstack role add --user $CONGRESS_USER --project $SERVICE_TENANT $ADMIN_ROLE - -echo "Create Congress service" -openstack service create congress --type "policy" --description "Congress Service" -export CONGRESS_SERVICE=$(openstack service list | awk "/ congress / { print \$2 }") - -echo "Create Congress endpoint" -openstack endpoint create $CONGRESS_SERVICE \ - --region $OS_REGION_NAME \ - --publicurl http://$CONGRESS_HOST:1789/ \ - --adminurl http://$CONGRESS_HOST:1789/ \ - --internalurl http://$CONGRESS_HOST:1789/ - -echo "Start the Congress service" -ssh -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no heat-admin@$CONGRESS_HOST "~/congress/congress/bin/congress-server &>/dev/null &" - -echo "Wait 30 seconds for Congress service to startup" -sleep 30 - -echo "Create data sources" -# To remove datasources: openstack congress datasource delete -openstack congress datasource create nova "nova" \ - --config username=$OS_USERNAME \ - --config tenant_name=$OS_TENANT_NAME \ - --config password=$OS_PASSWORD \ - --config auth_url=http://$KEYSTONE_HOST:5000/v2.0 -openstack congress datasource create neutronv2 "neutronv2" \ - --config username=$OS_USERNAME \ - --config tenant_name=$OS_TENANT_NAME \ - --config password=$OS_PASSWORD \ - --config auth_url=http://$KEYSTONE_HOST:5000/v2.0 -openstack congress datasource create ceilometer "ceilometer" \ - --config username=$OS_USERNAME \ - --config tenant_name=$OS_TENANT_NAME \ - --config password=$OS_PASSWORD \ - --config auth_url=http://$KEYSTONE_HOST:5000/v2.0 -openstack congress datasource create cinder "cinder" \ - --config username=$OS_USERNAME \ - --config tenant_name=$OS_TENANT_NAME \ - --config password=$OS_PASSWORD \ - --config auth_url=http://$KEYSTONE_HOST:5000/v2.0 -openstack congress datasource create glancev2 "glancev2" \ - --config username=$OS_USERNAME \ - --config tenant_name=$OS_TENANT_NAME \ - --config password=$OS_PASSWORD \ - --config auth_url=http://$KEYSTONE_HOST:5000/v2.0 -openstack congress datasource create keystone "keystone" \ - --config username=$OS_USERNAME \ - --config tenant_name=$OS_TENANT_NAME \ - --config password=$OS_PASSWORD \ - --config auth_url=http://$KEYSTONE_HOST:5000/v2.0 - -echo "Install tox test dependencies" -sudo yum install -y libffi-devel openssl-devel - -echo "Run Congress tox Tests" -cd ~/congress/congress -tox -epy27 - -set +x #echo off diff --git a/components/congress/install/bash/centos/install_congress_2.sh b/components/congress/install/bash/centos/install_congress_2.sh deleted file mode 100644 index a41c4a5..0000000 --- a/components/congress/install/bash/centos/install_congress_2.sh +++ /dev/null @@ -1,153 +0,0 @@ -#!/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. -# -# This is script 2 of 2 for installation of Congress on the Centos 7 based -# OPNFV Controller node as installed per the OPNFV Apex project. -# Prequisites: -# OPFNV install per https://wiki.opnfv.org/display/copper/Apex -# On the jumphost, logged in as stack on the undercloud VM: -# su stack -# Clone the Copper repo and run the install script: -# mkdir ~/git; cd git; git clone https://gerrit.opnfv.org/gerrit/copper -# cd copper -# source components/congress/install/bash/centos/install_congress_1.sh - -set -x -source ~/congress/admin-openrc.sh -source ~/congress/env.sh - -echo "install pip" -sudo yum install python-pip -y - -echo "install java" -# sudo yum install default-jre -y -# No package default-jre available. - -echo "install other dependencies" -sudo yum install apg git gcc libxml2 python-devel libzip-devel libxslt-devel -y -sudo pip install --upgrade pip virtualenv setuptools pbr tox - -echo "Clone congress" -cd ~/congress -git clone https://github.com/openstack/congress.git -cd congress -git checkout stable/liberty - -echo "Create virtualenv" -virtualenv ~/congress/congress -source bin/activate - -echo "Setup Congress" -sudo mkdir -p /etc/congress -sudo chown heat-admin /etc/congress -mkdir -p /etc/congress/snapshot -sudo mkdir /var/log/congress -sudo chown heat-admin /var/log/congress -cp etc/api-paste.ini /etc/congress -cp etc/policy.json /etc/congress - -echo "install requirements.txt and tox dependencies (detected by errors during 'tox -egenconfig')" -sudo yum install libffi-devel openssl openssl-devel -y - -echo "install dependencies of Congress" -cd ~/congress/congress -bin/pip install -r requirements.txt -bin/pip install . - -echo "install tox" -bin/pip install tox - -echo "generate congress.conf.sample" -tox -egenconfig - -echo "edit congress.conf.sample as needed" -sed -i -- 's/#verbose = true/verbose = true/g' etc/congress.conf.sample -sed -i -- 's/#log_file = /log_file = congress.log/g' etc/congress.conf.sample -sed -i -- 's/#log_dir = /log_dir = \/var\/log\/congress/g' etc/congress.conf.sample -sed -i -- 's/#bind_host = 0.0.0.0/bind_host = '$CONGRESS_HOST'/g' etc/congress.conf.sample -sed -i -- 's/#policy_path = /policy_path = \/etc\/congress\/snapshot/g' etc/congress.conf.sample -sed -i -- 's/#auth_strategy = keystone/auth_strategy = noauth/g' etc/congress.conf.sample -sed -i -- 's/#drivers =/drivers = congress.datasources.neutronv2_driver.NeutronV2Driver,congress.datasources.glancev2_driver.GlanceV2Driver,congress.datasources.nova_driver.NovaDriver,congress.datasources.keystone_driver.KeystoneDriver,congress.datasources.ceilometer_driver.CeilometerDriver,congress.datasources.cinder_driver.CinderDriver/g' etc/congress.conf.sample -sed -i -- 's/#auth_host = 127.0.0.1/auth_host = '$CONGRESS_HOST'/g' etc/congress.conf.sample -sed -i -- 's/#auth_port = 35357/auth_port = 35357/g' etc/congress.conf.sample -sed -i -- 's/#auth_protocol = https/auth_protocol = http/g' etc/congress.conf.sample -sed -i -- 's/#admin_tenant_name = admin/admin_tenant_name = admin/g' etc/congress.conf.sample -sed -i -- 's/#admin_user = /admin_user = congress/g' etc/congress.conf.sample -sed -i -- 's/#admin_password = /admin_password = congress/g' etc/congress.conf.sample -sed -i -- 's/#connection = /connection = mysql:\/\/congress@localhost:3306\/congress/g' etc/congress.conf.sample - -echo "copy congress.conf.sample to /etc/congress" -cp etc/congress.conf.sample /etc/congress/congress.conf - -echo "create congress database" -sudo mysql -e "CREATE DATABASE congress; GRANT ALL PRIVILEGES ON congress.* TO 'congress';" - -echo "install congress-db-manage dependencies (detected by errors)" -bin/pip install MySQL-python - -echo "create database schema" -congress-db-manage --config-file /etc/congress/congress.conf upgrade head - -echo "Install Congress client" -cd ~/congress -git clone https://github.com/openstack/python-congressclient.git -cd python-congressclient -git checkout stable/liberty -../congress/bin/pip install -r requirements.txt -../congress/bin/pip install . - -function _congress_setup_horizon { - local HORIZON_DIR="/usr/share/openstack-dashboard" - local CONGRESS_HORIZON_DIR="/home/heat-admin/git/congress/contrib/horizon" - sudo cp -r $CONGRESS_HORIZON_DIR/datasources $HORIZON_DIR/openstack_dashboard/dashboards/admin/ - sudo cp -r $CONGRESS_HORIZON_DIR/policies $HORIZON_DIR/openstack_dashboard/dashboards/admin/ - sudo cp -r $CONGRESS_HORIZON_DIR/static $HORIZON_DIR/openstack_dashboard/dashboards/admin/ - sudo cp -r $CONGRESS_HORIZON_DIR/templates $HORIZON_DIR/openstack_dashboard/dashboards/admin/ - sudo cp $CONGRESS_HORIZON_DIR/congress.py $HORIZON_DIR/openstack_dashboard/api/ - sudo cp $CONGRESS_HORIZON_DIR/_50_policy.py $HORIZON_DIR/openstack_dashboard/local/enabled/ - sudo cp $CONGRESS_HORIZON_DIR/_60_policies.py $HORIZON_DIR/openstack_dashboard/local/enabled/ - sudo cp $CONGRESS_HORIZON_DIR/_70_datasources.py $HORIZON_DIR/openstack_dashboard/local/enabled/ - - # For unit tests - sudo sh -c 'echo "python-congressclient" >> '$HORIZON_DIR'/requirements.txt' - sudo sh -c 'echo -e \ -"\n# Load the pluggable dashboard settings"\ -"\nimport openstack_dashboard.local.enabled"\ -"\nfrom openstack_dashboard.utils import settings"\ -"\n\nINSTALLED_APPS = list(INSTALLED_APPS)"\ -"\nsettings.update_dashboards(["\ -"\n openstack_dashboard.local.enabled,"\ -"\n], HORIZON_CONFIG, INSTALLED_APPS)" >> '$HORIZON_DIR'/openstack_dashboard/test/settings.py' - - # Setup alias for django-admin which could be different depending on distro - local django_admin - if type -p django-admin > /dev/null; then - django_admin=django-admin - else - django_admin=django-admin.py - fi - - # Collect and compress static files (e.g., JavaScript, CSS) - DJANGO_SETTINGS_MODULE=openstack_dashboard.settings $django_admin collectstatic --noinput - DJANGO_SETTINGS_MODULE=openstack_dashboard.settings $django_admin compress --force - - # Restart Horizon - sudo service apache2 restart -} -# Commented out as the procedure is not yet working -#echo "Install Horizon Policy plugin" -#_congress_setup_horizon - -set +x #echo off diff --git a/components/congress/install/bash/clean_congress.sh b/components/congress/install/bash/clean_congress.sh new file mode 100644 index 0000000..59a2b5f --- /dev/null +++ b/components/congress/install/bash/clean_congress.sh @@ -0,0 +1,71 @@ +#!/bin/bash +# CCopyright 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. +# +# This is a cleanup script for installation of Congress on the OPNFV Controller +# node as installed via JOID or Apex (Fuel and Compass not yet verified). +# Presumably something has failed, and any record of the Congress feature +# in OpenStack needs to be removed, so you can try the install again. +# Prerequisites: +# - OPFNV installed via JOID or Apex +# - For Apex installs, on the jumphost, ssh to the undercloud VM and +# $ su stack +# - For JOID installs, admin-openrc.sh saved from Horizon to ~/admin-openrc.sh +# - Retrieve the copper remova script as below +# $ cd ~ +# $ wget https://git.opnfv.org/cgit/copper/tree/components/congress/install/bash/clean_congress.sh + +echo "OS-specific prerequisite steps" +dist=`grep DISTRIB_ID /etc/*-release | awk -F '=' '{print $2}'` + +if [ "$dist" == "Ubuntu" ]; then + # Ubuntu + echo "Ubuntu-based install" + export CTLUSER="ubuntu" + echo "Stop the Congress service" + # Have to use "python" here as congress-server does not show up in the process list (?) + ssh -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $CTLUSER@$CONGRESS_HOST "pkill python; exit" + source ~/admin-openrc.sh <~/congress/env.sh +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=$(juju status --format=short | awk "/keystone\/0/ { print \$3 }") +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 }") +EOF + source ~/congress/env.sh + export CTLUSER="ubuntu" + ssh -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $CTLUSER@$CONGRESS_HOST "mkdir ~/congress; exit" + juju scp ~/admin-openrc.sh ubuntu@$CONGRESS_HOST:/home/$CTLUSER/congress + juju scp ~/congress/env.sh ubuntu@$CONGRESS_HOST:/home/$CTLUSER/congress + echo "Copy install_congress_2.sh to the congress server and execute" + juju scp ~/install_congress_2.sh $CTLUSER@$CONGRESS_HOST:/home/ubuntu/congress + ssh -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $CTLUSER@$CONGRESS_HOST "source ~/congress/install_congress_2.sh; exit" + echo "Install jumphost dependencies" + echo "Update package repos" + sudo apt-get update + echo "install pip" + sudo apt-get install python-pip -y + echo "install other dependencies" + sudo apt-get install apg git gcc python-dev libxml2 libxslt1-dev libzip-dev -y + sudo pip install --upgrade pip virtualenv setuptools pbr tox + source ~/admin-openrc.sh <~/congress/env.sh +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 + source ~/congress/env.sh + CTLUSER="heat-admin" + ssh -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $CTLUSER@$CONTROLLER_HOST1 "mkdir ~/congress; exit" + scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ~/congress/env.sh $CTLUSER@$CONTROLLER_HOST1:/home/$CTLUSER/congress + echo "Setup env for overcloud API access and copy to congress server" + source ~/overcloudrc + export OS_REGION_NAME=$(openstack endpoint list | awk "/ nova / { print \$4 }") + cp ~/overcloudrc ~/congress/admin-openrc.sh + # sed command below is a workaound for a bug - region shows up twice for some reason + cat <>~/admin-openrc.sh +export OS_REGION_NAME=$OS_REGION_NAME +EOFif [ "$dist" == "Ubuntu" ]; then + scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ~/admin-openrc.sh $CTLUSER@$CONTROLLER_HOST1:/home/$CTLUSER/congress + echo "Copy install_congress_2.sh to the congress server and execute" + scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ~/install_congress_2.sh $CTLUSER@$CONTROLLER_HOST1:/home/$CTLUSER/congress + ssh -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $CTLUSER@$CONTROLLER_HOST1 "source ~/congress/install_congress_2.sh; exit" + echo "Install jumphost dependencies" + echo "install pip" + sudo yum install python-pip -y + echo "install other dependencies" + sudo yum install apg git gcc libxml2 python-devel libzip-devel libxslt-devel -y + sudo pip install --upgrade pip virtualenv setuptools pbr tox + source ~/admin-openrc.sh +fi + +echo "Create virtualenv" +virtualenv ~/congress/venv +cd ~/congress/venv +source bin/activate + +echo "Clone congress" +cd ~/congress +git clone https://github.com/openstack/congress.git +cd congress +if [ $# -eq 1 ]; then git checkout $1; fi + +echo "Install OpenStack client" +cd ~/congress +git clone https://github.com/openstack/python-openstackclient.git +cd python-openstackclient +if [ $# -eq 1 ]; then git checkout $1; fi +pip install -r requirements.txt +pip install . + +echo "Install Congress client" +cd ~/congress +git clone https://github.com/openstack/python-congressclient.git +cd python-congressclient +if [ $# -eq 1 ]; then git checkout $1; fi +pip install -r requirements.txt +pip install . + +echo "Install Keystone client" +cd ~/congress +git clone https://github.com/openstack/python-keystoneclient.git +cd python-keystoneclient +if [ $# -eq 1 ]; then git checkout $1; fi +pip install -r requirements.txt +pip install . + +echo "setup Congress user. TODO: needs update in http://congress.readthedocs.org/en/latest/readme.html#installing-congress" +pip install cliff --upgrade +export ADMIN_ROLE=$(openstack role list | awk "/ admin / { print \$2 }") +export SERVICE_TENANT=$(openstack project list | awk "/ admin / { print \$2 }") +openstack user create --password congress --project admin --email "congress@example.com" congress +export CONGRESS_USER=$(openstack user list | awk "/ congress / { print \$2 }") +openstack role add --user $CONGRESS_USER --project $SERVICE_TENANT $ADMIN_ROLE + +echo "Create Congress service" +openstack service create congress --type "policy" --description "Congress Service" +export CONGRESS_SERVICE=$(openstack service list | awk "/ congress / { print \$2 }") + +echo "Create Congress endpoint" +openstack endpoint create $CONGRESS_SERVICE \ + --region $OS_REGION_NAME \ + --publicurl http://$CONGRESS_HOST:1789/ \ + --adminurl http://$CONGRESS_HOST:1789/ \ + --internalurl http://$CONGRESS_HOST:1789/ + +echo "Start the Congress service" +ssh -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $CTLUSER@$CONGRESS_HOST "source ~/congress/venv/bin/activate; ~/congress/congress/bin/congress-server &>/dev/null &" + +echo "Wait 30 seconds for Congress service to startup" +sleep 30 + +echo "Create data sources" +# To remove datasources: openstack congress datasource delete +openstack congress datasource create nova "nova" \ + --config username=$OS_USERNAME \ + --config tenant_name=$OS_TENANT_NAME \ + --config password=$OS_PASSWORD \ + --config auth_url=http://$KEYSTONE_HOST:5000/v2.0 +openstack congress datasource create neutronv2 "neutronv2" \ + --config username=$OS_USERNAME \ + --config tenant_name=$OS_TENANT_NAME \ + --config password=$OS_PASSWORD \ + --config auth_url=http://$KEYSTONE_HOST:5000/v2.0 +openstack congress datasource create ceilometer "ceilometer" \ + --config username=$OS_USERNAME \ + --config tenant_name=$OS_TENANT_NAME \ + --config password=$OS_PASSWORD \ + --config auth_url=http://$KEYSTONE_HOST:5000/v2.0 +openstack congress datasource create cinder "cinder" \ + --config username=$OS_USERNAME \ + --config tenant_name=$OS_TENANT_NAME \ + --config password=$OS_PASSWORD \ + --config auth_url=http://$KEYSTONE_HOST:5000/v2.0 +openstack congress datasource create glancev2 "glancev2" \ + --config username=$OS_USERNAME \ + --config tenant_name=$OS_TENANT_NAME \ + --config password=$OS_PASSWORD \ + --config auth_url=http://$KEYSTONE_HOST:5000/v2.0 +openstack congress datasource create keystone "keystone" \ + --config username=$OS_USERNAME \ + --config tenant_name=$OS_TENANT_NAME \ + --config password=$OS_PASSWORD \ + --config auth_url=http://$KEYSTONE_HOST:5000/v2.0 + +echo "Install tox test dependencies" +if [ "$dist" == "Ubuntu" ]; then + sudo apt-get install -y libffi-dev libssl-dev +else + sudo yum install -y libffi-devel openssl-devel +fi + +echo "Run Congress tox Tests" +cd ~/congress/congress +tox -epy27 + +set +x #echo off diff --git a/components/congress/install/bash/install_congress_2.sh b/components/congress/install/bash/install_congress_2.sh new file mode 100644 index 0000000..b4b129d --- /dev/null +++ b/components/congress/install/bash/install_congress_2.sh @@ -0,0 +1,202 @@ +#!/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. +# +# This is script 2 of 2 for installation of Congress on the OPNFV Controller +# node as installed via JOID or Apex (Fuel and Compass not yet verified). +# Prerequisites: +# - OPFNV installed via JOID or Apex +# - For Apex installs, on the jumphost, ssh to the undercloud VM and +# $ su stack +# - For JOID installs, admin-openrc.sh saved from Horizon to ~/admin-openrc.sh +# - Retrieve the copper install script as below, optionally specifying the +# branch to use as a URL parameter, e.g. ?h=stable%2Fbrahmaputra +# $ cd ~ +# $ wget https://git.opnfv.org/cgit/copper/tree/components/congress/install/bash/install_congress_1.sh +# $ wget https://git.opnfv.org/cgit/copper/tree/components/congress/install/bash/install_congress_2.sh +# $ source install_congress_1.sh [openstack-branch] +# optionally specifying the branch identifier to use for OpenStack +# + +set -x + +if [ $# -eq 1 ]; then osbranch=$1; fi + +echo "OS-specific prerequisite steps" +dist=`grep DISTRIB_ID /etc/*-release | awk -F '=' '{print $2}'` + +if [ "$dist" == "Ubuntu" ]; then + # Ubuntu + echo "Ubuntu-based install" + export CTLUSER="ubuntu" + source ~/congress/admin-openrc.sh </log_file = congress.log/g' etc/congress.conf.sample +sed -i -- 's/#log_dir = /log_dir = \/var\/log\/congress/g' etc/congress.conf.sample +sed -i -- 's/#bind_host = 0.0.0.0/bind_host = '$CONGRESS_HOST'/g' etc/congress.conf.sample +sed -i -- 's/#policy_path = /policy_path = \/etc\/congress\/snapshot/g' etc/congress.conf.sample +sed -i -- 's/#auth_strategy = keystone/auth_strategy = noauth/g' etc/congress.conf.sample +sed -i -- 's/#drivers =/drivers = congress.datasources.neutronv2_driver.NeutronV2Driver,congress.datasources.glancev2_driver.GlanceV2Driver,congress.datasources.nova_driver.NovaDriver,congress.datasources.keystone_driver.KeystoneDriver,congress.datasources.ceilometer_driver.CeilometerDriver,congress.datasources.cinder_driver.CinderDriver/g' etc/congress.conf.sample +sed -i -- 's/#auth_host = 127.0.0.1/auth_host = '$CONGRESS_HOST'/g' etc/congress.conf.sample +sed -i -- 's/#auth_port = 35357/auth_port = 35357/g' etc/congress.conf.sample +sed -i -- 's/#auth_protocol = https/auth_protocol = http/g' etc/congress.conf.sample +sed -i -- 's/#admin_tenant_name = admin/admin_tenant_name = admin/g' etc/congress.conf.sample +sed -i -- 's/#admin_user = /admin_user = congress/g' etc/congress.conf.sample +sed -i -- 's/#admin_password = /admin_password = congress/g' etc/congress.conf.sample +sed -i -- 's/#connection = /connection = mysql:\/\/congress@localhost:3306\/congress/g' etc/congress.conf.sample + +echo "copy congress.conf.sample to /etc/congress" +cp etc/congress.conf.sample /etc/congress/congress.conf + +echo "create congress database" +sudo mysql -e "CREATE DATABASE congress; GRANT ALL PRIVILEGES ON congress.* TO 'congress';" + +echo "install congress-db-manage dependencies (detected by errors)" +if [ "$dist" == "Ubuntu" ]; then sudo apt-get build-dep python-mysqldb -y; fi +pip install MySQL-python + +echo "create database schema" +congress-db-manage --config-file /etc/congress/congress.conf upgrade head + +echo "Install Congress client" +cd ~/congress +git clone https://github.com/openstack/python-congressclient.git +cd python-congressclient +if [ $# -eq 1 ]; then git checkout $1; fi +pip install -r requirements.txt +pip install . + +# Fix error found during startup of congress server +echo "Install python fixtures" +pip install fixtures + +# TODO: The rest of this script is not yet tested +function _congress_setup_horizon { + local HORIZON_DIR="/usr/share/openstack-dashboard" + local CONGRESS_HORIZON_DIR="/home/heat-admin/git/congress/contrib/horizon" + sudo cp -r $CONGRESS_HORIZON_DIR/datasources $HORIZON_DIR/openstack_dashboard/dashboards/admin/ + sudo cp -r $CONGRESS_HORIZON_DIR/policies $HORIZON_DIR/openstack_dashboard/dashboards/admin/ + sudo cp -r $CONGRESS_HORIZON_DIR/static $HORIZON_DIR/openstack_dashboard/dashboards/admin/ + sudo cp -r $CONGRESS_HORIZON_DIR/templates $HORIZON_DIR/openstack_dashboard/dashboards/admin/ + sudo cp $CONGRESS_HORIZON_DIR/congress.py $HORIZON_DIR/openstack_dashboard/api/ + sudo cp $CONGRESS_HORIZON_DIR/_50_policy.py $HORIZON_DIR/openstack_dashboard/local/enabled/ + sudo cp $CONGRESS_HORIZON_DIR/_60_policies.py $HORIZON_DIR/openstack_dashboard/local/enabled/ + sudo cp $CONGRESS_HORIZON_DIR/_70_datasources.py $HORIZON_DIR/openstack_dashboard/local/enabled/ + + # For unit tests + sudo sh -c 'echo "python-congressclient" >> '$HORIZON_DIR'/requirements.txt' + sudo sh -c 'echo -e \ +"\n# Load the pluggable dashboard settings"\ +"\nimport openstack_dashboard.local.enabled"\ +"\nfrom openstack_dashboard.utils import settings"\ +"\n\nINSTALLED_APPS = list(INSTALLED_APPS)"\ +"\nsettings.update_dashboards(["\ +"\n openstack_dashboard.local.enabled,"\ +"\n], HORIZON_CONFIG, INSTALLED_APPS)" >> '$HORIZON_DIR'/openstack_dashboard/test/settings.py' + + # Setup alias for django-admin which could be different depending on distro + local django_admin + if type -p django-admin > /dev/null; then + django_admin=django-admin + else + django_admin=django-admin.py + fi + + # Collect and compress static files (e.g., JavaScript, CSS) + DJANGO_SETTINGS_MODULE=openstack_dashboard.settings $django_admin collectstatic --noinput + DJANGO_SETTINGS_MODULE=openstack_dashboard.settings $django_admin compress --force + + # Restart Horizon + sudo service apache2 restart +} +# Commented out as the procedure is not yet working +#echo "Install Horizon Policy plugin" +#_congress_setup_horizon + +set +x #echo off diff --git a/components/congress/test-webapp/setup/install_congress_testserver_1.sh b/components/congress/test-webapp/setup/install_congress_testserver_1.sh deleted file mode 100644 index dfb2a4b..0000000 --- a/components/congress/test-webapp/setup/install_congress_testserver_1.sh +++ /dev/null @@ -1,127 +0,0 @@ -#!/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: script 1 of 2 for installation of a test server for Congress. -# Status: this is a work in progress, under test. -# -# Prequisite: OPFNV installed per JOID or Apex installer -# On jumphost: -# - Congress installed through install_congress_1.sh -# - ~/congress/env.sh created as part of Congress install (install_congress_1.sh) -# How to use: -# $ source install_congress_testserver_1.sh [] -# If provided, is the name of the controller node in MAAS -# (the parameter is not used for Apex-based installs) - -set -x - -echo "Install prerequisites" -dist=`grep DISTRIB_ID /etc/*-release | awk -F '=' '{print $2}'` - -if [ "$dist" == "Ubuntu" ]; then - # Create and Activate the Container - # Earlier versions of the JOID installer installed lxc and created local templates - # but now we have to get the ubuntu template from the controller - - if [ $# -lt 1 ]; then - echo 1>&2 "$0: arguments required " - set +x - return 2 - fi - - sudo apt-get install -y lxc - - echo "Copy lxc-ubuntu container from the controller" - juju scp ubuntu@$1:/usr/share/lxc/templates/lxc-ubuntu ~/lxc-ubuntu - sudo cp ~/lxc-ubuntu /usr/share/lxc/templates/lxc-ubuntu - - echo "Create the copper container" - sudo lxc-create -n copper -t /usr/share/lxc/templates/lxc-ubuntu -l DEBUG -- -b $USER ~/$USER - - echo "Start copper" - sudo lxc-start -n copper -d - if (($? > 0)); then - echo Error starting copper lxc container - return - fi - - echo "Get the CONGRESS_HOST value from env.sh" - source ~/congress/env.sh - - echo "Get copper address" - sleep 5 - export COPPER_HOST="" - while [ "$COPPER_HOST" == "" ]; do - sleep 5 - export COPPER_HOST=$(sudo lxc-info --name copper | grep IP | awk "/ / { print \$2 }") - done - echo COPPER_HOST = $COPPER_HOST - - echo "Create the environment file" - cat <~/congress/env.sh -export COPPER_HOST=$COPPER_HOST -export CONGRESS_HOST=$CONGRESS_HOST -export KEYSTONE_HOST=$KEYSTONE_HOST -export CEILOMETER_HOST=$CEILOMETER_HOST -export CINDER_HOST=$CINDER_HOST -export GLANCE_HOST=$GLANCE_HOST -export NEUTRON_HOST=$NEUTRON_HOST -export NOVA_HOST=$NOVA_HOST -EOF - - echo "Invoke install_congress_testserver_2.sh on copper" - ssh -t -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $USER@$COPPER_HOST "source ~/git/copper/components/congress/test-webapp/setup/install_congress_testserver_2.sh; exit" - -else - sudo tee /etc/yum.repos.d/docker.repo <<-'EOF' -[dockerrepo] -name=Docker Repository -baseurl=https://yum.dockerproject.org/repo/main/centos/$releasever/ -enabled=1 -gpgcheck=1 -gpgkey=https://yum.dockerproject.org/gpg -EOF - sudo service docker start - - echo "Setup webapp files" - if [ ! -d /tmp/copper ]; then mkdir /tmp/copper; fi - if [ ! -d /tmp/copper/log ]; then mkdir /tmp/copper/log; fi - sudo scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no stack@192.0.2.1:/home/stack/congress/*.sh /tmp/copper - source /tmp/copper/env.sh - cp -r ~/git/copper/components/congress/test-webapp/* /tmp/copper/ - if [ ! -d /tmp/copper/tests ]; then mkdir /tmp/copper/tests; fi - cp -r ~/git/copper/tests/* /tmp/copper/tests - echo "Point proxy.php to the Congress server" - source /tmp/copper/env.sh - sed -i -- "s/CONGRESS_HOST/$CONGRESS_HOST/g" /tmp/copper/www/proxy/index.php - - echo "Start webapp container" - sudo docker build -t copper-webapp /tmp/copper - CID=$(sudo docker run -p 8080:80 -d copper-webapp) - CIP=$(sudo docker inspect $CID | grep IPAddress | cut -d '"' -f 4 | tail -1) - echo "Copper Webapp ID address: $CIP" - - echo "Start Centos container" - sudo docker pull centos - echo "Attach to the Centos container" - echo "Once logged in, enter the command 'source /opt/copper/setup/install_congress_testserver_2.sh'" - sudo docker run -i -t -P --name copper-cli -v /tmp/copper:/opt/copper centos /bin/bash -# sudo docker attach $CID -# sudo docker run -it -P --name copper -v /tmp/copper:/opt/copper centos /opt/copper/setup/install_congress_testserver_2.sh -# sudo docker ps -a -fi - -set +x - diff --git a/components/congress/test-webapp/setup/install_congress_testserver_2.sh b/components/congress/test-webapp/setup/install_congress_testserver_2.sh deleted file mode 100644 index 1f50be3..0000000 --- a/components/congress/test-webapp/setup/install_congress_testserver_2.sh +++ /dev/null @@ -1,137 +0,0 @@ -#!/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: script 2 of 2 for installation of a test server for Congress. -# Status: this is a work in progress, under test. -# -# Prequisite: OPFNV installed per JOID or Apex installer -# On jumphost: -# - Congress installed through install_congress_1.sh -# How to use: -# $ source install_congress_testserver_1.sh - -set -x - -echo "Setup OpenStack environment variables per your OPNFV install" -source /opt/copper/env.sh -source /opt/copper/admin-openrc.sh - -echo "Install prerequisites" -dist=`grep DISTRIB_ID /etc/*-release | awk -F '=' '{print $2}'` - -if [ "$dist" == "Ubuntu" ]; then - echo "Update the base server" - set -x - apt-get update - #apt-get -y upgrade - - echo "Install pip" - apt-get install -y python-pip - - echo "Install java" - apt-get install -y default-jre - - echo "Install other dependencies" - apt-get install -y git gcc python-dev libxml2 libxslt1-dev libzip-dev php5-curl - - echo "Install Apache, PHP" - apt-get install -y apache2 php5 libapache2-mod-php5 - - echo "Setup the Congress Test Webappp" - - echo "Copy the Apache config" - cp /opt/copper/www/ubuntu-apache2.conf /etc/apache2/apache2.conf - - echo "Copy the webapp to the Apache root directory and fix permissions" - cp -R /opt/copper/www/html /var/www - chmod 755 /var/www/html -R - - echo "Point copper.js to the trusty-copper server per your install" - sed -i -- "s/COPPER_HOST/$COPPER_HOST/g" /var/www/html/copper.js - - echo "Point proxy.php to the Congress server per your install" - sed -i -- "s/CONGRESS_HOST/$CONGRESS_HOST/g" /var/www/html/proxy/index.php - - echo "Make webapp log directory" - mkdir /tmp/copper/log - - /etc/init.d/apache2 restart - -else - echo "Add epel repo" - yum install epel-release -y - - echo "install pip" - yum install python-pip -y - - echo "install other dependencies" - yum install apg git gcc libxml2 python-devel libzip-devel libxslt-devel -y - -fi - -echo "Install python dependencies" -pip install --upgrade pip setuptools pbr tox - -echo "Install OpenStack client" -mkdir /opt/copper/git -cd /opt/copper/git -git clone https://github.com/openstack/python-openstackclient.git -cd python-openstackclient -git checkout stable/liberty -pip install -r requirements.txt -pip install . - -echo "Install Congress client" -cd /opt/copper/git -git clone https://github.com/openstack/python-congressclient.git -cd python-congressclient -git checkout stable/liberty -pip install -r requirements.txt -pip install . - -echo "Install Glance client" -cd /opt/copper/git -git clone https://github.com/openstack/python-glanceclient.git -cd python-glanceclient -git checkout stable/liberty -pip install -r requirements.txt -pip install . - -echo "Install Neutron client" -cd /opt/copper/git -git clone https://github.com/openstack/python-neutronclient.git -cd python-neutronclient -git checkout stable/liberty -pip install -r requirements.txt -pip install . - -echo "Install Nova client" -cd /opt/copper/git -git clone https://github.com/openstack/python-novaclient.git -cd python-novaclient -git checkout stable/liberty -pip install -r requirements.txt -pip install . - -echo "Install Keystone client" -cd /opt/copper/git -git clone https://github.com/openstack/python-keystoneclient.git -cd python-keystoneclient -git checkout stable/liberty -pip install -r requirements.txt -pip install . - -set +x - -- cgit 1.2.3-korg