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 | |
| 4 | # Creates ONOS cluster using ONOS docker images |
Thomas Vachuska | 61f0e0b | 2018-05-15 14:08:11 -0700 | [diff] [blame^] | 5 | ONOS_IMAGE=onosproject/onos:1.13.1 |
Thomas Vachuska | c419f0e | 2018-02-07 14:24:46 -0800 | [diff] [blame] | 6 | SSH_KEY=$(cut -d\ -f2 ~/.ssh/id_rsa.pub) |
| 7 | |
| 8 | for 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 |
| 14 | done |
| 15 | |
| 16 | function 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 Vachuska | 61f0e0b | 2018-05-15 14:08:11 -0700 | [diff] [blame^] | 21 | 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 Vachuska | c419f0e | 2018-02-07 14:24:46 -0800 | [diff] [blame] | 23 | sleep 1; |
| 24 | done |
| 25 | onos $ip summary >/dev/null 2>&1 |
| 26 | done |
| 27 | } |
| 28 | |
| 29 | OC1=$(docker container inspect onos-1 | grep \"IPAddress | cut -d: -f2 | sort -u | tr -d '", ') |
| 30 | OC2=$(docker container inspect onos-2 | grep \"IPAddress | cut -d: -f2 | sort -u | tr -d '", ') |
| 31 | OC3=$(docker container inspect onos-3 | grep \"IPAddress | cut -d: -f2 | sort -u | tr -d '", ') |
| 32 | ONOS_INSTANCES="$OC1 $OC2 $OC3" |
| 33 | |
| 34 | waitForStart |
| 35 | |
| 36 | echo "Activating OpenFlow and ProxyARP applications..." |
Thomas Vachuska | 61f0e0b | 2018-05-15 14:08:11 -0700 | [diff] [blame^] | 37 | onos $OC1 app activate org.onosproject.openflow proxyarp layout |
Thomas Vachuska | c419f0e | 2018-02-07 14:24:46 -0800 | [diff] [blame] | 38 | onos $OC1 |
| 39 | |