blob: 4f3c8f3246d8a262a7b83b1a305bb71a6a94ad30 [file] [log] [blame]
#!/bin/bash
# -----------------------------------------------------------------------------
# Creates the ONOS cluster using 3 docker container instances.
# -----------------------------------------------------------------------------
export PATH="$PATH:bin:onos/bin"
# Creates ONOS cluster using ONOS docker images
ONOS_IMAGE=onosproject/onos:1.12.0
SSH_KEY=$(cut -d\ -f2 ~/.ssh/id_rsa.pub)
for i in {1..3}; do
echo "Setting up onos-$i..."
docker container run --detach --name onos-$i --hostname onos-$i --restart always $ONOS_IMAGE
docker exec -i onos-$i /bin/bash -c "mkdir config; cat > config/cluster.json" < $(dirname $0)/cluster.json
docker exec -it onos-$i bin/onos-user-key sdn $SSH_KEY >/dev/null 2>&1
docker exec -it onos-$i bin/onos-user-password onos rocks >/dev/null 2>&1
done
function waitForStart {
sleep 5
for i in {1..3}; do
echo "Waiting for onos-$i startup..."
ip=$(docker container inspect onos-$i | grep \"IPAddress | cut -d: -f2 | sort -u | tr -d '", ')
for t in {1..30}; do
curl --fail -sS http://$ip:8181/onos/v1/cluster --user onos:rocks 1>/dev/null 2>&1 && break;
sleep 1;
done
onos $ip summary >/dev/null 2>&1
done
}
OC1=$(docker container inspect onos-1 | grep \"IPAddress | cut -d: -f2 | sort -u | tr -d '", ')
OC2=$(docker container inspect onos-2 | grep \"IPAddress | cut -d: -f2 | sort -u | tr -d '", ')
OC3=$(docker container inspect onos-3 | grep \"IPAddress | cut -d: -f2 | sort -u | tr -d '", ')
ONOS_INSTANCES="$OC1 $OC2 $OC3"
waitForStart
echo "Activating OpenFlow and ProxyARP applications..."
onos $OC1 app activate openflow proxyarp
onos $OC1