Andy Bavier | 628710c | 2015-08-05 15:41:39 -0400 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | set -x |
Andy Bavier | d54e0f5 | 2015-08-04 17:25:17 -0400 | [diff] [blame] | 3 | |
Andy Bavier | 628710c | 2015-08-05 15:41:39 -0400 | [diff] [blame] | 4 | # This script assumes that it is being run on the ctl node of the Tutorial-OpenStack |
| 5 | # profile on CloudLab. |
Andy Bavier | d54e0f5 | 2015-08-04 17:25:17 -0400 | [diff] [blame] | 6 | |
Andy Bavier | 628710c | 2015-08-05 15:41:39 -0400 | [diff] [blame] | 7 | XOS="http://ctl:9999/" |
Andy Bavier | d54e0f5 | 2015-08-04 17:25:17 -0400 | [diff] [blame] | 8 | AUTH="padmin@vicci.org:letmein" |
Andy Bavier | 628710c | 2015-08-05 15:41:39 -0400 | [diff] [blame] | 9 | |
| 10 | # Install Docker |
| 11 | wget -qO- https://get.docker.com/ | sh |
| 12 | sudo usermod -aG docker $(whoami) |
| 13 | |
| 14 | sudo apt-get install httpie |
| 15 | |
Andy Bavier | 1b8fd47 | 2015-08-06 10:33:14 -0400 | [diff] [blame] | 16 | sudo docker build -t xos . |
Andy Bavier | 628710c | 2015-08-05 15:41:39 -0400 | [diff] [blame] | 17 | |
| 18 | # OpenStack is using port 8000... |
| 19 | MYIP=$( hostname -i ) |
Andy Bavier | 1b8fd47 | 2015-08-06 10:33:14 -0400 | [diff] [blame] | 20 | sudo docker run -d --add-host="ctl:$MYIP" -p 9999:8000 xos |
Andy Bavier | 628710c | 2015-08-05 15:41:39 -0400 | [diff] [blame] | 21 | |
| 22 | echo "Waiting for XOS to come up" |
| 23 | until http $XOS &> /dev/null |
| 24 | do |
| 25 | sleep 1 |
| 26 | done |
| 27 | |
| 28 | # Create public key if none present |
| 29 | cat /dev/zero | ssh-keygen -q -N "" |
| 30 | PUBKEY=$( cat ~/.ssh/id_rsa.pub ) |
Andy Bavier | d54e0f5 | 2015-08-04 17:25:17 -0400 | [diff] [blame] | 31 | |
| 32 | # Copy public key |
| 33 | # BUG: Shouldn't have to set the 'enacted' field... |
| 34 | http --auth $AUTH PATCH $XOS/xos/users/1/ public_key="$PUBKEY" enacted=$( date "+%Y-%m-%dT%T") |
| 35 | |
Andy Bavier | d54e0f5 | 2015-08-04 17:25:17 -0400 | [diff] [blame] | 36 | # Set up controller |
| 37 | http --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 |
| 40 | http --auth $AUTH PATCH $XOS/xos/sitedeployments/1/ controller=$XOS/xos/controllers/1/ |
| 41 | |
| 42 | # Add image |
| 43 | http --auth $AUTH POST $XOS/xos/images/ name=trusty-server-multi-nic disk_format=QCOW2 container_format=BARE |
| 44 | |
| 45 | # Activate image |
| 46 | http --auth $AUTH POST $XOS/xos/imagedeploymentses/ deployment=$XOS/xos/deployments/1/ image=$XOS/xos/images/1/ |
| 47 | |
| 48 | # Add node |
Andy Bavier | adff3dc | 2015-08-07 12:28:49 -0400 | [diff] [blame] | 49 | NODES=$( sudo bash -c "source /root/setup/admin-openrc.sh ; nova hypervisor-list" |grep cloudlab|awk '{print $4}' ) |
| 50 | for NODE in $NODES |
| 51 | do |
| 52 | http --auth $AUTH POST $XOS/xos/nodes/ name=$NODE site_deployment=$XOS/xos/sitedeployments/1/ |
| 53 | done |
Andy Bavier | d54e0f5 | 2015-08-04 17:25:17 -0400 | [diff] [blame] | 54 | |
| 55 | # Modify networktemplate/2 |
| 56 | # BUG: Shouldn't have to set the controller_kind field, it's invalid in the initial fixture |
Andy Bavier | 753f482 | 2015-08-06 10:34:12 -0400 | [diff] [blame] | 57 | FLATNET=$( sudo bash -c "source /root/setup/admin-openrc.sh ; neutron net-list" |grep flat|awk '{print $4}' ) |
Andy Bavier | 1b8fd47 | 2015-08-06 10:33:14 -0400 | [diff] [blame] | 58 | http --auth $AUTH PATCH $XOS/xos/networktemplates/2/ shared_network_name=$FLATNET controller_kind="" |