blob: 4f3c8f3246d8a262a7b83b1a305bb71a6a94ad30 [file] [log] [blame]
Thomas Vachuskac419f0e2018-02-07 14:24:46 -08001#!/bin/bash
2# -----------------------------------------------------------------------------
3# Creates the ONOS cluster using 3 docker container instances.
4# -----------------------------------------------------------------------------
5export PATH="$PATH:bin:onos/bin"
6
7# Creates ONOS cluster using ONOS docker images
8ONOS_IMAGE=onosproject/onos:1.12.0
9SSH_KEY=$(cut -d\ -f2 ~/.ssh/id_rsa.pub)
10
11for i in {1..3}; do
12 echo "Setting up onos-$i..."
13 docker container run --detach --name onos-$i --hostname onos-$i --restart always $ONOS_IMAGE
14 docker exec -i onos-$i /bin/bash -c "mkdir config; cat > config/cluster.json" < $(dirname $0)/cluster.json
15 docker exec -it onos-$i bin/onos-user-key sdn $SSH_KEY >/dev/null 2>&1
16 docker exec -it onos-$i bin/onos-user-password onos rocks >/dev/null 2>&1
17done
18
19function waitForStart {
20 sleep 5
21 for i in {1..3}; do
22 echo "Waiting for onos-$i startup..."
23 ip=$(docker container inspect onos-$i | grep \"IPAddress | cut -d: -f2 | sort -u | tr -d '", ')
24 for t in {1..30}; do
25 curl --fail -sS http://$ip:8181/onos/v1/cluster --user onos:rocks 1>/dev/null 2>&1 && break;
26 sleep 1;
27 done
28 onos $ip summary >/dev/null 2>&1
29 done
30}
31
32OC1=$(docker container inspect onos-1 | grep \"IPAddress | cut -d: -f2 | sort -u | tr -d '", ')
33OC2=$(docker container inspect onos-2 | grep \"IPAddress | cut -d: -f2 | sort -u | tr -d '", ')
34OC3=$(docker container inspect onos-3 | grep \"IPAddress | cut -d: -f2 | sort -u | tr -d '", ')
35ONOS_INSTANCES="$OC1 $OC2 $OC3"
36
37waitForStart
38
39echo "Activating OpenFlow and ProxyARP applications..."
40onos $OC1 app activate openflow proxyarp
41onos $OC1
42