initial commit

Change-Id: I5063800f2ddaf90a350325a9186479c25f90f8e1
diff --git a/roles/onos-fabric/files/bin/minify b/roles/onos-fabric/files/bin/minify
new file mode 100755
index 0000000..b91023c
--- /dev/null
+++ b/roles/onos-fabric/files/bin/minify
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+PROG=$(basename $0)
+
+usage() {
+    echo "$PROG: [options]"
+    echo ""
+    echo "    -h | --help       display this message"
+}
+
+FILE=
+while [ $# -gt 0 ]; do
+    case $1 in
+        -h|--help)
+            usage
+            exit
+            ;;
+        *)
+            FILE=$1
+            ;;
+    esac
+    shift
+done
+
+if [ "$FILE x" == " x" ]; then
+    sed -e 's|//.*$||g' -e '/^\s*$/d' # <&0
+else
+    cat $FILE | sed -e 's|//.*$||g' -e '/^\s*$/d'
+fi
diff --git a/roles/onos-fabric/files/bin/onos-cfg-delete b/roles/onos-fabric/files/bin/onos-cfg-delete
new file mode 100755
index 0000000..4404b5c
--- /dev/null
+++ b/roles/onos-fabric/files/bin/onos-cfg-delete
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+curl -slL -X DELETE --header "Accept: application/json" "http://karaf:karaf@localhost:8181/onos/v1/network/configuration" $*
+
diff --git a/roles/onos-fabric/files/bin/onos-cfg-get b/roles/onos-fabric/files/bin/onos-cfg-get
new file mode 100755
index 0000000..8d0cabf
--- /dev/null
+++ b/roles/onos-fabric/files/bin/onos-cfg-get
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+curl -sLl -X GET --header "Accept: application/json" "http://karaf:karaf@localhost:8181/onos/v1/network/configuration" | python -m json.tool
+
diff --git a/roles/onos-fabric/files/bin/onos-cfg-post b/roles/onos-fabric/files/bin/onos-cfg-post
new file mode 100755
index 0000000..328b8b0
--- /dev/null
+++ b/roles/onos-fabric/files/bin/onos-cfg-post
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+cat $1 | sed -e 's|//.*$||g' -e '/^\s*$/d' | curl -slL -X POST --header "Content-Type: application/json" --header "Accept: application/json" -d "@-" "http://karaf:karaf@localhost:8181/onos/v1/network/configuration"
diff --git a/roles/onos-fabric/files/bin/ping-test.sh b/roles/onos-fabric/files/bin/ping-test.sh
new file mode 100755
index 0000000..d7b894e
--- /dev/null
+++ b/roles/onos-fabric/files/bin/ping-test.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+HOSTS="10.3.1.1 10.3.1.2 10.3.2.1 10.3.2.2 10.3.1.254 10.3.2.254 192.168.10.1 8.8.8.8"
+
+ME=$(ifconfig | grep "10\.3\.[0-9]\.[0-9]" | sed -e 's/.*addr:\(10\.3\.[0-9]\.[0-9]\).*/\1/g' 2> /dev/null) 
+echo "FROM: $ME"
+for TO in $HOSTS; do
+    T=$(ping -q -c 1 -W 1 -I eth0 $TO | grep rtt | awk '{print $4}' | sed -e 's|/| |g') #sed -e 's|r| |')
+    echo  "$TO: $T" | awk '{printf("    %-15s %-7s\n", $1, $2, $3, $4)}'
+done
diff --git a/roles/onos-fabric/files/bin/restart-vms.sh b/roles/onos-fabric/files/bin/restart-vms.sh
new file mode 100755
index 0000000..ef14e5f
--- /dev/null
+++ b/roles/onos-fabric/files/bin/restart-vms.sh
@@ -0,0 +1,39 @@
+#!/bin/bash
+
+function verify {
+    local L=$1
+    for i in $L; do
+        grep $i /etc/bind/maas/dhcp_harvest.inc > /dev/null 2>&1
+        if [ $? -ne 0 ]; then
+            echo "0"
+            return
+        fi
+    done
+    echo "1"
+}
+
+for i in $(uvt-kvm list); do
+    virsh start $i
+done
+
+LIST=$(uvt-kvm list)
+CNT=$(uvt-kvm list | wc -l)
+# plus 4 for the switches
+
+RETRY=5
+VERIFIED=0
+while [ $VERIFIED -ne 1 -a $RETRY -gt 0 ]; do
+    echo "INFO: Waiting for VMs to start"
+    sleep 5
+    curl -slL -XPOST http://127.0.0.1:8954/harvest >> /dev/null
+    VERIFIED=$(verify $LIST)
+    RETRY=$(expr $RETRY - 1)
+    echo "INFO: Verifing all VMs started"
+done
+
+if [ $VERIFIED -ne 1 ]; then
+    echo "ERROR: Likely VMs did not all boot correctly"
+    exit 1
+else
+    echo "INFO: Looks like all VM started correctly"
+fi