blob: 20ba51aba6ee6afc9cf6d01c08eaa24ac02baed5 [file] [log] [blame]
Andy Bavier050dc832015-08-05 15:41:39 -04001#!/bin/bash
2set -x
Andy Bavier4b8504a2015-08-04 17:25:17 -04003
Andy Baviercc0aacc2015-09-01 17:43:03 -04004# This script assumes that it is being run on the ctl node of the OpenStack
Andy Bavier050dc832015-08-05 15:41:39 -04005# profile on CloudLab.
Andy Bavier4b8504a2015-08-04 17:25:17 -04006
Andy Bavier050dc832015-08-05 15:41:39 -04007XOS="http://ctl:9999/"
Andy Bavier4b8504a2015-08-04 17:25:17 -04008AUTH="padmin@vicci.org:letmein"
Andy Baviercc0aacc2015-09-01 17:43:03 -04009CORD=0
10IMAGE="xos"
Andy Bavier050dc832015-08-05 15:41:39 -040011
Andy Bavierf3151612015-09-01 14:19:11 -040012# Create public key if none present
Andy Bavier84582092015-09-01 18:02:28 -040013[ -e ~/.ssh/id_rsa ] || cat /dev/zero | ssh-keygen -q -N ""
Andy Bavierf3151612015-09-01 14:19:11 -040014
Andy Bavier050dc832015-08-05 15:41:39 -040015# Install Docker
Andy Bavier516be122015-09-01 17:57:52 -040016which docker > /dev/null || wget -qO- https://get.docker.com/ | sh
Andy Bavier050dc832015-08-05 15:41:39 -040017sudo usermod -aG docker $(whoami)
18
Andy Baviera4b4e912015-09-28 10:28:17 -040019sudo apt-get -y install httpie
Andy Bavier050dc832015-08-05 15:41:39 -040020
Andy Baviercc0aacc2015-09-01 17:43:03 -040021if [ "$CORD" -ne 0 ]
22then
Andy Bavier84582092015-09-01 18:02:28 -040023 cp ~/.ssh/id_rsa.pub xos/observers/vcpe/vcpe_public_key
24 cp ~/.ssh/id_rsa xos/observers/vcpe/vcpe_private_key
svavilapfa144d82015-10-13 23:50:03 -040025 cp ~/.ssh/id_rsa.pub xos/observers/monitoring_channel/monitoring_channel_public_key
26 cp ~/.ssh/id_rsa xos/observers/monitoring_channel/monitoring_channel_private_key
Andy Baviercc0aacc2015-09-01 17:43:03 -040027fi
28
Jeremy Mowery3c1239c2015-10-27 13:06:56 -070029cp ~/.ssh/id_rsa xos/observers/helloworldservice/helloworldservice_private_key
30
Andy Bavierf0bd80b2015-08-06 10:33:14 -040031sudo docker build -t xos .
Andy Bavier050dc832015-08-05 15:41:39 -040032
Andy Baviercc0aacc2015-09-01 17:43:03 -040033if [ "$CORD" -ne 0 ]
34then
35 sudo docker build -t cord -f Dockerfile.cord .
36 IMAGE="cord"
37fi
38
Andy Bavier050dc832015-08-05 15:41:39 -040039# OpenStack is using port 8000...
40MYIP=$( hostname -i )
svavilapfa144d82015-10-13 23:50:03 -040041MYFLATLANIF=$( sudo bash -c "netstat -i" |grep flat|awk '{print $1}' )
42MYFLATLANIP=$( ifconfig $MYFLATLANIF | grep "inet addr" | awk -F: '{print $2}' | awk '{print $1}' )
Andy Baviercc0aacc2015-09-01 17:43:03 -040043sudo docker run -d --add-host="ctl:$MYIP" -p 9999:8000 $IMAGE
Andy Bavier050dc832015-08-05 15:41:39 -040044
45echo "Waiting for XOS to come up"
46until http $XOS &> /dev/null
47do
48 sleep 1
49done
50
Andy Bavier4b8504a2015-08-04 17:25:17 -040051# Copy public key
52# BUG: Shouldn't have to set the 'enacted' field...
Andy Bavier84582092015-09-01 18:02:28 -040053PUBKEY=$( cat ~/.ssh/id_rsa.pub )
Andy Bavier4b8504a2015-08-04 17:25:17 -040054http --auth $AUTH PATCH $XOS/xos/users/1/ public_key="$PUBKEY" enacted=$( date "+%Y-%m-%dT%T")
55
Andy Bavier4b8504a2015-08-04 17:25:17 -040056# Set up controller
Andy Bavier28c397d2015-09-28 11:44:36 -040057sudo cp /root/setup/admin-openrc.sh /tmp
58sudo chmod a+r /tmp/admin-openrc.sh
59#sudo sed -i 's/:5000/:35357/' /tmp/admin-openrc.sh
60source /tmp/admin-openrc.sh
svavilapfa144d82015-10-13 23:50:03 -040061
62if [ "$CORD" -ne 1 ]
63then
64 http --auth $AUTH POST $XOS/xos/controllers/ name=CloudLab deployment=$XOS/xos/deployments/1/ backend_type=OpenStack version=Kilo auth_url=$OS_AUTH_URL admin_user=$OS_USERNAME admin_tenant=$OS_TENANT_NAME admin_password=$OS_PASSWORD domain=Default
65else
66 sudo cp /root/setup/settings /tmp
67 sudo chmod a+r /tmp/settings
68 source /tmp/settings
69 source /tmp/admin-openrc.sh
70 http --auth $AUTH POST $XOS/xos/controllers/ name=CloudLab deployment=$XOS/xos/deployments/1/ backend_type=OpenStack version=Kilo auth_url=$OS_AUTH_URL admin_user=$OS_USERNAME admin_tenant=$OS_TENANT_NAME admin_password=$OS_PASSWORD domain=Default rabbit_host=$MYFLATLANIP rabbit_user=$RABBIT_USER rabbit_password=$RABBIT_PASS
71fi
Andy Bavier4b8504a2015-08-04 17:25:17 -040072
73# Add controller to site
74http --auth $AUTH PATCH $XOS/xos/sitedeployments/1/ controller=$XOS/xos/controllers/1/
75
76# Add image
77http --auth $AUTH POST $XOS/xos/images/ name=trusty-server-multi-nic disk_format=QCOW2 container_format=BARE
78
79# Activate image
80http --auth $AUTH POST $XOS/xos/imagedeploymentses/ deployment=$XOS/xos/deployments/1/ image=$XOS/xos/images/1/
81
82# Add node
Andy Bavierd1357712015-08-07 12:28:49 -040083NODES=$( sudo bash -c "source /root/setup/admin-openrc.sh ; nova hypervisor-list" |grep cloudlab|awk '{print $4}' )
84for NODE in $NODES
85do
86 http --auth $AUTH POST $XOS/xos/nodes/ name=$NODE site_deployment=$XOS/xos/sitedeployments/1/
87done
Andy Bavier4b8504a2015-08-04 17:25:17 -040088
89# Modify networktemplate/2
90# BUG: Shouldn't have to set the controller_kind field, it's invalid in the initial fixture
Andy Bavier56646822015-08-06 10:34:12 -040091FLATNET=$( sudo bash -c "source /root/setup/admin-openrc.sh ; neutron net-list" |grep flat|awk '{print $4}' )
Andy Bavierf0bd80b2015-08-06 10:33:14 -040092http --auth $AUTH PATCH $XOS/xos/networktemplates/2/ shared_network_name=$FLATNET controller_kind=""
Andy Bavier6d1041c2015-09-03 11:21:22 -040093
94if [ "$CORD" -ne 0 ]
95then
Andy Bavier487f8cf2015-09-15 15:18:53 -040096 DOCKER=$( sudo docker ps|grep $IMAGE|awk '{print $NF}' )
svavilapfa144d82015-10-13 23:50:03 -040097 sudo docker exec $DOCKER bash -c "cd /opt/xos/tosca; python run.py padmin@vicci.org samples/cord-cloudlab.yaml; python run.py padmin@vicci.org samples/ceilometer.yaml"
Andy Bavier6d1041c2015-09-03 11:21:22 -040098fi