blob: b64ac6641ca95b3e040cc0090a019c804b9af6de [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 Baviercc0aacc2015-09-01 17:43:03 -040013#cat /dev/zero | ssh-keygen -q -N ""
Andy Bavierf3151612015-09-01 14:19:11 -040014PUBKEY=$( cat ~/.ssh/id_rsa.pub )
15
Andy Bavier050dc832015-08-05 15:41:39 -040016# Install Docker
17wget -qO- https://get.docker.com/ | sh
18sudo usermod -aG docker $(whoami)
19
20sudo apt-get install httpie
21
Andy Baviercc0aacc2015-09-01 17:43:03 -040022if [ "$CORD" -ne 0 ]
23then
24 cp ~/.ssh/id_rsa.pub xos/observers/vcpe/vcpe_public_key
25 cp ~/.ssh/id_rsa xos/observers/vcpe/vcpe_private_key
26fi
27
Andy Bavierf0bd80b2015-08-06 10:33:14 -040028sudo docker build -t xos .
Andy Bavier050dc832015-08-05 15:41:39 -040029
Andy Baviercc0aacc2015-09-01 17:43:03 -040030if [ "$CORD" -ne 0 ]
31then
32 sudo docker build -t cord -f Dockerfile.cord .
33 IMAGE="cord"
34fi
35
Andy Bavier050dc832015-08-05 15:41:39 -040036# OpenStack is using port 8000...
37MYIP=$( hostname -i )
Andy Baviercc0aacc2015-09-01 17:43:03 -040038sudo docker run -d --add-host="ctl:$MYIP" -p 9999:8000 $IMAGE
Andy Bavier050dc832015-08-05 15:41:39 -040039
40echo "Waiting for XOS to come up"
41until http $XOS &> /dev/null
42do
43 sleep 1
44done
45
Andy Bavier4b8504a2015-08-04 17:25:17 -040046# Copy public key
47# BUG: Shouldn't have to set the 'enacted' field...
48http --auth $AUTH PATCH $XOS/xos/users/1/ public_key="$PUBKEY" enacted=$( date "+%Y-%m-%dT%T")
49
Andy Bavier4b8504a2015-08-04 17:25:17 -040050# Set up controller
51http --auth $AUTH POST $XOS/xos/controllers/ name=CloudLab deployment=$XOS/xos/deployments/1/ backend_type=OpenStack version=Juno auth_url="http://ctl:5000/v2.0" admin_user=admin admin_tenant=admin admin_password="N!ceD3m0"
52
53# Add controller to site
54http --auth $AUTH PATCH $XOS/xos/sitedeployments/1/ controller=$XOS/xos/controllers/1/
55
56# Add image
57http --auth $AUTH POST $XOS/xos/images/ name=trusty-server-multi-nic disk_format=QCOW2 container_format=BARE
58
59# Activate image
60http --auth $AUTH POST $XOS/xos/imagedeploymentses/ deployment=$XOS/xos/deployments/1/ image=$XOS/xos/images/1/
61
62# Add node
Andy Bavierd1357712015-08-07 12:28:49 -040063NODES=$( sudo bash -c "source /root/setup/admin-openrc.sh ; nova hypervisor-list" |grep cloudlab|awk '{print $4}' )
64for NODE in $NODES
65do
66 http --auth $AUTH POST $XOS/xos/nodes/ name=$NODE site_deployment=$XOS/xos/sitedeployments/1/
67done
Andy Bavier4b8504a2015-08-04 17:25:17 -040068
69# Modify networktemplate/2
70# BUG: Shouldn't have to set the controller_kind field, it's invalid in the initial fixture
Andy Bavier56646822015-08-06 10:34:12 -040071FLATNET=$( sudo bash -c "source /root/setup/admin-openrc.sh ; neutron net-list" |grep flat|awk '{print $4}' )
Andy Bavierf0bd80b2015-08-06 10:33:14 -040072http --auth $AUTH PATCH $XOS/xos/networktemplates/2/ shared_network_name=$FLATNET controller_kind=""