blob: bf4308208c61ffec735e22e2a5d6e5bc2d2702ca [file] [log] [blame]
Andy Bavier628710c2015-08-05 15:41:39 -04001#!/bin/bash
2set -x
Andy Bavierd54e0f52015-08-04 17:25:17 -04003
Andy Bavier628710c2015-08-05 15:41:39 -04004# This script assumes that it is being run on the ctl node of the Tutorial-OpenStack
5# 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 Bavier628710c2015-08-05 15:41:39 -04009
10# Install Docker
11wget -qO- https://get.docker.com/ | sh
12sudo usermod -aG docker $(whoami)
13
14sudo apt-get install httpie
15
Andy Bavier1b8fd472015-08-06 10:33:14 -040016sudo docker build -t xos .
Andy Bavier628710c2015-08-05 15:41:39 -040017
18# OpenStack is using port 8000...
19MYIP=$( hostname -i )
Andy Bavier1b8fd472015-08-06 10:33:14 -040020sudo docker run -d --add-host="ctl:$MYIP" -p 9999:8000 xos
Andy Bavier628710c2015-08-05 15:41:39 -040021
22echo "Waiting for XOS to come up"
23until http $XOS &> /dev/null
24do
25 sleep 1
26done
27
28# Create public key if none present
29cat /dev/zero | ssh-keygen -q -N ""
30PUBKEY=$( cat ~/.ssh/id_rsa.pub )
Andy Bavierd54e0f52015-08-04 17:25:17 -040031
32# Copy public key
33# BUG: Shouldn't have to set the 'enacted' field...
34http --auth $AUTH PATCH $XOS/xos/users/1/ public_key="$PUBKEY" enacted=$( date "+%Y-%m-%dT%T")
35
Andy Bavierd54e0f52015-08-04 17:25:17 -040036# Set up controller
37http --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"
38
39# Add controller to site
40http --auth $AUTH PATCH $XOS/xos/sitedeployments/1/ controller=$XOS/xos/controllers/1/
41
42# Add image
43http --auth $AUTH POST $XOS/xos/images/ name=trusty-server-multi-nic disk_format=QCOW2 container_format=BARE
44
45# Activate image
46http --auth $AUTH POST $XOS/xos/imagedeploymentses/ deployment=$XOS/xos/deployments/1/ image=$XOS/xos/images/1/
47
48# Add node
Andy Bavier628710c2015-08-05 15:41:39 -040049NODE=$( sudo bash -c "source /root/setup/admin-openrc.sh ; nova hypervisor-list" |grep cloudlab|awk '{print $4}' )
Andy Bavierd54e0f52015-08-04 17:25:17 -040050http --auth $AUTH POST $XOS/xos/nodes/ name=$NODE site_deployment=$XOS/xos/sitedeployments/1/
51
52# Modify networktemplate/2
53# BUG: Shouldn't have to set the controller_kind field, it's invalid in the initial fixture
Andy Bavier1b8fd472015-08-06 10:33:14 -040054FLATNET=$( sudo bash -c "source /root/setup/admin-openrc.sh ; netron net-list" |grep flat|awk '{print $4}' )
55http --auth $AUTH PATCH $XOS/xos/networktemplates/2/ shared_network_name=$FLATNET controller_kind=""