blob: 392be7080d012606bd64294f2852ceb2e0709caf [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
4# Creates ONOS cluster using ONOS docker images
Thomas Vachuska61f0e0b2018-05-15 14:08:11 -07005ONOS_IMAGE=onosproject/onos:1.13.1
Thomas Vachuskac419f0e2018-02-07 14:24:46 -08006SSH_KEY=$(cut -d\ -f2 ~/.ssh/id_rsa.pub)
7
8for i in {1..3}; do
9 echo "Setting up onos-$i..."
10 docker container run --detach --name onos-$i --hostname onos-$i --restart always $ONOS_IMAGE
11 docker exec -i onos-$i /bin/bash -c "mkdir config; cat > config/cluster.json" < $(dirname $0)/cluster.json
12 docker exec -it onos-$i bin/onos-user-key sdn $SSH_KEY >/dev/null 2>&1
13 docker exec -it onos-$i bin/onos-user-password onos rocks >/dev/null 2>&1
14done
15
16function waitForStart {
17 sleep 5
18 for i in {1..3}; do
19 echo "Waiting for onos-$i startup..."
20 ip=$(docker container inspect onos-$i | grep \"IPAddress | cut -d: -f2 | sort -u | tr -d '", ')
Thomas Vachuska61f0e0b2018-05-15 14:08:11 -070021 for t in {1..60}; do
22 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 -080023 sleep 1;
24 done
25 onos $ip summary >/dev/null 2>&1
26 done
27}
28
29OC1=$(docker container inspect onos-1 | grep \"IPAddress | cut -d: -f2 | sort -u | tr -d '", ')
30OC2=$(docker container inspect onos-2 | grep \"IPAddress | cut -d: -f2 | sort -u | tr -d '", ')
31OC3=$(docker container inspect onos-3 | grep \"IPAddress | cut -d: -f2 | sort -u | tr -d '", ')
32ONOS_INSTANCES="$OC1 $OC2 $OC3"
33
34waitForStart
35
36echo "Activating OpenFlow and ProxyARP applications..."
Thomas Vachuska61f0e0b2018-05-15 14:08:11 -070037onos $OC1 app activate org.onosproject.openflow proxyarp layout
Thomas Vachuskac419f0e2018-02-07 14:24:46 -080038onos $OC1
39