Andy Bavier | 050dc83 | 2015-08-05 15:41:39 -0400 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | set -x |
Andy Bavier | 4b8504a | 2015-08-04 17:25:17 -0400 | [diff] [blame] | 3 | |
Andy Bavier | cc0aacc | 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 | 050dc83 | 2015-08-05 15:41:39 -0400 | [diff] [blame] | 5 | # profile on CloudLab. |
Andy Bavier | 4b8504a | 2015-08-04 17:25:17 -0400 | [diff] [blame] | 6 | |
Andy Bavier | 050dc83 | 2015-08-05 15:41:39 -0400 | [diff] [blame] | 7 | XOS="http://ctl:9999/" |
Andy Bavier | 4b8504a | 2015-08-04 17:25:17 -0400 | [diff] [blame] | 8 | AUTH="padmin@vicci.org:letmein" |
Andy Bavier | cc0aacc | 2015-09-01 17:43:03 -0400 | [diff] [blame] | 9 | CORD=0 |
| 10 | IMAGE="xos" |
Andy Bavier | 050dc83 | 2015-08-05 15:41:39 -0400 | [diff] [blame] | 11 | |
Andy Bavier | f315161 | 2015-09-01 14:19:11 -0400 | [diff] [blame] | 12 | # Create public key if none present |
Andy Bavier | 8458209 | 2015-09-01 18:02:28 -0400 | [diff] [blame] | 13 | [ -e ~/.ssh/id_rsa ] || cat /dev/zero | ssh-keygen -q -N "" |
Andy Bavier | f315161 | 2015-09-01 14:19:11 -0400 | [diff] [blame] | 14 | |
Andy Bavier | 050dc83 | 2015-08-05 15:41:39 -0400 | [diff] [blame] | 15 | # Install Docker |
Andy Bavier | 516be12 | 2015-09-01 17:57:52 -0400 | [diff] [blame] | 16 | which docker > /dev/null || wget -qO- https://get.docker.com/ | sh |
Andy Bavier | 050dc83 | 2015-08-05 15:41:39 -0400 | [diff] [blame] | 17 | sudo usermod -aG docker $(whoami) |
| 18 | |
Andy Bavier | a4b4e91 | 2015-09-28 10:28:17 -0400 | [diff] [blame] | 19 | sudo apt-get -y install httpie |
Andy Bavier | 050dc83 | 2015-08-05 15:41:39 -0400 | [diff] [blame] | 20 | |
Andy Bavier | cc0aacc | 2015-09-01 17:43:03 -0400 | [diff] [blame] | 21 | if [ "$CORD" -ne 0 ] |
| 22 | then |
Andy Bavier | 8458209 | 2015-09-01 18:02:28 -0400 | [diff] [blame] | 23 | cp ~/.ssh/id_rsa.pub xos/observers/vcpe/vcpe_public_key |
| 24 | cp ~/.ssh/id_rsa xos/observers/vcpe/vcpe_private_key |
svavilap | fa144d8 | 2015-10-13 23:50:03 -0400 | [diff] [blame] | 25 | cp ~/.ssh/id_rsa.pub xos/observers/monitoring_channel/monitoring_channel_public_key |
| 26 | cp ~/.ssh/id_rsa xos/observers/monitoring_channel/monitoring_channel_private_key |
Andy Bavier | cc0aacc | 2015-09-01 17:43:03 -0400 | [diff] [blame] | 27 | fi |
| 28 | |
Jeremy Mowery | 3c1239c | 2015-10-27 13:06:56 -0700 | [diff] [blame^] | 29 | cp ~/.ssh/id_rsa xos/observers/helloworldservice/helloworldservice_private_key |
| 30 | |
Andy Bavier | f0bd80b | 2015-08-06 10:33:14 -0400 | [diff] [blame] | 31 | sudo docker build -t xos . |
Andy Bavier | 050dc83 | 2015-08-05 15:41:39 -0400 | [diff] [blame] | 32 | |
Andy Bavier | cc0aacc | 2015-09-01 17:43:03 -0400 | [diff] [blame] | 33 | if [ "$CORD" -ne 0 ] |
| 34 | then |
| 35 | sudo docker build -t cord -f Dockerfile.cord . |
| 36 | IMAGE="cord" |
| 37 | fi |
| 38 | |
Andy Bavier | 050dc83 | 2015-08-05 15:41:39 -0400 | [diff] [blame] | 39 | # OpenStack is using port 8000... |
| 40 | MYIP=$( hostname -i ) |
svavilap | fa144d8 | 2015-10-13 23:50:03 -0400 | [diff] [blame] | 41 | MYFLATLANIF=$( sudo bash -c "netstat -i" |grep flat|awk '{print $1}' ) |
| 42 | MYFLATLANIP=$( ifconfig $MYFLATLANIF | grep "inet addr" | awk -F: '{print $2}' | awk '{print $1}' ) |
Andy Bavier | cc0aacc | 2015-09-01 17:43:03 -0400 | [diff] [blame] | 43 | sudo docker run -d --add-host="ctl:$MYIP" -p 9999:8000 $IMAGE |
Andy Bavier | 050dc83 | 2015-08-05 15:41:39 -0400 | [diff] [blame] | 44 | |
| 45 | echo "Waiting for XOS to come up" |
| 46 | until http $XOS &> /dev/null |
| 47 | do |
| 48 | sleep 1 |
| 49 | done |
| 50 | |
Andy Bavier | 4b8504a | 2015-08-04 17:25:17 -0400 | [diff] [blame] | 51 | # Copy public key |
| 52 | # BUG: Shouldn't have to set the 'enacted' field... |
Andy Bavier | 8458209 | 2015-09-01 18:02:28 -0400 | [diff] [blame] | 53 | PUBKEY=$( cat ~/.ssh/id_rsa.pub ) |
Andy Bavier | 4b8504a | 2015-08-04 17:25:17 -0400 | [diff] [blame] | 54 | http --auth $AUTH PATCH $XOS/xos/users/1/ public_key="$PUBKEY" enacted=$( date "+%Y-%m-%dT%T") |
| 55 | |
Andy Bavier | 4b8504a | 2015-08-04 17:25:17 -0400 | [diff] [blame] | 56 | # Set up controller |
Andy Bavier | 28c397d | 2015-09-28 11:44:36 -0400 | [diff] [blame] | 57 | sudo cp /root/setup/admin-openrc.sh /tmp |
| 58 | sudo chmod a+r /tmp/admin-openrc.sh |
| 59 | #sudo sed -i 's/:5000/:35357/' /tmp/admin-openrc.sh |
| 60 | source /tmp/admin-openrc.sh |
svavilap | fa144d8 | 2015-10-13 23:50:03 -0400 | [diff] [blame] | 61 | |
| 62 | if [ "$CORD" -ne 1 ] |
| 63 | then |
| 64 | http --auth $AUTH POST $XOS/xos/controllers/ name=CloudLab deployment=$XOS/xos/deployments/1/ backend_type=OpenStack version=Kilo auth_url=$OS_AUTH_URL admin_user=$OS_USERNAME admin_tenant=$OS_TENANT_NAME admin_password=$OS_PASSWORD domain=Default |
| 65 | else |
| 66 | sudo cp /root/setup/settings /tmp |
| 67 | sudo chmod a+r /tmp/settings |
| 68 | source /tmp/settings |
| 69 | source /tmp/admin-openrc.sh |
| 70 | http --auth $AUTH POST $XOS/xos/controllers/ name=CloudLab deployment=$XOS/xos/deployments/1/ backend_type=OpenStack version=Kilo auth_url=$OS_AUTH_URL admin_user=$OS_USERNAME admin_tenant=$OS_TENANT_NAME admin_password=$OS_PASSWORD domain=Default rabbit_host=$MYFLATLANIP rabbit_user=$RABBIT_USER rabbit_password=$RABBIT_PASS |
| 71 | fi |
Andy Bavier | 4b8504a | 2015-08-04 17:25:17 -0400 | [diff] [blame] | 72 | |
| 73 | # Add controller to site |
| 74 | http --auth $AUTH PATCH $XOS/xos/sitedeployments/1/ controller=$XOS/xos/controllers/1/ |
| 75 | |
| 76 | # Add image |
| 77 | http --auth $AUTH POST $XOS/xos/images/ name=trusty-server-multi-nic disk_format=QCOW2 container_format=BARE |
| 78 | |
| 79 | # Activate image |
| 80 | http --auth $AUTH POST $XOS/xos/imagedeploymentses/ deployment=$XOS/xos/deployments/1/ image=$XOS/xos/images/1/ |
| 81 | |
| 82 | # Add node |
Andy Bavier | d135771 | 2015-08-07 12:28:49 -0400 | [diff] [blame] | 83 | NODES=$( sudo bash -c "source /root/setup/admin-openrc.sh ; nova hypervisor-list" |grep cloudlab|awk '{print $4}' ) |
| 84 | for NODE in $NODES |
| 85 | do |
| 86 | http --auth $AUTH POST $XOS/xos/nodes/ name=$NODE site_deployment=$XOS/xos/sitedeployments/1/ |
| 87 | done |
Andy Bavier | 4b8504a | 2015-08-04 17:25:17 -0400 | [diff] [blame] | 88 | |
| 89 | # Modify networktemplate/2 |
| 90 | # BUG: Shouldn't have to set the controller_kind field, it's invalid in the initial fixture |
Andy Bavier | 5664682 | 2015-08-06 10:34:12 -0400 | [diff] [blame] | 91 | FLATNET=$( sudo bash -c "source /root/setup/admin-openrc.sh ; neutron net-list" |grep flat|awk '{print $4}' ) |
Andy Bavier | f0bd80b | 2015-08-06 10:33:14 -0400 | [diff] [blame] | 92 | http --auth $AUTH PATCH $XOS/xos/networktemplates/2/ shared_network_name=$FLATNET controller_kind="" |
Andy Bavier | 6d1041c | 2015-09-03 11:21:22 -0400 | [diff] [blame] | 93 | |
| 94 | if [ "$CORD" -ne 0 ] |
| 95 | then |
Andy Bavier | 487f8cf | 2015-09-15 15:18:53 -0400 | [diff] [blame] | 96 | DOCKER=$( sudo docker ps|grep $IMAGE|awk '{print $NF}' ) |
svavilap | fa144d8 | 2015-10-13 23:50:03 -0400 | [diff] [blame] | 97 | sudo docker exec $DOCKER bash -c "cd /opt/xos/tosca; python run.py padmin@vicci.org samples/cord-cloudlab.yaml; python run.py padmin@vicci.org samples/ceilometer.yaml" |
Andy Bavier | 6d1041c | 2015-09-03 11:21:22 -0400 | [diff] [blame] | 98 | fi |