Adding artifacts for the tutorial VM.
Change-Id: I5aea02fe70ec012d7fcacebaa2f9b15b949b41b8
diff --git a/tools/tutorials/vm/cluster.json b/tools/tutorials/vm/cluster.json
new file mode 100644
index 0000000..59dc1b3
--- /dev/null
+++ b/tools/tutorials/vm/cluster.json
@@ -0,0 +1 @@
+{"name":"default","nodes":[{"id":"172.17.0.4","ip":"172.17.0.4","port":9876},{"id":"172.17.0.2","ip":"172.17.0.2","port":9876},{"id":"172.17.0.3","ip":"172.17.0.3","port":9876}],"partitions":[{"id":3,"members":["172.17.0.2","172.17.0.3","172.17.0.4"]},{"id":2,"members":["172.17.0.2","172.17.0.3","172.17.0.4"]},{"id":1,"members":["172.17.0.2","172.17.0.3","172.17.0.4"]}]}
diff --git a/tools/tutorials/vm/createCluster b/tools/tutorials/vm/createCluster
new file mode 100755
index 0000000..4f3c8f3
--- /dev/null
+++ b/tools/tutorials/vm/createCluster
@@ -0,0 +1,42 @@
+#!/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
+
diff --git a/tools/tutorials/vm/destroyCluster b/tools/tutorials/vm/destroyCluster
new file mode 100755
index 0000000..9bc3a74
--- /dev/null
+++ b/tools/tutorials/vm/destroyCluster
@@ -0,0 +1,15 @@
+#!/bin/bash
+# -----------------------------------------------------------------------------
+# Destroys the ONOS cluster by stopping the 3 docker containers.
+# -----------------------------------------------------------------------------
+
+# 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 "Destroying onos-$i..."
+ docker stop onos-$i
+done
+
+docker container prune --force
diff --git a/tools/tutorials/vm/exportVM b/tools/tutorials/vm/exportVM
new file mode 100755
index 0000000..48420c9
--- /dev/null
+++ b/tools/tutorials/vm/exportVM
@@ -0,0 +1,12 @@
+#!/bin/bash
+# -----------------------------------------------------------------------------
+# Exports the ONOS Tutorial VM into an OVA file for publishing.
+# -----------------------------------------------------------------------------
+
+export VER=1.12.0
+export OVA=/tmp/onos-tutorial-$VER.ova
+rm -f $OVA
+vboxmanage export "ONOS Tutorial" --output $OVA --manifest \
+ --vsys 0 --product "ONOS" --vendor "Open Networking Foundation" --version "$VER" \
+ --description "ONOS Basic Tutorial VM; 3 node cluster using docker; mininet topologies"
+wc -c $OVA
\ No newline at end of file
diff --git a/tools/tutorials/vm/prepForExport b/tools/tutorials/vm/prepForExport
new file mode 100755
index 0000000..fb944a7
--- /dev/null
+++ b/tools/tutorials/vm/prepForExport
@@ -0,0 +1,10 @@
+#!/bin/bash
+# -----------------------------------------------------------------------------
+# Prepars the ONOS Tutorial VM for export; run from the VM.
+# -----------------------------------------------------------------------------
+sudo chattr +i ~/.config/xfce4/desktop/icons*
+destroyCluster
+sudo mn -c
+sudo dd if=/dev/zero of=zerofillfile bs=1M
+rm -f zerofillfile /tmp/*
+sudo shutdown now
diff --git a/tools/tutorials/vm/uploadToS3 b/tools/tutorials/vm/uploadToS3
new file mode 100755
index 0000000..3a0e2cb
--- /dev/null
+++ b/tools/tutorials/vm/uploadToS3
@@ -0,0 +1,7 @@
+#!/bin/bash
+# -----------------------------------------------------------------------------
+# Publishes the ONOS Tutorial OVA file.
+# -----------------------------------------------------------------------------
+export VER=1.12.0
+export OVA=/tmp/onos-tutorial-$VER.ova
+uploadToS3.py $OVA --secret $AWS_SECRET_ACCESS_KEY --key $AWS_ACCESS_KEY_ID --bucket onos --dest vm/