blob: f275517ae748cbfd0b8fec51c2c20afbb333cb65 [file] [log] [blame]
Andy Bavier628710c2015-08-05 15:41:39 -04001#!/bin/bash
2set -x
Andy Bavierd54e0f52015-08-04 17:25:17 -04003
Andy Bavieradc065d2015-09-01 17:43:03 -04004# This script assumes that it is being run on the ctl node of the OpenStack
Andy Bavier628710c2015-08-05 15:41:39 -04005# profile on CloudLab.
Andy Bavierd54e0f52015-08-04 17:25:17 -04006
Andy Bavier628710c2015-08-05 15:41:39 -04007XOS="http://ctl:9999/"
Andy Bavierd54e0f52015-08-04 17:25:17 -04008AUTH="padmin@vicci.org:letmein"
Andy Bavieradc065d2015-09-01 17:43:03 -04009CORD=0
10IMAGE="xos"
Andy Bavier628710c2015-08-05 15:41:39 -040011
Andy Bavier8954c2e2015-09-01 14:19:11 -040012# Create public key if none present
Andy Bavierf422f2c2015-09-01 18:02:28 -040013[ -e ~/.ssh/id_rsa ] || cat /dev/zero | ssh-keygen -q -N ""
Andy Bavier8954c2e2015-09-01 14:19:11 -040014
Andy Bavier628710c2015-08-05 15:41:39 -040015# Install Docker
Andy Bavierb79acf72015-09-01 17:57:52 -040016which docker > /dev/null || wget -qO- https://get.docker.com/ | sh
Andy Bavier628710c2015-08-05 15:41:39 -040017sudo usermod -aG docker $(whoami)
18
Andy Baviere0828bc2015-09-28 10:28:17 -040019sudo apt-get -y install httpie
Andy Bavier628710c2015-08-05 15:41:39 -040020
Andy Bavieradc065d2015-09-01 17:43:03 -040021if [ "$CORD" -ne 0 ]
22then
Andy Bavierf422f2c2015-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
Andy Bavieradc065d2015-09-01 17:43:03 -040025fi
26
Andy Bavier1b8fd472015-08-06 10:33:14 -040027sudo docker build -t xos .
Andy Bavier628710c2015-08-05 15:41:39 -040028
Andy Bavieradc065d2015-09-01 17:43:03 -040029if [ "$CORD" -ne 0 ]
30then
31 sudo docker build -t cord -f Dockerfile.cord .
32 IMAGE="cord"
33fi
34
Andy Bavier628710c2015-08-05 15:41:39 -040035# OpenStack is using port 8000...
36MYIP=$( hostname -i )
Andy Bavieradc065d2015-09-01 17:43:03 -040037sudo docker run -d --add-host="ctl:$MYIP" -p 9999:8000 $IMAGE
Andy Bavier628710c2015-08-05 15:41:39 -040038
39echo "Waiting for XOS to come up"
40until http $XOS &> /dev/null
41do
42 sleep 1
43done
44
Andy Bavierd54e0f52015-08-04 17:25:17 -040045# Copy public key
46# BUG: Shouldn't have to set the 'enacted' field...
Andy Bavierf422f2c2015-09-01 18:02:28 -040047PUBKEY=$( cat ~/.ssh/id_rsa.pub )
Andy Bavierd54e0f52015-08-04 17:25:17 -040048http --auth $AUTH PATCH $XOS/xos/users/1/ public_key="$PUBKEY" enacted=$( date "+%Y-%m-%dT%T")
49
Andy Bavierd54e0f52015-08-04 17:25:17 -040050# Set up controller
Andy Bavierddc2f552015-09-28 11:44:36 -040051sudo cp /root/setup/admin-openrc.sh /tmp
52sudo chmod a+r /tmp/admin-openrc.sh
53#sudo sed -i 's/:5000/:35357/' /tmp/admin-openrc.sh
54source /tmp/admin-openrc.sh
Andy Baviere0828bc2015-09-28 10:28:17 -040055http --auth $AUTH POST $XOS/xos/controllers/ name=CloudLab deployment=$XOS/xos/deployments/1/ backend_type=OpenStack version=Juno auth_url=$OS_AUTH_URL admin_user=$OS_USERNAME admin_tenant=$OS_TENANT_NAME admin_password=$OS_PASSWORD domain=Default
Andy Bavierd54e0f52015-08-04 17:25:17 -040056
57# Add controller to site
58http --auth $AUTH PATCH $XOS/xos/sitedeployments/1/ controller=$XOS/xos/controllers/1/
59
60# Add image
61http --auth $AUTH POST $XOS/xos/images/ name=trusty-server-multi-nic disk_format=QCOW2 container_format=BARE
62
63# Activate image
64http --auth $AUTH POST $XOS/xos/imagedeploymentses/ deployment=$XOS/xos/deployments/1/ image=$XOS/xos/images/1/
65
66# Add node
Andy Bavieradff3dc2015-08-07 12:28:49 -040067NODES=$( sudo bash -c "source /root/setup/admin-openrc.sh ; nova hypervisor-list" |grep cloudlab|awk '{print $4}' )
68for NODE in $NODES
69do
70 http --auth $AUTH POST $XOS/xos/nodes/ name=$NODE site_deployment=$XOS/xos/sitedeployments/1/
71done
Andy Bavierd54e0f52015-08-04 17:25:17 -040072
73# Modify networktemplate/2
74# BUG: Shouldn't have to set the controller_kind field, it's invalid in the initial fixture
Andy Bavier753f4822015-08-06 10:34:12 -040075FLATNET=$( sudo bash -c "source /root/setup/admin-openrc.sh ; neutron net-list" |grep flat|awk '{print $4}' )
Andy Bavier1b8fd472015-08-06 10:33:14 -040076http --auth $AUTH PATCH $XOS/xos/networktemplates/2/ shared_network_name=$FLATNET controller_kind=""
Andy Bavierc5302fc2015-09-03 11:21:22 -040077
78if [ "$CORD" -ne 0 ]
79then
Andy Bavier9a1719c2015-09-15 15:18:53 -040080 DOCKER=$( sudo docker ps|grep $IMAGE|awk '{print $NF}' )
81 sudo docker exec $DOCKER bash -c "cd /opt/xos/tosca; python run.py padmin@vicci.org samples/cord-cloudlab.yaml"
Andy Bavierc5302fc2015-09-03 11:21:22 -040082fi