summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/congress/joid/install_congress_1.sh161
-rw-r--r--components/congress/joid/install_congress_2.sh198
2 files changed, 224 insertions, 135 deletions
diff --git a/components/congress/joid/install_congress_1.sh b/components/congress/joid/install_congress_1.sh
index 8c15076..a6ebd96 100644
--- a/components/congress/joid/install_congress_1.sh
+++ b/components/congress/joid/install_congress_1.sh
@@ -19,30 +19,42 @@
#
# On jumphost:
# Download admin-openrc.sh from Horizon and save in ~
-# source ~/git/copper/components/congress/joid/install_congress_1.sh <controller_hostname>
-# <controller_hostname> is the name of the controller node in MAAS.
+# source install_congress_1.sh <host>
+# (copies install_congress_2.sh to <host> and executes it)
+# <hostname> is the name of the host in which to install Congress.
+#
+# If "horizon", Congress will be installed in the same LXC as Horizon,
+# as necessary for the OpenStack Dashboard Policy plugins to work.
+# Otherwise provide the node name of the controller node, where Congress
+# will be installed in an LXC (NOTE: Policy plugin for OpenStack dashboard
+# does not currently get installed for the LXC-based Congress deploy)
-if [ $# -lt 1 ]; then
- echo 1>&2 "$0: not enough arguments"
- return 2
+if [ $# -gt 1 ] && [ $2 == "debug" ]; then set -x #echo on
fi
-if [ $1 == "debug" ]; then set -x #echo on
-fi
-
-echo "Create the congress container"
-juju ssh ubuntu@$1 "sudo lxc-clone -o juju-trusty-lxc-template -n juju-trusty-congress; sudo lxc-start -n juju-trusty-congress -d; exit"
+source ~/admin-openrc.sh <<EOF
+openstack
+EOF
-echo "Get the congress server address"
-CONGRESS_HOST=""
-while [ "$CONGRESS_HOST" == "" ]; do
- sleep 5
- CONGRESS_HOST=$(juju ssh ubuntu@$1 "sudo lxc-info --name juju-trusty-congress | grep IP" | awk "/ / { print \$2 }" | tr -d '\r')
-done
+if [ $1 == "horizon" ]; then
+ echo "Set CONGRESS_HOST to HORIZON_HOST"
+ CONGRESS_HOST=$(juju status --format=short | awk "/openstack-dashboard/ { print \$3 }")
+else
+ echo "Create the congress container"
+ juju ssh ubuntu@$1 "sudo lxc-clone -o juju-trusty-lxc-template -n juju-trusty-congress; sudo lxc-start -n juju-trusty-congress -d; exit"
+ echo "Get the congress server address"
+ CONGRESS_HOST=""
+ while [ "$CONGRESS_HOST" == "" ]; do
+ sleep 5
+ CONGRESS_HOST=$(juju ssh ubuntu@$1 "sudo lxc-info --name juju-trusty-congress | grep IP" | awk "/ / { print \$2 }" | tr -d '\r')
+ done
+fi
+
echo "Create the environment file and copy to the congress server"
cat <<EOF >~/env.sh
export CONGRESS_HOST=$CONGRESS_HOST
+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 }")
@@ -54,8 +66,119 @@ source ~/env.sh
juju scp ~/admin-openrc.sh ubuntu@$CONGRESS_HOST:/home/ubuntu
juju scp ~/env.sh ubuntu@$CONGRESS_HOST:/home/ubuntu
-echo "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"
+echo "Copy install_congress_2.sh to the congress server and execute"
+juju scp ~/git/copper/components/congress/joid/install_congress_2b.sh ubuntu@$CONGRESS_HOST:/home/ubuntu
+ssh -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ubuntu@$CONGRESS_HOST "source ~/install_congress_2b.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
+
+echo "Clone congress"
+mkdir ~/git
+cd ~/git
+git clone https://github.com/openstack/congress.git
+cd congress
+git checkout stable/liberty
+
+echo "Create virtualenv"
+virtualenv ~/git/congress
+source bin/activate
+
+echo "Install and test OpenStack client"
+cd ~/git
+git clone https://github.com/openstack/python-openstackclient.git
+cd python-openstackclient
+git checkout stable/liberty
+~/git/congress/bin/pip install -r requirements.txt
+~/git/congress/bin/pip install .
+openstack service list
+
+echo "Install and test Congress client"
+cd ~/git
+git clone https://github.com/openstack/python-congressclient.git
+cd python-congressclient
+git checkout stable/liberty
+~/git/congress/bin/pip install -r requirements.txt
+~/git/congress/bin/pip install .
+openstack congress driver list
+
+echo "Install and test Keystone client"
+cd ~/git
+git clone https://github.com/openstack/python-keystoneclient.git
+cd python-keystoneclient
+git checkout stable/liberty
+~/git/congress/bin/pip install -r requirements.txt
+~/git/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 ubuntu@$CONGRESS_HOST "~/git/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 <name>
+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 "Run Congress Tempest Tests"
+cd ~/git/congress
+# tox -epy27
set +x #echo off
diff --git a/components/congress/joid/install_congress_2.sh b/components/congress/joid/install_congress_2.sh
index d6a27e0..312a0c3 100644
--- a/components/congress/joid/install_congress_2.sh
+++ b/components/congress/joid/install_congress_2.sh
@@ -15,13 +15,20 @@
#
# This is script 2 of 2 for installation of Congress on an Ubuntu 14.04
-# LXC container in the OPNFV Controller node.
+# LXC container (same as Horizon) 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)
+# source install_congress_1.sh <host>
+# (copies install_congress_2.sh to <host> and executes it)
+# <hostname> is the name of the host in which to install Congress.
+#
+# If "horizon", Congress will be installed in the same LXC as Horizon,
+# as necessary for the OpenStack Dashboard Policy plugins to work.
+# Otherwise provide the node name of the controller node, where Congress
+# will be installed in an LXC (NOTE: Policy plugin for OpenStack dashboard
+# does not currently get installed for the LXC-based Congress deploy)
set -x
source ~/admin-openrc.sh <<EOF
@@ -29,8 +36,9 @@ openstack
EOF
source ~/env.sh
-echo "Update package repos"
+echo "Update/upgrade package repos"
sudo apt-get update
+#sudo apt-get upgrade -y
echo "install pip"
sudo apt-get install python-pip -y
@@ -40,6 +48,7 @@ sudo apt-get install default-jre -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
echo "set mysql root user password and install mysql"
export MYSQL_PASSWORD=$(/usr/bin/apg -n 1 -m 16 -c cl_seed)
@@ -54,20 +63,18 @@ git clone https://github.com/openstack/congress.git
cd congress
git checkout stable/liberty
-echo "Install virtualenv"
-sudo pip install virtualenv
-
echo "Create virtualenv"
virtualenv ~/git/congress
source bin/activate
echo "Setup Congress"
sudo mkdir -p /etc/congress
-sudo mkdir -p /etc/congress/snapshot
+sudo chown ubuntu /etc/congress
+mkdir -p /etc/congress/snapshot
sudo mkdir /var/log/congress
sudo chown ubuntu /var/log/congress
-sudo cp etc/api-paste.ini /etc/congress
-sudo cp etc/policy.json /etc/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 apt-get install libffi-dev -y
@@ -76,133 +83,92 @@ sudo apt-get install libssl-dev -y
echo "install dependencies of Congress"
cd ~/git/congress
-sudo pip install -r requirements.txt
-sudo pip install .
+bin/pip install -r requirements.txt
+bin/pip install .
echo "install tox"
-sudo pip install tox
+bin/pip install tox
echo "generate congress.conf.sample"
-sudo tox -egenconfig
+tox -egenconfig
echo "edit congress.conf.sample as needed"
-sudo sed -i -- 's/#verbose = true/verbose = true/g' etc/congress.conf.sample
-sudo sed -i -- 's/#log_file = <None>/log_file = congress.log/g' etc/congress.conf.sample
-sudo sed -i -- 's/#log_dir = <None>/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 = <None>/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 = <None>/admin_user = congress/g' etc/congress.conf.sample
-sudo sed -i -- 's/#admin_password = <None>/admin_password = congress/g' etc/congress.conf.sample
-sudo sed -i -- 's/#connection = <None>/connection = mysql:\/\/ubuntu:'$MYSQL_PASSWORD'@localhost:3306\/congress/g' etc/congress.conf.sample
+sed -i -- 's/#verbose = true/verbose = true/g' etc/congress.conf.sample
+sed -i -- 's/#log_file = <None>/log_file = congress.log/g' etc/congress.conf.sample
+sed -i -- 's/#log_dir = <None>/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 = <None>/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 = <None>/admin_user = congress/g' etc/congress.conf.sample
+sed -i -- 's/#admin_password = <None>/admin_password = congress/g' etc/congress.conf.sample
+sed -i -- 's/#connection = <None>/connection = mysql:\/\/ubuntu:'$MYSQL_PASSWORD'@localhost:3306\/congress/g' etc/congress.conf.sample
echo "copy congress.conf.sample to /etc/congress"
-sudo cp etc/congress.conf.sample /etc/congress/congress.conf
+cp etc/congress.conf.sample /etc/congress/congress.conf
echo "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"';"
echo "install congress-db-manage dependencies (detected by errors)"
sudo apt-get build-dep python-mysqldb -y
-pip install MySQL-python
+bin/pip install MySQL-python
echo "create database schema"
congress-db-manage --config-file /etc/congress/congress.conf upgrade head
-echo "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
-
-echo "Install and test Congress client"
+echo "Install 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
-
-echo "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 .
-
-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 in the background"
-cd ~/git/congress
-sudo bin/congress-server &
-
-echo "disown the process (so it keeps running if you get disconnected)"
-disown -h %1
-
-echo "Create data sources"
-# To remove datasources: openstack congress datasource delete <name>
-# 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
-
-echo "Run Congress Tempest Tests"
-cd ~/git/congress
-# tox -epy27
+../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/ubuntu/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