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 | |
| 16 | docker build -t xos . |
| 17 | |
| 18 | # OpenStack is using port 8000... |
| 19 | MYIP=$( hostname -i ) |
| 20 | docker run -d --add-host="ctl:$MYIP" -p 9999:8000 xos |
| 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 | 628710c | 2015-08-05 15:41:39 -0400 | [diff] [blame] | 49 | NODE=$( sudo bash -c "source /root/setup/admin-openrc.sh ; nova hypervisor-list" |grep cloudlab|awk '{print $4}' ) |
Andy Bavier | d54e0f5 | 2015-08-04 17:25:17 -0400 | [diff] [blame] | 50 | http --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 Bavier | 27795b1 | 2015-08-05 16:13:46 -0400 | [diff] [blame] | 54 | http --auth $AUTH PATCH $XOS/xos/networktemplates/2/ shared_network_name=flat-data-net controller_kind="" |