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 | adc065d | 2015-09-01 17:43:03 -0400 | [diff] [blame] | 4 | # This script assumes that it is being run on the ctl node of the OpenStack |
Andy Bavier | 628710c | 2015-08-05 15:41:39 -0400 | [diff] [blame] | 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 | adc065d | 2015-09-01 17:43:03 -0400 | [diff] [blame] | 9 | CORD=0 |
| 10 | IMAGE="xos" |
Andy Bavier | b79acf7 | 2015-09-01 17:57:52 -0400 | [diff] [blame^] | 11 | KEYFILE="~/.ssh/id_rsa" |
Andy Bavier | 628710c | 2015-08-05 15:41:39 -0400 | [diff] [blame] | 12 | |
Andy Bavier | 8954c2e | 2015-09-01 14:19:11 -0400 | [diff] [blame] | 13 | # Create public key if none present |
Andy Bavier | b79acf7 | 2015-09-01 17:57:52 -0400 | [diff] [blame^] | 14 | [ -e $KEYFILE ] || cat /dev/zero | ssh-keygen -q -N "" |
Andy Bavier | 8954c2e | 2015-09-01 14:19:11 -0400 | [diff] [blame] | 15 | |
Andy Bavier | 628710c | 2015-08-05 15:41:39 -0400 | [diff] [blame] | 16 | # Install Docker |
Andy Bavier | b79acf7 | 2015-09-01 17:57:52 -0400 | [diff] [blame^] | 17 | which docker > /dev/null || wget -qO- https://get.docker.com/ | sh |
Andy Bavier | 628710c | 2015-08-05 15:41:39 -0400 | [diff] [blame] | 18 | sudo usermod -aG docker $(whoami) |
| 19 | |
| 20 | sudo apt-get install httpie |
| 21 | |
Andy Bavier | adc065d | 2015-09-01 17:43:03 -0400 | [diff] [blame] | 22 | if [ "$CORD" -ne 0 ] |
| 23 | then |
Andy Bavier | b79acf7 | 2015-09-01 17:57:52 -0400 | [diff] [blame^] | 24 | cp $KEYFILE.pub xos/observers/vcpe/vcpe_public_key |
| 25 | cp $KEYFILE xos/observers/vcpe/vcpe_private_key |
Andy Bavier | adc065d | 2015-09-01 17:43:03 -0400 | [diff] [blame] | 26 | fi |
| 27 | |
Andy Bavier | 1b8fd47 | 2015-08-06 10:33:14 -0400 | [diff] [blame] | 28 | sudo docker build -t xos . |
Andy Bavier | 628710c | 2015-08-05 15:41:39 -0400 | [diff] [blame] | 29 | |
Andy Bavier | adc065d | 2015-09-01 17:43:03 -0400 | [diff] [blame] | 30 | if [ "$CORD" -ne 0 ] |
| 31 | then |
| 32 | sudo docker build -t cord -f Dockerfile.cord . |
| 33 | IMAGE="cord" |
| 34 | fi |
| 35 | |
Andy Bavier | 628710c | 2015-08-05 15:41:39 -0400 | [diff] [blame] | 36 | # OpenStack is using port 8000... |
| 37 | MYIP=$( hostname -i ) |
Andy Bavier | adc065d | 2015-09-01 17:43:03 -0400 | [diff] [blame] | 38 | sudo docker run -d --add-host="ctl:$MYIP" -p 9999:8000 $IMAGE |
Andy Bavier | 628710c | 2015-08-05 15:41:39 -0400 | [diff] [blame] | 39 | |
| 40 | echo "Waiting for XOS to come up" |
| 41 | until http $XOS &> /dev/null |
| 42 | do |
| 43 | sleep 1 |
| 44 | done |
| 45 | |
Andy Bavier | d54e0f5 | 2015-08-04 17:25:17 -0400 | [diff] [blame] | 46 | # Copy public key |
| 47 | # BUG: Shouldn't have to set the 'enacted' field... |
Andy Bavier | b79acf7 | 2015-09-01 17:57:52 -0400 | [diff] [blame^] | 48 | PUBKEY=$( cat $KEYFILE.pub ) |
Andy Bavier | d54e0f5 | 2015-08-04 17:25:17 -0400 | [diff] [blame] | 49 | http --auth $AUTH PATCH $XOS/xos/users/1/ public_key="$PUBKEY" enacted=$( date "+%Y-%m-%dT%T") |
| 50 | |
Andy Bavier | d54e0f5 | 2015-08-04 17:25:17 -0400 | [diff] [blame] | 51 | # Set up controller |
| 52 | 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" |
| 53 | |
| 54 | # Add controller to site |
| 55 | http --auth $AUTH PATCH $XOS/xos/sitedeployments/1/ controller=$XOS/xos/controllers/1/ |
| 56 | |
| 57 | # Add image |
| 58 | http --auth $AUTH POST $XOS/xos/images/ name=trusty-server-multi-nic disk_format=QCOW2 container_format=BARE |
| 59 | |
| 60 | # Activate image |
| 61 | http --auth $AUTH POST $XOS/xos/imagedeploymentses/ deployment=$XOS/xos/deployments/1/ image=$XOS/xos/images/1/ |
| 62 | |
| 63 | # Add node |
Andy Bavier | adff3dc | 2015-08-07 12:28:49 -0400 | [diff] [blame] | 64 | NODES=$( sudo bash -c "source /root/setup/admin-openrc.sh ; nova hypervisor-list" |grep cloudlab|awk '{print $4}' ) |
| 65 | for NODE in $NODES |
| 66 | do |
| 67 | http --auth $AUTH POST $XOS/xos/nodes/ name=$NODE site_deployment=$XOS/xos/sitedeployments/1/ |
| 68 | done |
Andy Bavier | d54e0f5 | 2015-08-04 17:25:17 -0400 | [diff] [blame] | 69 | |
| 70 | # Modify networktemplate/2 |
| 71 | # 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] | 72 | 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] | 73 | http --auth $AUTH PATCH $XOS/xos/networktemplates/2/ shared_network_name=$FLATNET controller_kind="" |