blob: ebdfec8a07c3599f5ac3da7bdc77879da4e900c4 [file] [log] [blame]
Thomas Vachuskac419f0e2018-02-07 14:24:46 -08001#!/bin/bash
Thomas Vachuskac419f0e2018-02-07 14:24:46 -08002export PATH="$PATH:bin:onos/bin"
3
Thomas Vachuskac419f0e2018-02-07 14:24:46 -08004SSH_KEY=$(cut -d\ -f2 ~/.ssh/id_rsa.pub)
5
Thomas Vachuskae7013e92018-09-12 01:18:43 -07006# Create Atomix cluster using Atomix docker image
7ATOMIX_IMAGE=atomix/atomix:3.0.5
8for i in {1..3}; do
9 echo "Setting up atomix-$i..."
10 docker container run --detach --name atomix-$i --hostname atomix-$i \
11 --restart=always -v /home/sdn/bin/config:/atomix $ATOMIX_IMAGE \
12 --config /atomix/atomix-$i.conf
13done
14
15# Create ONOS cluster using ONOS docker image
16ONOS_IMAGE=onosproject/onos:1.14.0
Thomas Vachuskac419f0e2018-02-07 14:24:46 -080017for i in {1..3}; do
18 echo "Setting up onos-$i..."
Thomas Vachuskae7013e92018-09-12 01:18:43 -070019 docker container run --detach --name onos-$i --hostname onos-$i --restart=always $ONOS_IMAGE
20 docker exec -i onos-$i /bin/bash -c "mkdir config; cat > config/cluster.json" < $(dirname $0)/config/cluster-$i.json
Thomas Vachuskac419f0e2018-02-07 14:24:46 -080021 docker exec -it onos-$i bin/onos-user-key sdn $SSH_KEY >/dev/null 2>&1
22 docker exec -it onos-$i bin/onos-user-password onos rocks >/dev/null 2>&1
23done
24
25function waitForStart {
26 sleep 5
27 for i in {1..3}; do
28 echo "Waiting for onos-$i startup..."
29 ip=$(docker container inspect onos-$i | grep \"IPAddress | cut -d: -f2 | sort -u | tr -d '", ')
Thomas Vachuska61f0e0b2018-05-15 14:08:11 -070030 for t in {1..60}; do
31 curl --fail -sS http://$ip:8181/onos/v1/applications --user onos:rocks 1>/dev/null 2>&1 && break;
Thomas Vachuskac419f0e2018-02-07 14:24:46 -080032 sleep 1;
33 done
34 onos $ip summary >/dev/null 2>&1
35 done
36}
37
Thomas Vachuskae7013e92018-09-12 01:18:43 -070038# Extract the IP addresses of the ONOS nodes
Thomas Vachuskac419f0e2018-02-07 14:24:46 -080039OC1=$(docker container inspect onos-1 | grep \"IPAddress | cut -d: -f2 | sort -u | tr -d '", ')
40OC2=$(docker container inspect onos-2 | grep \"IPAddress | cut -d: -f2 | sort -u | tr -d '", ')
41OC3=$(docker container inspect onos-3 | grep \"IPAddress | cut -d: -f2 | sort -u | tr -d '", ')
42ONOS_INSTANCES="$OC1 $OC2 $OC3"
43
44waitForStart
45
46echo "Activating OpenFlow and ProxyARP applications..."
Thomas Vachuska61f0e0b2018-05-15 14:08:11 -070047onos $OC1 app activate org.onosproject.openflow proxyarp layout
Thomas Vachuskac419f0e2018-02-07 14:24:46 -080048onos $OC1
49