Thomas Vachuska | c419f0e | 2018-02-07 14:24:46 -0800 | [diff] [blame] | 1 | #!/bin/bash |
Thomas Vachuska | c419f0e | 2018-02-07 14:24:46 -0800 | [diff] [blame] | 2 | export PATH="$PATH:bin:onos/bin" |
| 3 | |
Thomas Vachuska | c419f0e | 2018-02-07 14:24:46 -0800 | [diff] [blame] | 4 | SSH_KEY=$(cut -d\ -f2 ~/.ssh/id_rsa.pub) |
| 5 | |
Thomas Vachuska | e7013e9 | 2018-09-12 01:18:43 -0700 | [diff] [blame] | 6 | # Create Atomix cluster using Atomix docker image |
| 7 | ATOMIX_IMAGE=atomix/atomix:3.0.5 |
| 8 | for 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 |
| 13 | done |
| 14 | |
| 15 | # Create ONOS cluster using ONOS docker image |
| 16 | ONOS_IMAGE=onosproject/onos:1.14.0 |
Thomas Vachuska | c419f0e | 2018-02-07 14:24:46 -0800 | [diff] [blame] | 17 | for i in {1..3}; do |
| 18 | echo "Setting up onos-$i..." |
Thomas Vachuska | e7013e9 | 2018-09-12 01:18:43 -0700 | [diff] [blame] | 19 | 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 Vachuska | c419f0e | 2018-02-07 14:24:46 -0800 | [diff] [blame] | 21 | 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 |
| 23 | done |
| 24 | |
| 25 | function 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 Vachuska | 61f0e0b | 2018-05-15 14:08:11 -0700 | [diff] [blame] | 30 | 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 Vachuska | c419f0e | 2018-02-07 14:24:46 -0800 | [diff] [blame] | 32 | sleep 1; |
| 33 | done |
| 34 | onos $ip summary >/dev/null 2>&1 |
| 35 | done |
| 36 | } |
| 37 | |
Thomas Vachuska | e7013e9 | 2018-09-12 01:18:43 -0700 | [diff] [blame] | 38 | # Extract the IP addresses of the ONOS nodes |
Thomas Vachuska | c419f0e | 2018-02-07 14:24:46 -0800 | [diff] [blame] | 39 | OC1=$(docker container inspect onos-1 | grep \"IPAddress | cut -d: -f2 | sort -u | tr -d '", ') |
| 40 | OC2=$(docker container inspect onos-2 | grep \"IPAddress | cut -d: -f2 | sort -u | tr -d '", ') |
| 41 | OC3=$(docker container inspect onos-3 | grep \"IPAddress | cut -d: -f2 | sort -u | tr -d '", ') |
| 42 | ONOS_INSTANCES="$OC1 $OC2 $OC3" |
| 43 | |
| 44 | waitForStart |
| 45 | |
| 46 | echo "Activating OpenFlow and ProxyARP applications..." |
Thomas Vachuska | 61f0e0b | 2018-05-15 14:08:11 -0700 | [diff] [blame] | 47 | onos $OC1 app activate org.onosproject.openflow proxyarp layout |
Thomas Vachuska | c419f0e | 2018-02-07 14:24:46 -0800 | [diff] [blame] | 48 | onos $OC1 |
| 49 | |