blob: 5c54811c23e35f81b744d7b48c7609a24c875d20 [file] [log] [blame]
Andy Bavierea5b44c2016-04-08 16:12:30 -04001#!/bin/bash
2
Andy Bavier76349042016-05-04 16:10:29 -07003function bootstrap() {
4 cd ~
5 sudo apt-get update
6 sudo apt-get -y install git
7 git clone https://github.com/open-cloud/openstack-cluster-setup.git
8 cd ~/openstack-cluster-setup
9 git checkout roles
10 sed -i "s/zdw/acb/" inventory/cord-cloudlab
11 cp vars/example_keystone.yml vars/cord_keystone.yml
Andy Bavierea5b44c2016-04-08 16:12:30 -040012
Andy Bavier76349042016-05-04 16:10:29 -070013 ./bootstrap.sh
Andy Bavierea5b44c2016-04-08 16:12:30 -040014
Andy Bavier76349042016-05-04 16:10:29 -070015 # Log into the local node once to get host key
16 ssh -o StrictHostKeyChecking=no localhost "ls > /dev/null"
17}
18
19function setup_openstack() {
20 # Run the playbook
21 ansible-playbook -i inventory/cord-cloudlab cord-single-playbook.yml
22}
23
24function pull_docker_images() {
25 # Pull down the Docker images
26 echo ""
27 echo "Pull down the Docker images for ONOS and XOS"
28 echo "This can take 20 minutes or more, be patient!"
29 ssh ubuntu@onos-cord.cordtest.opencloud.us "cd cord; sudo docker-compose up -d"
30 ssh ubuntu@xos.cordtest.opencloud.us "cd xos/xos/configurations/cord-pod; git checkout feature/roles-setup; sudo docker-compose pull"
31}
32
33function wait_for_openstack() {
34 # Need to wait for OpenStack services to come up before running any XOS "make" commands
35 echo "Waiting for the OpenStack services to fully come up."
36 echo "This can take 30 minutes or more, be patient!"
37 i=0
38 until juju status --format=summary|grep "started: 22" > /dev/null
39 do
40 sleep 60
41 (( i += 1 ))
42 echo "Waited $i minutes"
43 done
44
45 echo "All OpenStack services are up."
46}
47
48function simulate_fabric() {
49 echo ""
50 echo "Setting up simulated fabric on nova-compute node"
51 ssh ubuntu@nova-compute.cordtest.opencloud.us "wget https://raw.githubusercontent.com/open-cloud/openstack-cluster-setup/master/scripts/compute-ext-net.sh; sudo bash compute-ext-net.sh"
52}
53
54function setup_xos() {
55 echo ""
56 echo "Setting up XOS, will take a few minutes"
57 ssh ubuntu@xos.cordtest.opencloud.us "cd xos/xos/configurations/cord-pod; make"
58 echo ""
59 echo "Pause 2 minutes"
60 sleep 120
61
62 ssh ubuntu@xos.cordtest.opencloud.us "cd xos/xos/configurations/cord-pod; make vtn"
63 echo ""
64 echo "Pause 30 seconds"
65 sleep 30
66
67 ssh ubuntu@xos.cordtest.opencloud.us "cd xos/xos/configurations/cord-pod; make cord"
68}
69
70function setup_test_client() {
71 ssh ubuntu@nova-compute.cordtest.opencloud.us "sudo apt-get -y install lxc"
72
73 # Change default bridge
74 ssh ubuntu@nova-compute.cordtest.opencloud.us "sudo sed -i 's/lxcbr0/databr/' /etc/lxc/default.conf"
75
76 # Create test client
77 ssh ubuntu@nova-compute.cordtest.opencloud.us "sudo lxc-create -t ubuntu -n testclient"
78 ssh ubuntu@nova-compute.cordtest.opencloud.us "sudo lxc-start -n testclient"
79
80 # Configure network interface inside of test client with s-tag and c-tag
81 ssh ubuntu@nova-compute.cordtest.opencloud.us "sudo lxc-attach -n testclient -- ip link add link eth0 name eth0.222 type vlan id 222"
82 ssh ubuntu@nova-compute.cordtest.opencloud.us "sudo lxc-attach -n testclient -- ip link add link eth0.222 name eth0.222.111 type vlan id 111"
83 ssh ubuntu@nova-compute.cordtest.opencloud.us "sudo lxc-attach -n testclient -- ifconfig eth0.222 up"
84 ssh ubuntu@nova-compute.cordtest.opencloud.us "sudo lxc-attach -n testclient -- ifconfig eth0.222.111 up"
85}
86
87function run_e2e_test() {
88 source ~/admin-openrc.sh
89
90 echo "*** Wait for vSG VM to come up"
91 i=0
92 until nova list --all-tenants|grep ACTIVE > /dev/null
93 do
94 sleep 60
95 (( i += 1 ))
96 echo "Waited $i minutes"
97 done
98
99 # get mgmt IP address
100 ID=$( nova list --all-tenants|grep mysite_vsg|awk '{print $2}' )
101 MGMTIP=$( nova interface-list $ID|grep 172.27|awk '{print $8}' )
102
103 echo ""
104 echo "*** ssh into vsg VM, wait for Docker container to come up"
105 i=0
106 until ssh -o ProxyCommand="ssh -W %h:%p ubuntu@nova-compute" ubuntu@$MGMTIP "sudo docker ps|grep vcpe" > /dev/null
107 do
108 sleep 60
109 (( i += 1 ))
110 echo "Waited $i minutes"
111 done
112
113 echo ""
114 echo "*** Run dhclient in test client"
115 ssh ubuntu@nova-compute.cordtest.opencloud.us "sudo lxc-attach -n testclient -- dhclient eth0.222.111" > /dev/null
116
117 echo ""
118 echo "*** Routes in test client"
119 ssh ubuntu@nova-compute.cordtest.opencloud.us "sudo lxc-attach -n testclient -- route -n"
120
121
122 echo ""
123 echo "*** Test external connectivity in test client"
124 ssh ubuntu@nova-compute.cordtest.opencloud.us "sudo lxc-attach -n testclient -- ping -c 3 8.8.8.8"
125
126 echo ""
127 if [ $? -eq 0 ]
128 then
129 echo "*** [PASSED] End-to-end connectivity test"
130 exit 0
131 else
132 echo "*** [FAILED] End-to-end connectivity test"
133 exit 1
134 fi
135}
136
137# Parse options
138RUN_TEST=0
139while getopts ":ht" opt; do
140 case ${opt} in
141 h ) "echo Usage:"
142 echo " $0 install OpenStack and prep XOS and ONOS VMs [default]"
143 echo " $0 -h display this help message"
144 echo " $0 -t do install, bring up cord-pod configuration, run E2E test"
145 exit 0
146 ;;
147 t ) RUN_TEST=1
148 ;;
149 \? ) echo "Invalid option"
150 exit 1
151 ;;
152 esac
Andy Bavierea5b44c2016-04-08 16:12:30 -0400153done
154
Andy Bavier76349042016-05-04 16:10:29 -0700155# What to do
156bootstrap
157setup_openstack
158pull_docker_images
159wait_for_openstack
160simulate_fabric
161
162if [[ $RUN_TEST -eq 1 ]]
163then
164 setup_xos
165 setup_test_client
166 run_e2e_test
167fi