From 59ec0025ea7b179d4cd605f93bad561884e2d705 Mon Sep 17 00:00:00 2001 From: blsaws Date: Fri, 19 Feb 2016 16:55:38 -0800 Subject: Complete congress bash script install automation. JIRA: COPPER-2 Change-Id: I64746cf76750516812a094778c92967c9515f979 Signed-off-by: blsaws --- components/congress/joid/install_congress_1.sh | 38 ++++- components/congress/joid/install_congress_2.sh | 186 +++++++++++++++++++++++- components/congress/joid/install_congress_3.sh | 45 ------ components/congress/joid/install_congress_4.sh | 188 ------------------------- 4 files changed, 214 insertions(+), 243 deletions(-) delete mode 100644 components/congress/joid/install_congress_3.sh delete mode 100644 components/congress/joid/install_congress_4.sh diff --git a/components/congress/joid/install_congress_1.sh b/components/congress/joid/install_congress_1.sh index f2fc4da..251eb67 100644 --- a/components/congress/joid/install_congress_1.sh +++ b/components/congress/joid/install_congress_1.sh @@ -13,16 +13,42 @@ # See the License for the specific language governing permissions and # limitations under the License. # -# This is script 1 of 5 for installation of Congress on an Ubuntu 14.04 +# This is script 1 of 2 for installation of Congress on an Ubuntu 14.04 # LXC container in the OPNFV Controller node. # Prequisite: OPFNV install per https://wiki.opnfv.org/copper/academy/joid # # On jumphost: # Download admin-openrc.sh from Horizon and save in ~ # source ~/git/copper/components/congress/joid/install_congress_1.sh -# (copies install_congress_2.sh to node1-control and executes it) -# next: see install_congress_3.sh -juju scp ~/git/copper/components/congress/joid/install_congress_2.sh ubuntu@node1-control:/home/ubuntu -juju ssh ubuntu@node1-control "source ~/install_congress_2.sh; exit" -return +set -x + +# Create the congress container +juju ssh ubuntu@node1-control "sudo lxc-clone -o juju-trusty-lxc-template -n juju-trusty-congress; sudo lxc-start -n juju-trusty-congress -d; exit" + +# Get the congress server address +CONGRESS_HOST="" +while [ "$CONGRESS_HOST" == "" ]; do + sleep 5 + CONGRESS_HOST=$(juju ssh ubuntu@node1-control "sudo lxc-info --name juju-trusty-congress | grep IP" | awk "/ / { print \$2 }" | tr -d '\r') +done + +# Create the environment file and copy to the congress server +cat <~/env.sh +export CONGRESS_HOST=$CONGRESS_HOST +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 ~/env.sh +juju scp ~/admin-openrc.sh ubuntu@$CONGRESS_HOST:/home/ubuntu +juju scp ~/env.sh ubuntu@$CONGRESS_HOST:/home/ubuntu + +# Copy the install script to the congress server and execute +juju scp ~/git/copper/components/congress/joid/install_congress_2.sh ubuntu@$CONGRESS_HOST:/home/ubuntu +ssh -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ubuntu@$CONGRESS_HOST "source ~/install_congress_2.sh; exit" + +set +x diff --git a/components/congress/joid/install_congress_2.sh b/components/congress/joid/install_congress_2.sh index 5dedf75..b56079d 100644 --- a/components/congress/joid/install_congress_2.sh +++ b/components/congress/joid/install_congress_2.sh @@ -13,7 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # -# This is script 2 of 5 for installation of Congress on an Ubuntu 14.04 + +# This is script 2 of 2 for installation of Congress on an Ubuntu 14.04 # LXC container in the OPNFV Controller node. # Prequisite: OPFNV install per https://wiki.opnfv.org/copper/academy/joid # @@ -23,8 +24,185 @@ # (copies install_congress_2.sh to node1-control and executes it) set -x -sudo lxc-clone -o juju-trusty-lxc-template -n juju-trusty-congress -sudo lxc-start -n juju-trusty-congress -d +source ~/admin-openrc.sh </log_file = congress.log/g' etc/congress.conf.sample +sudo sed -i -- 's/#log_dir = /log_dir = \/var\/log\/congress/g' etc/congress.conf.sample +sudo sed -i -- 's/#bind_host = 0.0.0.0/bind_host = '$CONGRESS_HOST'/g' etc/congress.conf.sample +sudo sed -i -- 's/#policy_path = /policy_path = \/etc\/congress\/snapshot/g' etc/congress.conf.sample +sudo sed -i -- 's/#auth_strategy = keystone/auth_strategy = noauth/g' etc/congress.conf.sample +sudo 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 +sudo sed -i -- 's/#auth_host = 127.0.0.1/auth_host = '$CONGRESS_HOST'/g' etc/congress.conf.sample +sudo sed -i -- 's/#auth_port = 35357/auth_port = 35357/g' etc/congress.conf.sample +sudo sed -i -- 's/#auth_protocol = https/auth_protocol = http/g' etc/congress.conf.sample +sudo sed -i -- 's/#admin_tenant_name = admin/admin_tenant_name = admin/g' etc/congress.conf.sample +sudo sed -i -- 's/#admin_user = /admin_user = congress/g' etc/congress.conf.sample +sudo sed -i -- 's/#admin_password = /admin_password = congress/g' etc/congress.conf.sample +sudo sed -i -- 's/#connection = /connection = mysql:\/\/ubuntu:'$MYSQL_PASSWORD'@localhost:3306\/congress/g' etc/congress.conf.sample + +# copy congress.conf.sample to /etc/congress +sudo cp etc/congress.conf.sample /etc/congress/congress.conf + +# create congress database +sudo mysql --user=root --password=$MYSQL_PASSWORD -e "CREATE DATABASE congress; GRANT ALL PRIVILEGES ON congress.* TO 'ubuntu@localhost' IDENTIFIED BY '"$MYSQL_PASSWORD"'; GRANT ALL PRIVILEGES ON congress.* TO 'ubuntu'@'%' IDENTIFIED BY '"$MYSQL_PASSWORD"'; exit;" + +# install congress-db-manage dependencies (detected by errors) +sudo apt-get build-dep python-mysqldb -y +pip install MySQL-python + +# create database schema +congress-db-manage --config-file /etc/congress/congress.conf upgrade head + +# Install and test OpenStack client +cd ~/git +git clone https://github.com/openstack/python-openstackclient.git +cd python-openstackclient +git checkout stable/liberty +sudo pip install -r requirements.txt +sudo pip install . +openstack service list + +# Install and test Congress client +cd ~/git +git clone https://github.com/openstack/python-congressclient.git +cd python-congressclient +git checkout stable/liberty +sudo pip install -r requirements.txt +sudo pip install . +openstack congress driver list + +# Install and test Keystone client +cd ~/git +git clone https://github.com/openstack/python-keystoneclient.git +cd python-keystoneclient +git checkout stable/liberty +sudo pip install -r requirements.txt +sudo pip install . + +# 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 + +# Create Congress service +openstack service create congress --type "policy" --description "Congress Service" +export CONGRESS_SERVICE=$(openstack service list | awk "/ congress / { print \$2 }") + +# 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/ + +# Start the Congress service in the background +cd ~/git/congress +sudo bin/congress-server & + +# disown the process (so it keeps running if you get disconnected) +disown -h %1 + +# Create data sources +# To remove datasources: openstack congress datasource delete +# Insert a delay here, as nova datasource seems to fail to get setup (server not ready?) sleep 10 -sudo lxc-info -n juju-trusty-congress +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 + +# Run Congress Tempest Tests +cd ~/git/congress +# tox -epy27 set +x +return diff --git a/components/congress/joid/install_congress_3.sh b/components/congress/joid/install_congress_3.sh deleted file mode 100644 index 6f094fb..0000000 --- a/components/congress/joid/install_congress_3.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/bash -# Copyright 2015-2016 Open Platform for NFV Project, Inc. and its contributors -# -# 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 3 of 4 for installation of Congress on an Ubuntu 14.04 -# LXC container in the OPNFV Controller node. -# Prequisite: OPFNV install per https://wiki.opnfv.org/copper/academy/joid -# -# On jumphost: -# Download admin-openrc.sh from Horizon and save in ~ -# source ~/git/copper/components/congress/joid/install_congress_1.sh -# (copies install_congress_2.sh to node1-control and executes it) -# Edit install_congress_3.sh with the congress host address from lxc_info -# - Congress server IP address as discovered in lxc-info above -# source ~/git/copper/components/congress/joid/install_congress_3.sh - -#ssh-keygen -f "/home/opnfv/.ssh/known_hosts" -R $1 -if (($? > 0)); then - return -fi -cat <~/env.sh -export CONGRESS_HOST=$1 -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 ~/env.sh -juju scp ~/admin-openrc.sh ubuntu@$CONGRESS_HOST:/home/ubuntu -juju scp ~/env.sh ubuntu@$CONGRESS_HOST:/home/ubuntu -juju scp ~/git/copper/components/congress/joid/install_congress_4.sh ubuntu@$CONGRESS_HOST:/home/ubuntu -ssh -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ubuntu@$CONGRESS_HOST "source ~/install_congress_4.sh; exit" diff --git a/components/congress/joid/install_congress_4.sh b/components/congress/joid/install_congress_4.sh deleted file mode 100644 index a96cc7a..0000000 --- a/components/congress/joid/install_congress_4.sh +++ /dev/null @@ -1,188 +0,0 @@ -#!/bin/bash -# Copyright 2015-2016 Open Platform for NFV Project, Inc. and its contributors -# -# 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 4 of 4 for installation of Congress on an Ubuntu 14.04 -# LXC container in the OPNFV Controller node. -# Prequisite: OPFNV install per https://wiki.opnfv.org/copper/academy/joid -# -# On jumphost: -# Download admin-openrc.sh from Horizon and save in ~ -# source ~/git/copper/components/congress/joid/install_congress_1.sh -# (copies install_congress_2.sh to node1-control and executes it) -# Edit install_congress_3.sh with the congress host address from lxc_info -# - Congress server IP address as discovered in lxc-info above -# source ~/git/copper/components/congress/joid/install_congress_3.sh - -source ~/admin-openrc.sh </log_file = congress.log/g' etc/congress.conf.sample -sudo sed -i -- 's/#log_dir = /log_dir = \/var\/log\/congress/g' etc/congress.conf.sample -sudo sed -i -- 's/#bind_host = 0.0.0.0/bind_host = '$CONGRESS_HOST'/g' etc/congress.conf.sample -sudo sed -i -- 's/#policy_path = /policy_path = \/etc\/congress\/snapshot/g' etc/congress.conf.sample -sudo sed -i -- 's/#auth_strategy = keystone/auth_strategy = noauth/g' etc/congress.conf.sample -sudo 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 -sudo sed -i -- 's/#auth_host = 127.0.0.1/auth_host = '$CONGRESS_HOST'/g' etc/congress.conf.sample -sudo sed -i -- 's/#auth_port = 35357/auth_port = 35357/g' etc/congress.conf.sample -sudo sed -i -- 's/#auth_protocol = https/auth_protocol = http/g' etc/congress.conf.sample -sudo sed -i -- 's/#admin_tenant_name = admin/admin_tenant_name = admin/g' etc/congress.conf.sample -sudo sed -i -- 's/#admin_user = /admin_user = congress/g' etc/congress.conf.sample -sudo sed -i -- 's/#admin_password = /admin_password = congress/g' etc/congress.conf.sample -sudo sed -i -- 's/#connection = /connection = mysql:\/\/ubuntu:opnfvmysql@localhost:3306\/congress/g' etc/congress.conf.sample -# copy congress.conf.sample to /etc/congress -sudo cp etc/congress.conf.sample /etc/congress/congress.conf -# create congress database -sudo mysql --user=root --password=opnfvmysql < -# May need to insert a delay here, as nova datasource seems to fail to get setup (server not ready?) -sleep 10 -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 -# Run Congress Tempest Tests -cd ~/git/congress -# tox -epy27 -return -- cgit 1.2.3-korg