Changed folders composition. No file is deleted.

  - Created "old-scripts" folder to store obsolete files.
  - Created "sample" folder to store scripts about demo GUI.
  - Added start-ons2014demo.sh to start ONS 2014 demo GUI.
  - Modified web/* and sample/ONS2014demo/* scripts to adapt new composition.
  NOTE: No adaptation to current REST API. Those GUI won't work until adapted.

Change-Id: I98bdd7d45f0a43731bd0264c9815a0e46e06c097
diff --git a/demo-scripts/Sprint-4/cleanup.sh b/old-scripts/Sprint-4/cleanup.sh
similarity index 100%
rename from demo-scripts/Sprint-4/cleanup.sh
rename to old-scripts/Sprint-4/cleanup.sh
diff --git a/demo-scripts/Sprint-4/demo-prep.sh b/old-scripts/Sprint-4/demo-prep.sh
similarity index 100%
rename from demo-scripts/Sprint-4/demo-prep.sh
rename to old-scripts/Sprint-4/demo-prep.sh
diff --git a/demo-scripts/Sprint-4/demo.sh b/old-scripts/Sprint-4/demo.sh
similarity index 100%
rename from demo-scripts/Sprint-4/demo.sh
rename to old-scripts/Sprint-4/demo.sh
diff --git a/demo-scripts/Sprint-4/network-change.sh b/old-scripts/Sprint-4/network-change.sh
similarity index 100%
rename from demo-scripts/Sprint-4/network-change.sh
rename to old-scripts/Sprint-4/network-change.sh
diff --git a/demo-scripts/Sprint-4/start-cassandra.sh b/old-scripts/Sprint-4/start-cassandra.sh
similarity index 100%
rename from demo-scripts/Sprint-4/start-cassandra.sh
rename to old-scripts/Sprint-4/start-cassandra.sh
diff --git a/demo-scripts/Sprint-4/start-onos.sh b/old-scripts/Sprint-4/start-onos.sh
similarity index 100%
rename from demo-scripts/Sprint-4/start-onos.sh
rename to old-scripts/Sprint-4/start-onos.sh
diff --git a/demo-scripts/Sprint-4/update.sh b/old-scripts/Sprint-4/update.sh
similarity index 100%
rename from demo-scripts/Sprint-4/update.sh
rename to old-scripts/Sprint-4/update.sh
diff --git a/scripts/all-linkup.sh b/old-scripts/scripts/all-linkup.sh
similarity index 100%
rename from scripts/all-linkup.sh
rename to old-scripts/scripts/all-linkup.sh
diff --git a/scripts/ctrl-add-ext.sh b/old-scripts/scripts/ctrl-add-ext.sh
similarity index 100%
rename from scripts/ctrl-add-ext.sh
rename to old-scripts/scripts/ctrl-add-ext.sh
diff --git a/scripts/ctrl-local.sh b/old-scripts/scripts/ctrl-local.sh
similarity index 100%
rename from scripts/ctrl-local.sh
rename to old-scripts/scripts/ctrl-local.sh
diff --git a/scripts/ctrl-none.sh b/old-scripts/scripts/ctrl-none.sh
similarity index 100%
rename from scripts/ctrl-none.sh
rename to old-scripts/scripts/ctrl-none.sh
diff --git a/scripts/ctrl-one.sh b/old-scripts/scripts/ctrl-one.sh
similarity index 100%
rename from scripts/ctrl-one.sh
rename to old-scripts/scripts/ctrl-one.sh
diff --git a/scripts/ctrl-sw.sh b/old-scripts/scripts/ctrl-sw.sh
similarity index 100%
rename from scripts/ctrl-sw.sh
rename to old-scripts/scripts/ctrl-sw.sh
diff --git a/scripts/listports.sh b/old-scripts/scripts/listports.sh
similarity index 100%
rename from scripts/listports.sh
rename to old-scripts/scripts/listports.sh
diff --git a/scripts/onos-nodetool.py b/old-scripts/scripts/onos-nodetool.py
similarity index 100%
rename from scripts/onos-nodetool.py
rename to old-scripts/scripts/onos-nodetool.py
diff --git a/scripts/showflow.sh b/old-scripts/scripts/showflow.sh
similarity index 100%
rename from scripts/showflow.sh
rename to old-scripts/scripts/showflow.sh
diff --git a/test-network/flows/generate_flows_domains_8.py b/old-scripts/test-network/flows/generate_flows_domains_8.py
similarity index 100%
rename from test-network/flows/generate_flows_domains_8.py
rename to old-scripts/test-network/flows/generate_flows_domains_8.py
diff --git a/test-network/flows/test1_ons_flows_966.txt b/old-scripts/test-network/flows/test1_ons_flows_966.txt
similarity index 100%
rename from test-network/flows/test1_ons_flows_966.txt
rename to old-scripts/test-network/flows/test1_ons_flows_966.txt
diff --git a/test-network/flows/test2_ons_flows_126.txt b/old-scripts/test-network/flows/test2_ons_flows_126.txt
similarity index 100%
rename from test-network/flows/test2_ons_flows_126.txt
rename to old-scripts/test-network/flows/test2_ons_flows_126.txt
diff --git a/test-network/mininet/capsulator b/old-scripts/test-network/mininet/capsulator
similarity index 100%
rename from test-network/mininet/capsulator
rename to old-scripts/test-network/mininet/capsulator
Binary files differ
diff --git a/test-network/mininet/dev_network.py b/old-scripts/test-network/mininet/dev_network.py
similarity index 100%
rename from test-network/mininet/dev_network.py
rename to old-scripts/test-network/mininet/dev_network.py
diff --git a/test-network/mininet/dev_network_core.py b/old-scripts/test-network/mininet/dev_network_core.py
similarity index 100%
rename from test-network/mininet/dev_network_core.py
rename to old-scripts/test-network/mininet/dev_network_core.py
diff --git a/test-network/mininet/dev_network_core_1.py b/old-scripts/test-network/mininet/dev_network_core_1.py
similarity index 100%
rename from test-network/mininet/dev_network_core_1.py
rename to old-scripts/test-network/mininet/dev_network_core_1.py
diff --git a/test-network/mininet/dev_network_edge.py b/old-scripts/test-network/mininet/dev_network_edge.py
similarity index 100%
rename from test-network/mininet/dev_network_edge.py
rename to old-scripts/test-network/mininet/dev_network_edge.py
diff --git a/test-network/mininet/dev_network_edge_2.py b/old-scripts/test-network/mininet/dev_network_edge_2.py
similarity index 100%
rename from test-network/mininet/dev_network_edge_2.py
rename to old-scripts/test-network/mininet/dev_network_edge_2.py
diff --git a/test-network/mininet/dev_network_single.py b/old-scripts/test-network/mininet/dev_network_single.py
similarity index 100%
rename from test-network/mininet/dev_network_single.py
rename to old-scripts/test-network/mininet/dev_network_single.py
diff --git a/test-network/mininet/dev_network_tunnel_1.sh b/old-scripts/test-network/mininet/dev_network_tunnel_1.sh
similarity index 100%
rename from test-network/mininet/dev_network_tunnel_1.sh
rename to old-scripts/test-network/mininet/dev_network_tunnel_1.sh
diff --git a/test-network/mininet/dev_network_tunnel_2.sh b/old-scripts/test-network/mininet/dev_network_tunnel_2.sh
similarity index 100%
rename from test-network/mininet/dev_network_tunnel_2.sh
rename to old-scripts/test-network/mininet/dev_network_tunnel_2.sh
diff --git a/test-network/mininet/dev_network_tunnel_3.sh b/old-scripts/test-network/mininet/dev_network_tunnel_3.sh
similarity index 100%
rename from test-network/mininet/dev_network_tunnel_3.sh
rename to old-scripts/test-network/mininet/dev_network_tunnel_3.sh
diff --git a/test-network/mininet/dev_network_tunnel_4.sh b/old-scripts/test-network/mininet/dev_network_tunnel_4.sh
similarity index 100%
rename from test-network/mininet/dev_network_tunnel_4.sh
rename to old-scripts/test-network/mininet/dev_network_tunnel_4.sh
diff --git a/test-network/mininet/fat_tree.py b/old-scripts/test-network/mininet/fat_tree.py
similarity index 100%
rename from test-network/mininet/fat_tree.py
rename to old-scripts/test-network/mininet/fat_tree.py
diff --git a/test-network/mininet/ft.template.sprint4.py b/old-scripts/test-network/mininet/ft.template.sprint4.py
similarity index 100%
rename from test-network/mininet/ft.template.sprint4.py
rename to old-scripts/test-network/mininet/ft.template.sprint4.py
diff --git a/test-network/mininet/mesh_topology.py b/old-scripts/test-network/mininet/mesh_topology.py
similarity index 100%
rename from test-network/mininet/mesh_topology.py
rename to old-scripts/test-network/mininet/mesh_topology.py
diff --git a/test-network/mininet/mrun b/old-scripts/test-network/mininet/mrun
similarity index 100%
rename from test-network/mininet/mrun
rename to old-scripts/test-network/mininet/mrun
diff --git a/test-network/mininet/net.sprint5-templete.py b/old-scripts/test-network/mininet/net.sprint5-templete.py
similarity index 100%
rename from test-network/mininet/net.sprint5-templete.py
rename to old-scripts/test-network/mininet/net.sprint5-templete.py
diff --git a/test-network/mininet/net.sprint5.template.py b/old-scripts/test-network/mininet/net.sprint5.template.py
similarity index 100%
rename from test-network/mininet/net.sprint5.template.py
rename to old-scripts/test-network/mininet/net.sprint5.template.py
diff --git a/test-network/mininet/network.py b/old-scripts/test-network/mininet/network.py
similarity index 100%
rename from test-network/mininet/network.py
rename to old-scripts/test-network/mininet/network.py
diff --git a/test-network/mininet/onos-nw.template.py b/old-scripts/test-network/mininet/onos-nw.template.py
similarity index 100%
rename from test-network/mininet/onos-nw.template.py
rename to old-scripts/test-network/mininet/onos-nw.template.py
diff --git a/test-network/mininet/tunnel.template.sh b/old-scripts/test-network/mininet/tunnel.template.sh
similarity index 100%
rename from test-network/mininet/tunnel.template.sh
rename to old-scripts/test-network/mininet/tunnel.template.sh
diff --git a/testbed-ctrl-add-ext.sh b/old-scripts/testbed-ctrl-add-ext.sh
similarity index 100%
rename from testbed-ctrl-add-ext.sh
rename to old-scripts/testbed-ctrl-add-ext.sh
diff --git a/testbed-ctrl-none.sh b/old-scripts/testbed-ctrl-none.sh
similarity index 100%
rename from testbed-ctrl-none.sh
rename to old-scripts/testbed-ctrl-none.sh
diff --git a/web/README b/old-scripts/web/README
similarity index 100%
rename from web/README
rename to old-scripts/web/README
diff --git a/web/e2eflow.sh b/old-scripts/web/e2eflow.sh
similarity index 100%
rename from web/e2eflow.sh
rename to old-scripts/web/e2eflow.sh
diff --git a/web/flowdef_4node_144.txt b/old-scripts/web/flowdef_4node_144.txt
similarity index 100%
rename from web/flowdef_4node_144.txt
rename to old-scripts/web/flowdef_4node_144.txt
diff --git a/web/flowdef_4node_48.txt b/old-scripts/web/flowdef_4node_48.txt
similarity index 100%
rename from web/flowdef_4node_48.txt
rename to old-scripts/web/flowdef_4node_48.txt
diff --git a/web/flowdef_8node_1008.txt b/old-scripts/web/flowdef_8node_1008.txt
similarity index 100%
rename from web/flowdef_8node_1008.txt
rename to old-scripts/web/flowdef_8node_1008.txt
diff --git a/web/flowdef_8node_126.txt b/old-scripts/web/flowdef_8node_126.txt
similarity index 100%
rename from web/flowdef_8node_126.txt
rename to old-scripts/web/flowdef_8node_126.txt
diff --git a/web/flowdef_8node_252.txt b/old-scripts/web/flowdef_8node_252.txt
similarity index 100%
rename from web/flowdef_8node_252.txt
rename to old-scripts/web/flowdef_8node_252.txt
diff --git a/web/flowdef_8node_42.txt b/old-scripts/web/flowdef_8node_42.txt
similarity index 100%
rename from web/flowdef_8node_42.txt
rename to old-scripts/web/flowdef_8node_42.txt
diff --git a/web/flowdef_8node_420.txt b/old-scripts/web/flowdef_8node_420.txt
similarity index 100%
rename from web/flowdef_8node_420.txt
rename to old-scripts/web/flowdef_8node_420.txt
diff --git a/web/flowsync.py b/old-scripts/web/flowsync.py
similarity index 100%
rename from web/flowsync.py
rename to old-scripts/web/flowsync.py
diff --git a/web/get_datagrid.py b/old-scripts/web/get_datagrid.py
similarity index 100%
rename from web/get_datagrid.py
rename to old-scripts/web/get_datagrid.py
diff --git a/web/pingall.py b/old-scripts/web/pingall.py
similarity index 100%
rename from web/pingall.py
rename to old-scripts/web/pingall.py
diff --git a/web/pingallm-local.py b/old-scripts/web/pingallm-local.py
similarity index 100%
rename from web/pingallm-local.py
rename to old-scripts/web/pingallm-local.py
diff --git a/web/pingallm.py b/old-scripts/web/pingallm.py
similarity index 100%
rename from web/pingallm.py
rename to old-scripts/web/pingallm.py
diff --git a/web/preset_flow.py b/old-scripts/web/preset_flow.py
similarity index 100%
rename from web/preset_flow.py
rename to old-scripts/web/preset_flow.py
diff --git a/web/preset_flow.sh b/old-scripts/web/preset_flow.sh
similarity index 100%
rename from web/preset_flow.sh
rename to old-scripts/web/preset_flow.sh
diff --git a/web/pusher.py b/old-scripts/web/pusher.py
similarity index 100%
rename from web/pusher.py
rename to old-scripts/web/pusher.py
diff --git a/web/restapi.py b/old-scripts/web/restapi.py
similarity index 100%
rename from web/restapi.py
rename to old-scripts/web/restapi.py
diff --git a/web/restapi2.py b/old-scripts/web/restapi2.py
similarity index 100%
rename from web/restapi2.py
rename to old-scripts/web/restapi2.py
diff --git a/web/restapi3.py b/old-scripts/web/restapi3.py
similarity index 100%
rename from web/restapi3.py
rename to old-scripts/web/restapi3.py
diff --git a/scripts/all-linkup-hw.sh b/sample/ONS2014demo/scripts/all-linkup-hw.sh
similarity index 100%
rename from scripts/all-linkup-hw.sh
rename to sample/ONS2014demo/scripts/all-linkup-hw.sh
diff --git a/scripts/check-cluster-hw.sh b/sample/ONS2014demo/scripts/check-cluster-hw.sh
similarity index 100%
rename from scripts/check-cluster-hw.sh
rename to sample/ONS2014demo/scripts/check-cluster-hw.sh
diff --git a/web/config.json.dev.1node b/sample/ONS2014demo/scripts/config.json.dev.1node
similarity index 100%
rename from web/config.json.dev.1node
rename to sample/ONS2014demo/scripts/config.json.dev.1node
diff --git a/web/config.json.devA b/sample/ONS2014demo/scripts/config.json.devA
similarity index 100%
rename from web/config.json.devA
rename to sample/ONS2014demo/scripts/config.json.devA
diff --git a/web/config.json.hw b/sample/ONS2014demo/scripts/config.json.hw
similarity index 100%
rename from web/config.json.hw
rename to sample/ONS2014demo/scripts/config.json.hw
diff --git a/web/config.json.sw b/sample/ONS2014demo/scripts/config.json.sw
similarity index 100%
rename from web/config.json.sw
rename to sample/ONS2014demo/scripts/config.json.sw
diff --git a/web/config.json.sw_dev b/sample/ONS2014demo/scripts/config.json.sw_dev
similarity index 100%
rename from web/config.json.sw_dev
rename to sample/ONS2014demo/scripts/config.json.sw_dev
diff --git a/scripts/ctrl-add-ext.sh b/sample/ONS2014demo/scripts/ctrl-add-ext.sh
similarity index 100%
copy from scripts/ctrl-add-ext.sh
copy to sample/ONS2014demo/scripts/ctrl-add-ext.sh
diff --git a/scripts/ctrl-local.sh b/sample/ONS2014demo/scripts/ctrl-local.sh
similarity index 100%
copy from scripts/ctrl-local.sh
copy to sample/ONS2014demo/scripts/ctrl-local.sh
diff --git a/scripts/ctrl-none.sh b/sample/ONS2014demo/scripts/ctrl-none.sh
similarity index 100%
copy from scripts/ctrl-none.sh
copy to sample/ONS2014demo/scripts/ctrl-none.sh
diff --git a/scripts/ctrl-one.sh b/sample/ONS2014demo/scripts/ctrl-one.sh
similarity index 100%
copy from scripts/ctrl-one.sh
copy to sample/ONS2014demo/scripts/ctrl-one.sh
diff --git a/scripts/ctrl-sw.sh b/sample/ONS2014demo/scripts/ctrl-sw.sh
similarity index 100%
copy from scripts/ctrl-sw.sh
copy to sample/ONS2014demo/scripts/ctrl-sw.sh
diff --git a/scripts/delflow.sh b/sample/ONS2014demo/scripts/delflow.sh
similarity index 100%
rename from scripts/delflow.sh
rename to sample/ONS2014demo/scripts/delflow.sh
diff --git a/scripts/demo-reset-sw.sh b/sample/ONS2014demo/scripts/demo-reset-sw.sh
similarity index 100%
rename from scripts/demo-reset-sw.sh
rename to sample/ONS2014demo/scripts/demo-reset-sw.sh
diff --git a/scripts/demo-scale-out-sw.sh b/sample/ONS2014demo/scripts/demo-scale-out-sw.sh
similarity index 100%
rename from scripts/demo-scale-out-sw.sh
rename to sample/ONS2014demo/scripts/demo-scale-out-sw.sh
diff --git a/scripts/iperf b/sample/ONS2014demo/scripts/iperf
similarity index 100%
rename from scripts/iperf
rename to sample/ONS2014demo/scripts/iperf
Binary files differ
diff --git a/scripts/link-hw.sh b/sample/ONS2014demo/scripts/link-hw.sh
similarity index 75%
rename from scripts/link-hw.sh
rename to sample/ONS2014demo/scripts/link-hw.sh
index 129da36..e6f2487 100755
--- a/scripts/link-hw.sh
+++ b/sample/ONS2014demo/scripts/link-hw.sh
@@ -1,5 +1,7 @@
 #! /bin/bash
 
+SCRIPT_DIR=$(cd `dirname $0`; pwd)
+
 #controller=`hostname`
 switches=`ifconfig -a | grep sw |grep -v eth | awk '{print $1}'`
 
@@ -20,42 +22,42 @@
 
 if [  "x00:00:00:00:ba:5e:ba:11" == "x$1" ]; then
         if [ x$cmd == "xup" ]; then
-                ~/ONOS/scripts/prontolink.exp 10.128.0.61 $src_port 1  
+                ${SCRIPT_DIR}/prontolink.exp 10.128.0.61 $src_port 1  
         elif [ x$cmd == "xdown" ]; then
-                ~/ONOS/scripts/prontolink.exp 10.128.0.61 $src_port 0 
+                ${SCRIPT_DIR}/prontolink.exp 10.128.0.61 $src_port 0 
         else
 		echo "no cmd"
         fi
 elif [  "x00:00:00:00:00:00:ba:12" == "x$1" ]; then
         if [ x$cmd == "xup" ]; then
-                ~/ONOS/scripts/prontolink.exp 10.128.0.62 $src_port 1  
+                ${SCRIPT_DIR}/prontolink.exp 10.128.0.62 $src_port 1  
         elif [ x$cmd == "xdown" ]; then
-                ~/ONOS/scripts/prontolink.exp 10.128.0.62 $src_port 0 
+                ${SCRIPT_DIR}/prontolink.exp 10.128.0.62 $src_port 0 
         else
 		echo "no cmd"
         fi
 elif [  "x00:00:00:00:ba:5e:ba:13" == "x$1" ]; then
         if [ x$cmd == "xup" ]; then
-                ~/ONOS/scripts/prontolink.exp 10.128.0.63 $src_port 1 
+                ${SCRIPT_DIR}/prontolink.exp 10.128.0.63 $src_port 1 
         elif [ x$cmd == "xdown" ]; then
-                ~/ONOS/scripts/prontolink.exp 10.128.0.63 $src_port 0 
+                ${SCRIPT_DIR}/prontolink.exp 10.128.0.63 $src_port 0 
         else
 		echo "no cmd"
         fi
 elif [  "x00:00:20:4e:7f:51:8a:35" == "x$1" ]; then
         if [ x$cmd == "xup" ]; then
-                ~/ONOS/scripts/prontolink.exp 10.128.0.50 $src_port 1 
+                ${SCRIPT_DIR}/prontolink.exp 10.128.0.50 $src_port 1 
         elif [ x$cmd == "xdown" ]; then
-                ~/ONOS/scripts/prontolink.exp 10.128.0.50 $src_port 0 
+                ${SCRIPT_DIR}/prontolink.exp 10.128.0.50 $src_port 0 
         else
 		echo "no cmd"
         fi
 
 elif [  "x00:01:00:16:97:08:9a:46" == "x$1" ]; then
         if [ x$cmd == "xup" ]; then
-                ~/ONOS/scripts/neclink.exp $src_port no
+                ${SCRIPT_DIR}/neclink.exp $src_port no
         elif [ x$cmd == "xdown" ]; then
-                ~/ONOS/scripts/neclink.exp $src_port 
+                ${SCRIPT_DIR}/neclink.exp $src_port 
         else
 		echo "no cmd"
         fi
diff --git a/scripts/link.sh b/sample/ONS2014demo/scripts/link.sh
similarity index 100%
rename from scripts/link.sh
rename to sample/ONS2014demo/scripts/link.sh
diff --git a/scripts/localssh.sh b/sample/ONS2014demo/scripts/localssh.sh
similarity index 100%
rename from scripts/localssh.sh
rename to sample/ONS2014demo/scripts/localssh.sh
diff --git a/scripts/neclink.exp b/sample/ONS2014demo/scripts/neclink.exp
similarity index 100%
rename from scripts/neclink.exp
rename to sample/ONS2014demo/scripts/neclink.exp
diff --git a/scripts/prontolink.exp b/sample/ONS2014demo/scripts/prontolink.exp
similarity index 100%
rename from scripts/prontolink.exp
rename to sample/ONS2014demo/scripts/prontolink.exp
diff --git a/scripts/runiperf.sh b/sample/ONS2014demo/scripts/runiperf.sh
similarity index 100%
rename from scripts/runiperf.sh
rename to sample/ONS2014demo/scripts/runiperf.sh
diff --git a/scripts/showdpid.sh b/sample/ONS2014demo/scripts/showdpid.sh
similarity index 100%
rename from scripts/showdpid.sh
rename to sample/ONS2014demo/scripts/showdpid.sh
diff --git a/scripts/switch.sh b/sample/ONS2014demo/scripts/switch.sh
similarity index 100%
rename from scripts/switch.sh
rename to sample/ONS2014demo/scripts/switch.sh
diff --git a/scripts/template/ctrl-add-ext-template.sh b/sample/ONS2014demo/scripts/template/ctrl-add-ext-template.sh
similarity index 100%
rename from scripts/template/ctrl-add-ext-template.sh
rename to sample/ONS2014demo/scripts/template/ctrl-add-ext-template.sh
diff --git a/sample/ONS2014demo/scripts/topology_rest.py b/sample/ONS2014demo/scripts/topology_rest.py
new file mode 100755
index 0000000..9871057
--- /dev/null
+++ b/sample/ONS2014demo/scripts/topology_rest.py
@@ -0,0 +1,1003 @@
+#! /usr/bin/env python
+import pprint
+import os
+import sys
+import subprocess
+import json
+import argparse
+import io
+import time
+import random
+import re
+from urllib2 import Request, urlopen, URLError, HTTPError
+
+from flask import Flask, json, Response, render_template, make_response, request
+
+# paths for local access
+ONOS_DIR = os.getenv("HOME") + "/ONOS"
+ONOS_SCRIPTS_DIR = ONOS_DIR + "/scripts"
+ONS2014_DEMO_SCRIPTS_DIR = ONOS_DIR + "/sample/ONS2014demo/scripts"
+ONS2014_DEMO_WEB_DIR = ONOS_DIR + "/sample/ONS2014demo/web"
+LINK_FILE = ONS2014_DEMO_SCRIPTS_DIR + "/link.json"
+CONFIG_FILE = ONS2014_DEMO_SCRIPTS_DIR + "/config.json"
+
+# paths for remote access
+REMOTE_DEMO_SCRIPTS_DIR = "ONOS/sample/ONS2014demo/scripts"
+
+## Global Var for this proxy script setting.
+# "0.0.0.0" means any interface
+ProxyIP="0.0.0.0"
+ProxyPort=9000
+
+## Global Var for ON.Lab local REST ##
+RestIP="localhost"
+RestPort=8080
+ONOS_DEFAULT_HOST="localhost" ;# Has to set if LB=False
+DEBUG=1
+
+pp = pprint.PrettyPrinter(indent=4)
+app = Flask(__name__)
+
+def read_config():
+  global LB, TESTBED, controllers, core_switches, ONOS_GUI3_HOST, ONOS_GUI3_CONTROL_HOST
+  f = open(CONFIG_FILE)
+  conf = json.load(f)
+  LB = conf['LB']
+  TESTBED = conf['TESTBED']
+  controllers = conf['controllers']
+  core_switches=conf['core_switches']
+  ONOS_GUI3_HOST=conf['ONOS_GUI3_HOST']
+  ONOS_GUI3_CONTROL_HOST=conf['ONOS_GUI3_CONTROL_HOST']
+  f.close()
+
+def read_link_def():
+  global link_def
+  f=open(LINK_FILE)
+  try:
+    link_def=json.load(f)
+    f.close()
+  except:
+    print "Can't read link def file (link.json)"
+    sys.exit(1)
+
+def get_link_ports(src_dpid, dst_dpid):
+  ret = (-1, -1)
+  for link in link_def:
+    if link['src-switch'] == src_dpid and link['dst-switch'] == dst_dpid:
+        ret = (link['src-port'], link['dst-port'])
+        break
+  return ret
+
+## Worker Functions ##
+def log_error(txt):
+  print '%s' % (txt)
+
+def debug(txt):
+  if DEBUG:
+    print '%s' % (txt)
+
+### File Fetch ###
+@app.route('/', methods=['GET'])
+@app.route('/<filename>', methods=['GET'])
+@app.route('/js/<filename>', methods=['GET'])
+@app.route('/d3/<filename>', methods=['GET'])
+@app.route('/css/<filename>', methods=['GET'])
+@app.route('/assets/<filename>', methods=['GET'])
+@app.route('/data/<filename>', methods=['GET'])
+def return_file(filename="index.html"):
+  if request.path == "/":
+    fullpath = ONS2014_DEMO_WEB_DIR + "/index.html"
+  else:
+    fullpath = ONS2014_DEMO_WEB_DIR + "/" + str(request.path)[1:]
+
+  try:
+    open(fullpath)
+  except:
+    response = make_response("Cannot find a file: %s" % (fullpath), 500)
+    response.headers["Content-type"] = "text/html"
+    return response
+
+  response = make_response(open(fullpath).read())
+  suffix = fullpath.split(".")[-1]
+
+  if suffix == "html" or suffix == "htm":
+    response.headers["Content-type"] = "text/html"
+  elif suffix == "js":
+    response.headers["Content-type"] = "application/javascript"
+  elif suffix == "css":
+    response.headers["Content-type"] = "text/css"
+  elif suffix == "png":
+    response.headers["Content-type"] = "image/png"
+  elif suffix == "svg":
+    response.headers["Content-type"] = "image/svg+xml"
+
+  return response
+
+## Proxy ##
+@app.route("/proxy/gui/link/<cmd>/<src_dpid>/<src_port>/<dst_dpid>/<dst_port>")
+def proxy_link_change(cmd, src_dpid, src_port, dst_dpid, dst_port):
+  url = "%s/gui/link/%s/%s/%s/%s/%s" % (ONOS_GUI3_CONTROL_HOST, cmd, src_dpid, src_port, dst_dpid, dst_port)
+  try:
+    response = urlopen(url)
+    result = response.read()
+  except:
+    result = ""
+    print "REST IF has issue %s" % url
+
+  resp = Response(result, status=200, mimetype='application/json')
+  return resp
+
+@app.route("/proxy/gui/switchctrl/<cmd>")
+def proxy_switch_controller_setting(cmd):
+  url = "%s/gui/switchctrl/%s" % (ONOS_GUI3_CONTROL_HOST, cmd)
+  try:
+    response = urlopen(url)
+    result = response.read()
+  except:
+    result = ""
+    print "REST IF has issue %s" % url
+
+  resp = Response(result, status=200, mimetype='application/json')
+  return resp
+
+@app.route("/proxy/gui/switch/<cmd>/<dpid>")
+def proxy_switch_status_change(cmd, dpid):
+  url = "%s/gui/switch/%s/%s" % (ONOS_GUI3_CONTROL_HOST, cmd, dpid)
+  try:
+    response = urlopen(url)
+    result = response.read()
+  except:
+    result = ""
+    print "REST IF has issue %s" % url
+
+  resp = Response(result, status=200, mimetype='application/json')
+  return resp
+
+@app.route("/proxy/gui/controller/<cmd>/<controller_name>")
+def proxy_controller_status_change(cmd, controller_name):
+  url = "%s/gui/controller/%s/%s" % (ONOS_GUI3_CONTROL_HOST, cmd, controller_name)
+  try:
+    response = urlopen(url)
+    result = response.read()
+  except:
+    result = ""
+    print "REST IF has issue %s" % url
+ 
+  resp = Response(result, status=200, mimetype='application/json')
+  return resp
+
+@app.route("/proxy/gui/addflow/<src_dpid>/<src_port>/<dst_dpid>/<dst_port>/<srcMAC>/<dstMAC>")
+def proxy_add_flow(src_dpid, src_port, dst_dpid, dst_port, srcMAC, dstMAC):
+  try:
+    url = "%s/gui/addflow/%s/%s/%s/%s/%s/%s" % (ONOS_GUI3_CONTROL_HOST, src_dpid, src_port, dst_dpid, dst_port, srcMAC, dstMAC)
+    #print "proxy gui addflow " + url
+    (code, result) = get_json(url)
+  except:
+    print "REST IF has issue %s" % url
+    print "Result %s" % result
+    exit()
+
+  resp = Response(result, status=200, mimetype='application/json')
+  return resp
+
+@app.route("/proxy/gui/delflow/<flow_id>")
+def proxy_del_flow(flow_id):
+  url = "%s/gui/delflow/%s" % (ONOS_GUI3_CONTROL_HOST, flow_id)
+  try:
+    response = urlopen(url)
+    result = response.read()
+  except:
+    result = ""
+    print "REST IF has issue %s" % url
+
+  resp = Response(result, status=200, mimetype='application/json')
+  return resp
+
+@app.route("/proxy/gui/iperf/start/<flow_id>/<duration>/<samples>")
+def proxy_iperf_start(flow_id,duration,samples):
+  url = "%s/gui/iperf/start/%s/%s/%s" % (ONOS_GUI3_CONTROL_HOST, flow_id, duration, samples)
+  try:
+    response = urlopen(url)
+    result = response.read()
+  except:
+    result = ""
+    print "REST IF has issue %s" % url
+
+  resp = Response(result, status=200, mimetype='application/json')
+  return resp
+
+@app.route("/proxy/gui/iperf/rate/<flow_id>")
+def proxy_iperf_rate(flow_id):
+  url = "%s/gui/iperf/rate/%s" % (ONOS_GUI3_CONTROL_HOST, flow_id)
+  try:
+    response = urlopen(url)
+    result = response.read()
+  except:
+    result = ""
+    print "REST IF has issue %s" % url
+
+  resp = Response(result, status=200, mimetype='application/json')
+  return resp
+
+@app.route("/proxy/gui/reset")
+def proxy_gui_reset():
+  url = "%s/gui/reset" % (ONOS_GUI3_CONTROL_HOST)
+  try:
+    response = urlopen(url)
+    result = response.read()
+  except:
+    result = ""
+    print "REST IF has issue %s" % url
+
+  resp = Response(result, status=200, mimetype='application/json')
+  return resp
+
+@app.route("/proxy/gui/scale")
+def proxy_gui_scale():
+  url = "%s/gui/scale" % (ONOS_GUI3_CONTROL_HOST)
+  try:
+    response = urlopen(url)
+    result = response.read()
+  except:
+    result = ""
+    print "REST IF has issue %s" % url
+
+  resp = Response(result, status=200, mimetype='application/json')
+  return resp
+
+###### ONOS REST API ##############################
+## Worker Func ###
+def get_json(url):
+  code = 200;
+  try:
+    response = urlopen(url)
+  except URLError, e:
+    print "get_json: REST IF %s has issue. Reason: %s" % (url, e.reason)
+    result = ""
+    return (500, result)
+  except HTTPError, e:
+    print "get_json: REST IF %s has issue. Code %s" % (url, e.code)
+    result = ""
+    return (e.code, result)
+
+  result = response.read()
+#  parsedResult = json.loads(result)
+  return (code, result)
+
+def pick_host():
+  if LB == True:
+    nr_host=len(controllers)
+    r=random.randint(0, nr_host - 1)
+    host=controllers[r]
+  else:
+    host=ONOS_DEFAULT_HOST
+
+  return "http://" + host + ":8080"
+
+## Switch ##
+@app.route("/wm/onos/topology/switches/json")
+def switches():
+  if request.args.get('proxy') == None:
+    host = pick_host()
+  else:
+    host = ONOS_GUI3_HOST
+
+  url ="%s/wm/onos/topology/switches/json" % (host)
+  (code, result) = get_json(url)
+
+  resp = Response(result, status=code, mimetype='application/json')
+  return resp
+
+## Link ##
+@app.route("/wm/onos/topology/links/json")
+def links():
+  if request.args.get('proxy') == None:
+    host = pick_host()
+  else:
+    host = ONOS_GUI3_HOST
+
+  url ="%s/wm/onos/topology/links/json" % (host)
+  (code, result) = get_json(url)
+
+  resp = Response(result, status=code, mimetype='application/json')
+  return resp
+
+## FlowSummary ##
+@app.route("/wm/onos/flows/getsummary/<start>/<range>/json")
+def flows(start, range):
+  if request.args.get('proxy') == None:
+    host = pick_host()
+  else:
+    host = ONOS_GUI3_HOST
+
+  url ="%s/wm/onos/flows/getsummary/%s/%s/json" % (host, start, range)
+  (code, result) = get_json(url)
+
+  resp = Response(result, status=code, mimetype='application/json')
+  return resp
+
+@app.route("/wm/onos/registry/controllers/json")
+def registry_controllers():
+  if request.args.get('proxy') == None:
+    host = pick_host()
+  else:
+    host = ONOS_GUI3_HOST
+
+  url= "%s/wm/onos/registry/controllers/json" % (host)
+  (code, result) = get_json(url)
+
+  resp = Response(result, status=code, mimetype='application/json')
+  return resp
+
+
+@app.route("/wm/onos/registry/switches/json")
+def registry_switches():
+  if request.args.get('proxy') == None:
+    host = pick_host()
+  else:
+    host = ONOS_GUI3_HOST
+
+  url="%s/wm/onos/registry/switches/json" % (host)
+  (code, result) = get_json(url)
+
+  resp = Response(result, status=code, mimetype='application/json')
+  return resp
+
+def node_id(switch_array, dpid):
+  id = -1
+  for i, val in enumerate(switch_array):
+    if val['name'] == dpid:
+      id = i
+      break
+
+  return id
+
+## API for ON.Lab local GUI ##
+@app.route('/topology', methods=['GET'])
+def topology_for_gui():
+  try:
+    url="http://%s:%s/wm/onos/topology/switches/json" % (RestIP, RestPort)
+    (code, result) = get_json(url)
+    parsedResult = json.loads(result)
+  except:
+    log_error("REST IF has issue: %s" % url)
+    log_error("%s" % result)
+    return
+
+  topo = {}
+  switches = []
+  links = []
+  devices = []
+
+  for v in parsedResult:
+    if v.has_key('dpid'):
+#      if v.has_key('dpid') and str(v['state']) == "ACTIVE":#;if you want only ACTIVE nodes
+      dpid = str(v['dpid'])
+      state = str(v['state'])
+      sw = {}
+      sw['name']=dpid
+      sw['group']= -1
+
+      if state == "INACTIVE":
+        sw['group']=0
+      switches.append(sw)
+
+  try:
+    url="http://%s:%s/wm/onos/registry/switches/json" % (RestIP, RestPort)
+    (code, result) = get_json(url)
+    parsedResult = json.loads(result)
+  except:
+    log_error("REST IF has issue: %s" % url)
+    log_error("%s" % result)
+
+  for key in parsedResult:
+    dpid = key
+    ctrl = parsedResult[dpid][0]['controllerId']
+    sw_id = node_id(switches, dpid)
+    if sw_id != -1:
+      if switches[sw_id]['group'] != 0:
+        switches[sw_id]['group'] = controllers.index(ctrl) + 1
+
+  try:
+    url = "http://%s:%s/wm/onos/topology/links/json" % (RestIP, RestPort)
+    (code, result) = get_json(url)
+    parsedResult = json.loads(result)
+  except:
+    log_error("REST IF has issue: %s" % url)
+    log_error("%s" % result)
+    return
+#    sys.exit(0)
+
+  for v in parsedResult:
+    link = {}
+    if v.has_key('dst-switch'):
+      dst_dpid = str(v['dst-switch'])
+      dst_id = node_id(switches, dst_dpid)
+    if v.has_key('src-switch'):
+      src_dpid = str(v['src-switch'])
+      src_id = node_id(switches, src_dpid)
+    link['source'] = src_id
+    link['target'] = dst_id
+
+    #onpath = 0
+    #for (s,d) in path:
+    #  if s == v['src-switch'] and d == v['dst-switch']:
+    #    onpath = 1
+    #    break
+    #link['type'] = onpath
+
+    links.append(link)
+
+  topo['nodes'] = switches
+  topo['links'] = links
+
+  js = json.dumps(topo)
+  resp = Response(js, status=200, mimetype='application/json')
+  return resp
+
+@app.route("/wm/floodlight/topology/toporoute/<v1>/<p1>/<v2>/<p2>/json")
+def shortest_path(v1, p1, v2, p2):
+  try:
+    url = "http://%s:%s/wm/onos/topology/switches/json" % (RestIP, RestPort)
+    (code, result) = get_json(url)
+    parsedResult = json.loads(result)
+  except:
+    log_error("REST IF has issue: %s" % command)
+    log_error("%s" % result)
+    return
+
+  topo = {}
+  switches = []
+  links = []
+
+  for v in parsedResult:
+    if v.has_key('dpid'):
+      dpid = str(v['dpid'])
+      state = str(v['state'])
+      sw = {}
+      sw['name']=dpid
+      if str(v['state']) == "ACTIVE":
+        if dpid[-2:-1] == "a":
+         sw['group']=1
+        if dpid[-2:-1] == "b":
+         sw['group']=2
+        if dpid[-2:-1] == "c":
+         sw['group']=3
+      if str(v['state']) == "INACTIVE":
+         sw['group']=0
+
+      switches.append(sw)
+
+  try:
+    url = "http://%s:%s/wm/onos/topology/route/%s/%s/%s/%s/json" % (RestIP, RestPort, v1, p1, v2, p2)
+    (code, result) = get_json(url)
+    parsedResult = json.loads(result)
+  except:
+    log_error("No route")
+    parsedResult = []
+
+  path = [];
+  for i, v in enumerate(parsedResult):
+    if i < len(parsedResult) - 1:
+      sdpid= parsedResult['flowEntries'][i]['dpid']['value']
+      ddpid= parsedResult['flowEntries'][i+1]['dpid']['value']
+      path.append( (sdpid, ddpid))
+
+  try:
+    url = "http://%s:%s/wm/onos/topology/links/json" % (RestIP, RestPort)
+    (code, result) = get_json(url)
+    parsedResult = json.loads(result)
+  except:
+    log_error("REST IF has issue: %s" % command)
+    log_error("%s" % result)
+    return
+
+  for v in parsedResult:
+    link = {}
+    if v.has_key('dst-switch'):
+      dst_dpid = str(v['dst-switch'])
+      dst_id = node_id(switches, dst_dpid)
+    if v.has_key('src-switch'):
+      src_dpid = str(v['src-switch'])
+      src_id = node_id(switches, src_dpid)
+    link['source'] = src_id
+    link['target'] = dst_id
+    onpath = 0
+    for (s,d) in path:
+      if s == v['src-switch'] and d == v['dst-switch']:
+        onpath = 1
+        break
+
+    link['type'] = onpath
+    links.append(link)
+
+  topo['nodes'] = switches
+  topo['links'] = links
+
+  js = json.dumps(topo)
+  resp = Response(js, status=200, mimetype='application/json')
+  return resp
+
+@app.route("/wm/floodlight/core/controller/switches/json")
+def query_switch():
+  try:
+    url = "http://%s:%s/wm/onos/topology/switches/json" % (RestIP, RestPort)
+    (code, result) = get_json(url)
+    parsedResult = json.loads(result)
+  except:
+    log_error("REST IF has issue: %s" % url)
+    log_error("%s" % result)
+    return
+#    sys.exit(0)
+
+#  print command
+#  print result
+  switches_ = []
+  for v in parsedResult:
+    if v.has_key('dpid'):
+      if v.has_key('dpid') and str(v['state']) == "ACTIVE":#;if you want only ACTIVE nodes
+        dpid = str(v['dpid'])
+        state = str(v['state'])
+        sw = {}
+        sw['dpid']=dpid
+        sw['active']=state
+        switches_.append(sw)
+
+#  pp.pprint(switches_)
+  js = json.dumps(switches_)
+  resp = Response(js, status=200, mimetype='application/json')
+  return resp
+
+## return fake stat for now
+@app.route("/wm/floodlight/core/switch/<switchId>/<statType>/json")
+def switch_stat(switchId, statType):
+    if statType == "desc":
+        desc=[{"length":1056,"serialNumber":"None","manufacturerDescription":"Nicira Networks, Inc.","hardwareDescription":"Open vSwitch","softwareDescription":"1.4.0+build0","datapathDescription":"None"}]
+        ret = {}
+        ret[switchId]=desc
+    elif statType == "aggregate":
+        aggr = {"packetCount":0,"byteCount":0,"flowCount":0}
+        ret = {}
+        ret[switchId]=aggr
+    else:
+        ret = {}
+
+    js = json.dumps(ret)
+    resp = Response(js, status=200, mimetype='application/json')
+    return resp
+
+@app.route("/controller_status")
+def controller_status():
+  url= "http://%s:%d/wm/onos/registry/controllers/json" % (RestIP, RestPort)
+  (code, result) = get_json(url)
+  parsedResult = json.loads(result)
+
+  cont_status=[]
+  for i in controllers:
+    status={}
+    if i in parsedResult:
+      onos=1
+    else:
+      onos=0
+    status["name"]=i
+    status["onos"]=onos
+    status["cassandra"]=0
+    cont_status.append(status)
+
+  js = json.dumps(cont_status)
+  resp = Response(js, status=200, mimetype='application/json')
+  return resp
+
+
+### Command ###
+@app.route("/gui/controller/<cmd>/<controller_name>")
+def controller_status_change(cmd, controller_name):
+  if (TESTBED == "hw"):
+    start_onos="/home/admin/bin/onos start %s" % (controller_name[-1:])
+#    start_onos="/home/admin/bin/onos start %s > /tmp/debug " % (controller_name[-1:])
+    stop_onos="/home/admin/bin/onos stop %s" % (controller_name[-1:])
+#    stop_onos="/home/admin/bin/onos stop %s > /tmp/debug " % (controller_name[-1:])
+#    print "Debug: Controller command %s called %s" % (cmd, controller_name)
+  else:
+    # No longer use -i to specify keys (use .ssh/config to specify it)
+    start_onos="ssh %s \"cd ONOS; ./onos.sh core start\"" % (controller_name)
+    stop_onos="ssh %s \"cd ONOS; ./onos.sh core stop\"" % (controller_name)
+#    start_onos="ssh -i ~/.ssh/onlabkey.pem %s ONOS/start-onos.sh start" % (controller_name)
+#    stop_onos="ssh -i ~/.ssh/onlabkey.pem %s ONOS/start-onos.sh stop" % (controller_name)
+
+  if cmd == "up":
+    result=os.popen(start_onos).read()
+    ret = "controller %s is up: %s" % (controller_name, result)
+  elif cmd == "down":
+    result=os.popen(stop_onos).read()
+    ret = "controller %s is down: %s" % (controller_name, result)
+
+  return ret
+
+@app.route("/gui/switchctrl/<cmd>")
+def switch_controller_setting(cmd):
+  if cmd =="local":
+    print "All aggr switches connects to local controller only"
+    result=""
+    if (TESTBED == "sw"):
+      for i in range(1, len(controllers)):
+          cmd_string="ssh %s 'cd %s; ./ctrl-local.sh'" % (controllers[i], REMOTE_DEMO_SCRIPTS_DIR)
+          result += os.popen(cmd_string).read()
+    else:
+      cmd_string="cd; switch local > /tmp/watch"
+      result += os.popen(cmd_string).read()
+  elif cmd =="all":
+    print "All aggr switches connects to all controllers except for core controller"
+    result=""
+    if (TESTBED == "sw"):
+      for i in range(1, len(controllers)):
+        cmd_string="ssh %s 'cd %s; ./ctrl-add-ext.sh'" % (controllers[i], REMOTE_DEMO_SCRIPTS_DIR)
+#        cmd_string="ssh -i ~/.ssh/onlabkey.pem %s 'cd %s; ./ctrl-add-ext.sh'" % (controllers[i], REMOTE_DEMO_SCRIPTS_DIR)
+        print "cmd is: "+cmd_string
+        result += os.popen(cmd_string).read()
+    else:
+      cmd_string="/home/admin/bin/switch all > /tmp/watch"
+      result += os.popen(cmd_string).read()
+
+  return result
+
+@app.route("/gui/reset")
+def reset_demo():
+  if (TESTBED == "hw"):
+    cmd_string="cd ~/bin; ./demo-reset-hw.sh > /tmp/watch &"
+  else:
+    cmd_string="cd %s; ./demo-reset-sw.sh > /tmp/watch &" % (REMOTE_DEMO_SCRIPTS_DIR)
+  os.popen(cmd_string)
+  return "Reset" 
+
+@app.route("/gui/scale")
+def scale_demo():
+  if (TESTBED == "hw"):
+    cmd_string="cd ~/bin;  ~/bin/demo-scale-out-hw.sh > /tmp/watch &"
+  else:
+    cmd_string="cd %s; ./demo-scale-out-sw.sh > /tmp/watch &" % (REMOTE_DEMO_SCRIPTS_DIR)
+  os.popen(cmd_string)
+  return "scale"
+
+@app.route("/gui/switch/<cmd>/<dpid>")
+def switch_status_change(cmd, dpid):
+  result = ""
+  if (TESTBED == "hw"):
+    return result
+
+  r = re.compile(':')
+  dpid = re.sub(r, '', dpid)
+  host=controllers[0]
+  cmd_string="ssh %s 'cd %s; ./switch.sh %s %s'" % (host, REMOTE_DEMO_SCRIPTS_DIR, dpid, cmd)
+#  cmd_string="ssh -i ~/.ssh/onlabkey.pem %s 'cd %s; ./switch.sh %s %s'" % (host, REMOTE_DEMO_SCRIPTS_DIR, dpid, cmd)
+  get_status="ssh -i ~/.ssh/onlabkey.pem %s 'cd %s; ./switch.sh %s'" % (host, REMOTE_DEMO_SCRIPTS_DIR, dpid)
+  print "cmd_string"
+
+  if cmd =="up" or cmd=="down":
+    print "make dpid %s %s" % (dpid, cmd)
+    os.popen(cmd_string)
+    result=os.popen(get_status).read()
+
+  return result
+
+#* Link Up
+#http://localhost:9000/gui/link/up/<src_dpid>/<src_port>/<dst_dpid>/<dst_port>
+@app.route("/gui/link/up/<src_dpid>/<src_port>/<dst_dpid>/<dst_port>")
+def link_up(src_dpid, src_port, dst_dpid, dst_port):
+  result = ""
+
+  if (TESTBED == "sw"):
+    result = link_up_sw(src_dpid, src_port, dst_dpid, dst_port)
+  else:
+    result = link_up_hw(src_dpid, src_port, dst_dpid, dst_port)
+  return result
+
+# Link up on software testbed
+def link_up_sw(src_dpid, src_port, dst_dpid, dst_port):
+
+  cmd = 'up'
+  result=""
+  for dpid in (src_dpid, dst_dpid):
+    if dpid in core_switches:
+      host = controllers[0]
+    else:
+      hostid=int(dpid.split(':')[-2])
+      host = controllers[hostid-1]
+
+    if dpid == src_dpid:
+      (port, dontcare) = get_link_ports(dpid, dst_dpid)
+    else:
+      (port, dontcare) = get_link_ports(dpid, src_dpid)
+
+#    cmd_string="ssh -i ~/.ssh/onlabkey.pem %s 'cd %s; ./link.sh %s %s %s'" % (host, REMOTE_DEMO_SCRIPTS_DIR, dpid, port, cmd)
+    cmd_string="ssh %s 'cd %s; ./link.sh %s %s %s'" % (host, REMOTE_DEMO_SCRIPTS_DIR, dpid, port, cmd)
+    print cmd_string
+    res=os.popen(cmd_string).read()
+    result = result + ' ' + res
+
+  return result
+
+#      if hostid == 2 :
+#        src_ports = [51]
+#      else :
+#        src_ports = [26]
+#
+#    for port in src_ports :
+#      cmd_string="ssh -i ~/.ssh/onlabkey.pem %s 'cd %s; ./link.sh %s %s %s'" % (host, REMOTE_DEMO_SCRIPTS_DIR, dpid, port, cmd)
+#      print cmd_string
+#      res=os.popen(cmd_string).read()
+
+
+
+# Link up on hardware testbed
+def link_up_hw(src_dpid, src_port, dst_dpid, dst_port):
+
+	port1 = src_port
+	port2 = dst_port
+	if src_dpid == "00:00:00:00:ba:5e:ba:11":
+		if dst_dpid == "00:00:00:08:a2:08:f9:01":
+			port1 = 24
+			port2 = 24
+		elif dst_dpid == "00:01:00:16:97:08:9a:46":
+			port1 = 23
+			port2 = 23
+	elif src_dpid == "00:00:00:00:ba:5e:ba:13":
+                if dst_dpid == "00:00:20:4e:7f:51:8a:35":
+			port1 = 22
+			port2 = 22
+                elif dst_dpid == "00:00:00:00:00:00:ba:12":
+			port1 = 23
+			port2 = 23
+	elif src_dpid == "00:00:00:00:00:00:ba:12":
+                if dst_dpid == "00:00:00:00:ba:5e:ba:13":
+			port1 = 23
+			port2 = 23
+                elif dst_dpid == "00:00:00:08:a2:08:f9:01":
+			port1 = 22
+			port2 = 22
+                elif dst_dpid == "00:00:20:4e:7f:51:8a:35":
+			port1 = 24
+			port2 = 21
+	elif src_dpid == "00:01:00:16:97:08:9a:46":
+                if dst_dpid == "00:00:00:00:ba:5e:ba:11":
+			port1 = 23
+			port2 = 23
+                elif dst_dpid == "00:00:20:4e:7f:51:8a:35":
+			port1 = 24
+			port2 = 24
+	elif src_dpid == "00:00:00:08:a2:08:f9:01":
+                if dst_dpid == "00:00:00:00:ba:5e:ba:11":
+			port1 = 24
+			port2 = 24
+                elif dst_dpid == "00:00:00:00:00:00:ba:12":
+			port1 = 22
+			port2 = 22
+                elif dst_dpid == "00:00:20:4e:7f:51:8a:35":
+			port1 = 23
+			port2 = 23
+	elif src_dpid == "00:00:20:4e:7f:51:8a:35":
+                if dst_dpid == "00:00:00:00:00:00:ba:12":
+			port1 = 21
+			port2 = 24
+                elif dst_dpid == "00:00:00:00:ba:5e:ba:13":
+			port1 = 22
+			port2 = 22
+                elif dst_dpid == "00:01:00:16:97:08:9a:46":
+			port1 = 24
+			port2 = 24
+                elif dst_dpid == "00:00:00:08:a2:08:f9:01":
+			port1 = 23
+			port2 = 23
+
+	cmd = 'up'
+	result=""
+	host = controllers[0]
+	cmd_string="%s/link-hw.sh %s %s %s " % (ONS2014_DEMO_SCRIPTS_DIR, src_dpid, port1, cmd)
+	print cmd_string
+	res=os.popen(cmd_string).read()
+	result = result + ' ' + res
+	cmd_string="%s/link-hw.sh %s %s %s " % (ONS2014_DEMO_SCRIPTS_DIR, dst_dpid, port2, cmd)
+	print cmd_string
+	res=os.popen(cmd_string).read()
+	result = result + ' ' + res
+
+
+	return result
+
+
+#* Link Down
+#http://localhost:9000/gui/link/down/<src_dpid>/<src_port>/<dst_dpid>/<dst_port>
+@app.route("/gui/link/<cmd>/<src_dpid>/<src_port>/<dst_dpid>/<dst_port>")
+def link_down(cmd, src_dpid, src_port, dst_dpid, dst_port):
+
+  if src_dpid in core_switches:
+    host = controllers[0]
+  else:
+    hostid=int(src_dpid.split(':')[-2])
+    host = controllers[hostid-1]
+
+  if (TESTBED == "sw"):
+    cmd_string="ssh %s 'cd %s; ./link.sh %s %s %s'" % (host, REMOTE_DEMO_SCRIPTS_DIR, src_dpid, src_port, cmd)
+  else:
+    if ( src_dpid == "00:00:00:08:a2:08:f9:01" ):
+      cmd_string="%s/link-hw.sh %s %s %s " % (ONS2014_DEMO_SCRIPTS_DIR, dst_dpid, dst_port, cmd)
+    else:
+      cmd_string="%s/link-hw.sh %s %s %s " % (ONS2014_DEMO_SCRIPTS_DIR, src_dpid, src_port, cmd)
+  print cmd_string
+
+  result=os.popen(cmd_string).read()
+
+  return result
+
+#* Create Flow
+#http://localhost:9000/gui/addflow/<src_dpid>/<src_port>/<dst_dpid>/<dst_port>/<srcMAC>/<dstMAC>
+#1 FOOBAR 00:00:00:00:00:00:01:01 1 00:00:00:00:00:00:01:0b 1 matchSrcMac 00:00:00:00:00:00 matchDstMac 00:01:00:00:00:00
+@app.route("/gui/addflow/<src_dpid>/<src_port>/<dst_dpid>/<dst_port>/<srcMAC>/<dstMAC>")
+def add_flow(src_dpid, src_port, dst_dpid, dst_port, srcMAC, dstMAC):
+  host = pick_host()
+  url ="%s/wm/onos/flows/getsummary/%s/%s/json" % (host, 0, 0)
+  (code, result) = get_json(url)
+  parsedResult = json.loads(result)
+  if len(parsedResult) > 0:
+    if parsedResult[-1].has_key('flowId'):
+      flow_nr = int(parsedResult[-1]['flowId']['value'], 16)
+  else:
+    flow_nr = -1  # first flow
+    print "first flow"
+
+  flow_nr += 1
+  command =  "%s/add_flow.py -m onos %d %s %s %s %s %s matchSrcMac %s matchDstMac %s" % (ONOS_SCRIPTS_DIR, flow_nr, "dummy", src_dpid, src_port, dst_dpid, dst_port, srcMAC, dstMAC)
+  flow_nr += 1
+  command1 = "%s/add_flow.py -m onos %d %s %s %s %s %s matchSrcMac %s matchDstMac %s" % (ONOS_SCRIPTS_DIR, flow_nr, "dummy", dst_dpid, dst_port, src_dpid, src_port, dstMAC, srcMAC)
+  print "add flow: %s, %s" % (command, command1)
+  errcode = os.popen(command).read()
+  errcode1 = os.popen(command1).read()
+  ret=command+":"+errcode+" "+command1+":"+errcode1
+  print ret 
+  return ret
+
+#* Delete Flow
+#http://localhost:9000/gui/delflow/<flow_id>
+@app.route("/gui/delflow/<flow_id>")
+def del_flow(flow_id):
+  command = "%s/delete_flow.py %s" % (ONOS_SCRIPTS_DIR, flow_id)
+  print command
+  errcode = os.popen(command).read()
+  return errcode
+
+#* Start Iperf Througput
+#http://localhost:9000/gui/iperf/start/<flow_id>/<duration>
+@app.route("/gui/iperf/start/<flow_id>/<duration>/<samples>")
+def iperf_start(flow_id,duration,samples):
+  url = "http://%s:%s/wm/onos/flows/get/%s/json" % (RestIP, RestPort, flow_id)
+  try:
+    response = urlopen(url)
+    result = response.read()
+    if len(result) == 0:
+      print "No Flow found"
+      return "Flow %s not found" % (flow_id);
+  except:
+    print "REST IF has issue %s" % url
+    return "REST IF has issue %s" % url
+
+  parsedResult = json.loads(result)
+
+  flowId = int(parsedResult['flowId']['value'], 16)
+  src_dpid = parsedResult['dataPath']['srcPort']['dpid']['value']
+  src_port = parsedResult['dataPath']['srcPort']['port']['value']
+  dst_dpid = parsedResult['dataPath']['dstPort']['dpid']['value']
+  dst_port = parsedResult['dataPath']['dstPort']['port']['value']
+#  print "FlowPath: (flowId = %s src = %s/%s dst = %s/%s" % (flowId, src_dpid, src_port, dst_dpid, dst_port)
+
+  if src_dpid in core_switches:
+      src_host = controllers[0]
+  else:
+      hostid=int(src_dpid.split(':')[-2])
+      if TESTBED == "hw":
+        src_host = "mininet%i" % hostid
+      else:
+        src_host = controllers[hostid-1]
+
+  if dst_dpid in core_switches:
+      dst_host = controllers[0]
+  else:
+      hostid=int(dst_dpid.split(':')[-2])
+      if TESTBED == "hw":
+        dst_host = "mininet%i" % hostid
+      else:
+        dst_host = controllers[hostid-1]
+
+# /runiperf.sh <flowid> <src_dpid> <dst_dpid> hw:svr|sw:svr|hw:client|sw:client <proto>/<duration>/<interval>/<samples>
+  protocol="udp"
+  interval=0.1
+  if TESTBED == "hw":
+    cmd_string="dsh -w %s 'cd %s; " % (dst_host, REMOTE_DEMO_SCRIPTS_DIR)
+  else:
+    cmd_string="ssh %s 'cd %s; " % (dst_host, REMOTE_DEMO_SCRIPTS_DIR)
+  cmd_string += "./runiperf.sh %d %s %s %s:%s %s/%s/%s/%s'" % (flowId, src_dpid, dst_dpid, TESTBED, "svr", protocol, duration, interval, samples)
+  print cmd_string
+  os.popen(cmd_string)
+
+  if TESTBED == "hw":
+    cmd_string="dsh -w %s 'cd %s; " % (src_host, REMOTE_DEMO_SCRIPTS_DIR)
+  else:
+    cmd_string="ssh %s 'cd %s;" % (src_host, REMOTE_DEMO_SCRIPTS_DIR)
+  cmd_string+="./runiperf.sh %d %s %s %s:%s %s/%s/%s/%s'" % (flowId, src_dpid, dst_dpid, TESTBED, "client", protocol, duration, interval, samples)
+  print cmd_string
+  os.popen(cmd_string)
+
+  return cmd_string
+
+
+#* Get Iperf Throughput
+#http://localhost:9000/gui/iperf/rate/<flow_id>
+@app.route("/gui/iperf/rate/<flow_id>")
+def iperf_rate(flow_id):
+  url = "http://%s:%s/wm/onos/flows/get/%s/json" % (RestIP, RestPort, flow_id)
+  try:
+    response = urlopen(url)
+    result = response.read()
+    if len(result) == 0:
+      return "no such iperf flow (flowid %s)" % flow_id
+  except:
+    print "REST IF has issue %s" % url
+    exit
+
+  parsedResult = json.loads(result)
+
+  flowId = int(parsedResult['flowId']['value'], 16)
+  src_dpid = parsedResult['dataPath']['srcPort']['dpid']['value']
+  src_port = parsedResult['dataPath']['srcPort']['port']['value']
+  dst_dpid = parsedResult['dataPath']['dstPort']['dpid']['value']
+  dst_port = parsedResult['dataPath']['dstPort']['port']['value']
+
+  if dst_dpid in core_switches:
+    host = controllers[0]
+  else:
+    hostid=int(dst_dpid.split(':')[-2])
+    if TESTBED == "hw":
+      host = "mininet%i" % hostid
+    else:
+      host = controllers[hostid-1]
+
+  url="http://%s:%s/log/iperfsvr_%s.out" % (host, 9000, flow_id)
+  try:
+    response = urlopen(url)
+    result = response.read()
+  except:
+    print "REST IF has issue %s" % url
+    return 
+
+  if re.match("Cannot", result):
+    resp = Response(result, status=400, mimetype='text/html')
+    return "no iperf file found (host %s flowid %s): %s" % (host, flow_id, result)
+  else:
+    resp = Response(result, status=200, mimetype='application/json')
+    return resp
+
+if __name__ == "__main__":
+  random.seed()
+  read_config()
+  read_link_def()
+  if len(sys.argv) > 1 and sys.argv[1] == "-d":
+    # for debugging
+    #add_flow("00:00:00:00:00:00:02:02", 1, "00:00:00:00:00:00:03:02", 1, "00:00:00:00:02:02", "00:00:00:00:03:0c")
+    #proxy_link_change("up", "00:00:00:00:ba:5e:ba:11", 1, "00:00:00:00:00:00:00:00", 1)
+    #proxy_link_change("down", "00:00:20:4e:7f:51:8a:35", 1, "00:00:00:00:00:00:00:00", 1)
+    #proxy_link_change("up", "00:00:00:00:00:00:02:03", 1, "00:00:00:00:00:00:00:00", 1)
+    #proxy_link_change("down", "00:00:00:00:00:00:07:12", 1, "00:00:00:00:00:00:00:00", 1)
+    #print "-- query all switches --"
+    #query_switch()
+    #print "-- query topo --"
+    #topology_for_gui()
+    ##print "-- query all links --"
+    ##query_links()
+    #print "-- query all devices --"
+    #devices()
+    #links()
+    #switches()
+    #reset_demo()
+    pass
+  else:
+    app.debug = True
+    app.run(threaded=True, host=ProxyIP, port=ProxyPort)
diff --git a/web/ons-demo/README.txt b/sample/ONS2014demo/web/README.txt
similarity index 100%
rename from web/ons-demo/README.txt
rename to sample/ONS2014demo/web/README.txt
diff --git a/web/ons-demo/RELEASE_NOTES.txt b/sample/ONS2014demo/web/RELEASE_NOTES.txt
similarity index 100%
rename from web/ons-demo/RELEASE_NOTES.txt
rename to sample/ONS2014demo/web/RELEASE_NOTES.txt
diff --git a/web/ons-demo/assets/black-eye.svg b/sample/ONS2014demo/web/assets/black-eye.svg
similarity index 100%
rename from web/ons-demo/assets/black-eye.svg
rename to sample/ONS2014demo/web/assets/black-eye.svg
diff --git a/web/ons-demo/assets/delete.svg b/sample/ONS2014demo/web/assets/delete.svg
similarity index 100%
rename from web/ons-demo/assets/delete.svg
rename to sample/ONS2014demo/web/assets/delete.svg
diff --git a/web/ons-demo/assets/logo.svg b/sample/ONS2014demo/web/assets/logo.svg
similarity index 100%
rename from web/ons-demo/assets/logo.svg
rename to sample/ONS2014demo/web/assets/logo.svg
diff --git a/web/ons-demo/assets/switch.svg b/sample/ONS2014demo/web/assets/switch.svg
similarity index 100%
rename from web/ons-demo/assets/switch.svg
rename to sample/ONS2014demo/web/assets/switch.svg
diff --git a/web/ons-demo/assets/white-eye.svg b/sample/ONS2014demo/web/assets/white-eye.svg
similarity index 100%
rename from web/ons-demo/assets/white-eye.svg
rename to sample/ONS2014demo/web/assets/white-eye.svg
diff --git a/web/ons-demo/css/layout.default.css b/sample/ONS2014demo/web/css/layout.default.css
similarity index 100%
rename from web/ons-demo/css/layout.default.css
rename to sample/ONS2014demo/web/css/layout.default.css
diff --git a/web/ons-demo/css/skin.default.css b/sample/ONS2014demo/web/css/skin.default.css
similarity index 100%
rename from web/ons-demo/css/skin.default.css
rename to sample/ONS2014demo/web/css/skin.default.css
diff --git a/web/ons-demo/d3/d3.v3.js b/sample/ONS2014demo/web/d3/d3.v3.js
similarity index 100%
rename from web/ons-demo/d3/d3.v3.js
rename to sample/ONS2014demo/web/d3/d3.v3.js
diff --git a/web/ons-demo/d3/d3.v3.min.js b/sample/ONS2014demo/web/d3/d3.v3.min.js
similarity index 100%
rename from web/ons-demo/d3/d3.v3.min.js
rename to sample/ONS2014demo/web/d3/d3.v3.min.js
diff --git a/web/ons-demo/d3/topojson.v0.min.js b/sample/ONS2014demo/web/d3/topojson.v0.min.js
similarity index 100%
rename from web/ons-demo/d3/topojson.v0.min.js
rename to sample/ONS2014demo/web/d3/topojson.v0.min.js
diff --git a/web/ons-demo/data/configuration.json b/sample/ONS2014demo/web/data/configuration.json
similarity index 100%
rename from web/ons-demo/data/configuration.json
rename to sample/ONS2014demo/web/data/configuration.json
diff --git a/web/ons-demo/data/configuration.json.dev b/sample/ONS2014demo/web/data/configuration.json.dev
similarity index 100%
rename from web/ons-demo/data/configuration.json.dev
rename to sample/ONS2014demo/web/data/configuration.json.dev
diff --git a/web/ons-demo/data/configuration.json.devA b/sample/ONS2014demo/web/data/configuration.json.devA
similarity index 100%
rename from web/ons-demo/data/configuration.json.devA
rename to sample/ONS2014demo/web/data/configuration.json.devA
diff --git a/web/ons-demo/data/controllers.json b/sample/ONS2014demo/web/data/controllers.json
similarity index 100%
rename from web/ons-demo/data/controllers.json
rename to sample/ONS2014demo/web/data/controllers.json
diff --git a/web/ons-demo/data/controllers.json.dev b/sample/ONS2014demo/web/data/controllers.json.dev
similarity index 100%
rename from web/ons-demo/data/controllers.json.dev
rename to sample/ONS2014demo/web/data/controllers.json.dev
diff --git a/web/ons-demo/data/wm_core_topology_links_json.json b/sample/ONS2014demo/web/data/wm_core_topology_links_json.json
similarity index 100%
rename from web/ons-demo/data/wm_core_topology_links_json.json
rename to sample/ONS2014demo/web/data/wm_core_topology_links_json.json
diff --git a/web/ons-demo/data/wm_core_topology_switches_all_json.json b/sample/ONS2014demo/web/data/wm_core_topology_switches_all_json.json
similarity index 100%
rename from web/ons-demo/data/wm_core_topology_switches_all_json.json
rename to sample/ONS2014demo/web/data/wm_core_topology_switches_all_json.json
diff --git a/web/ons-demo/data/wm_flow_getall_json.json b/sample/ONS2014demo/web/data/wm_flow_getall_json.json
similarity index 100%
rename from web/ons-demo/data/wm_flow_getall_json.json
rename to sample/ONS2014demo/web/data/wm_flow_getall_json.json
diff --git a/web/ons-demo/data/wm_registry_controllers_json.json b/sample/ONS2014demo/web/data/wm_registry_controllers_json.json
similarity index 100%
rename from web/ons-demo/data/wm_registry_controllers_json.json
rename to sample/ONS2014demo/web/data/wm_registry_controllers_json.json
diff --git a/web/ons-demo/data/wm_registry_switches_json.json b/sample/ONS2014demo/web/data/wm_registry_switches_json.json
similarity index 100%
rename from web/ons-demo/data/wm_registry_switches_json.json
rename to sample/ONS2014demo/web/data/wm_registry_switches_json.json
diff --git a/web/ons-demo/data/world.json b/sample/ONS2014demo/web/data/world.json
similarity index 100%
rename from web/ons-demo/data/world.json
rename to sample/ONS2014demo/web/data/world.json
diff --git a/web/ons-demo/data/world.txt b/sample/ONS2014demo/web/data/world.txt
similarity index 100%
rename from web/ons-demo/data/world.txt
rename to sample/ONS2014demo/web/data/world.txt
diff --git a/web/ons-demo/index.html b/sample/ONS2014demo/web/index.html
similarity index 100%
rename from web/ons-demo/index.html
rename to sample/ONS2014demo/web/index.html
diff --git a/web/ons-demo/js/app.js b/sample/ONS2014demo/web/js/app.js
similarity index 100%
rename from web/ons-demo/js/app.js
rename to sample/ONS2014demo/web/js/app.js
diff --git a/web/ons-demo/js/async.js b/sample/ONS2014demo/web/js/async.js
similarity index 100%
rename from web/ons-demo/js/async.js
rename to sample/ONS2014demo/web/js/async.js
diff --git a/web/ons-demo/js/constants.js b/sample/ONS2014demo/web/js/constants.js
similarity index 100%
rename from web/ons-demo/js/constants.js
rename to sample/ONS2014demo/web/js/constants.js
diff --git a/web/ons-demo/js/controller.js b/sample/ONS2014demo/web/js/controller.js
similarity index 100%
rename from web/ons-demo/js/controller.js
rename to sample/ONS2014demo/web/js/controller.js
diff --git a/web/ons-demo/js/controllers.js b/sample/ONS2014demo/web/js/controllers.js
similarity index 100%
rename from web/ons-demo/js/controllers.js
rename to sample/ONS2014demo/web/js/controllers.js
diff --git a/web/ons-demo/js/debug.js b/sample/ONS2014demo/web/js/debug.js
similarity index 100%
rename from web/ons-demo/js/debug.js
rename to sample/ONS2014demo/web/js/debug.js
diff --git a/web/ons-demo/js/flows.js b/sample/ONS2014demo/web/js/flows.js
similarity index 100%
rename from web/ons-demo/js/flows.js
rename to sample/ONS2014demo/web/js/flows.js
diff --git a/web/ons-demo/js/forward.js b/sample/ONS2014demo/web/js/forward.js
similarity index 100%
rename from web/ons-demo/js/forward.js
rename to sample/ONS2014demo/web/js/forward.js
diff --git a/web/ons-demo/js/globals.js b/sample/ONS2014demo/web/js/globals.js
similarity index 100%
rename from web/ons-demo/js/globals.js
rename to sample/ONS2014demo/web/js/globals.js
diff --git a/web/ons-demo/js/init.js b/sample/ONS2014demo/web/js/init.js
similarity index 100%
rename from web/ons-demo/js/init.js
rename to sample/ONS2014demo/web/js/init.js
diff --git a/web/ons-demo/js/iperf.js b/sample/ONS2014demo/web/js/iperf.js
similarity index 100%
rename from web/ons-demo/js/iperf.js
rename to sample/ONS2014demo/web/js/iperf.js
diff --git a/web/ons-demo/js/map.js b/sample/ONS2014demo/web/js/map.js
similarity index 100%
rename from web/ons-demo/js/map.js
rename to sample/ONS2014demo/web/js/map.js
diff --git a/web/ons-demo/js/model.js b/sample/ONS2014demo/web/js/model.js
similarity index 100%
rename from web/ons-demo/js/model.js
rename to sample/ONS2014demo/web/js/model.js
diff --git a/web/ons-demo/js/rings.js b/sample/ONS2014demo/web/js/rings.js
similarity index 100%
rename from web/ons-demo/js/rings.js
rename to sample/ONS2014demo/web/js/rings.js
diff --git a/web/ons-demo/js/topology.js b/sample/ONS2014demo/web/js/topology.js
similarity index 100%
rename from web/ons-demo/js/topology.js
rename to sample/ONS2014demo/web/js/topology.js
diff --git a/web/ons-demo/js/topologyactions.js b/sample/ONS2014demo/web/js/topologyactions.js
similarity index 100%
rename from web/ons-demo/js/topologyactions.js
rename to sample/ONS2014demo/web/js/topologyactions.js
diff --git a/web/ons-demo/js/utils.js b/sample/ONS2014demo/web/js/utils.js
similarity index 100%
rename from web/ons-demo/js/utils.js
rename to sample/ONS2014demo/web/js/utils.js
diff --git a/web/rest-intent/add-get-intent.rb b/scripts/add-get-intent.rb
similarity index 100%
rename from web/rest-intent/add-get-intent.rb
rename to scripts/add-get-intent.rb
diff --git a/web/add_flow.py b/scripts/add_flow.py
similarity index 100%
rename from web/add_flow.py
rename to scripts/add_flow.py
diff --git a/web/delete_flow.py b/scripts/delete_flow.py
similarity index 100%
rename from web/delete_flow.py
rename to scripts/delete_flow.py
diff --git a/web/flowdef_demo_add.txt b/scripts/flowdef_demo_add.txt
similarity index 100%
rename from web/flowdef_demo_add.txt
rename to scripts/flowdef_demo_add.txt
diff --git a/web/flowdef_demo_start.txt b/scripts/flowdef_demo_start.txt
similarity index 100%
rename from web/flowdef_demo_start.txt
rename to scripts/flowdef_demo_start.txt
diff --git a/web/generate_flows.py b/scripts/generate_flows.py
similarity index 100%
rename from web/generate_flows.py
rename to scripts/generate_flows.py
diff --git a/web/get_datagrid_ngevents.py b/scripts/get_datagrid_ngevents.py
similarity index 100%
rename from web/get_datagrid_ngevents.py
rename to scripts/get_datagrid_ngevents.py
diff --git a/web/get_flow.py b/scripts/get_flow.py
similarity index 100%
rename from web/get_flow.py
rename to scripts/get_flow.py
diff --git a/web/get_network_graph.py b/scripts/get_network_graph.py
similarity index 100%
rename from web/get_network_graph.py
rename to scripts/get_network_graph.py
diff --git a/web/rest-intent/intent-installer.rb b/scripts/intent-installer.rb
similarity index 100%
rename from web/rest-intent/intent-installer.rb
rename to scripts/intent-installer.rb
diff --git a/perf-scripts/flow-manager-perf.py b/scripts/perf-scripts/flow-manager-perf.py
similarity index 100%
rename from perf-scripts/flow-manager-perf.py
rename to scripts/perf-scripts/flow-manager-perf.py
diff --git a/perf-scripts/flow-sync-perf.py b/scripts/perf-scripts/flow-sync-perf.py
similarity index 100%
rename from perf-scripts/flow-sync-perf.py
rename to scripts/perf-scripts/flow-sync-perf.py
diff --git a/perf-scripts/generate_flows.py b/scripts/perf-scripts/generate_flows.py
similarity index 100%
rename from perf-scripts/generate_flows.py
rename to scripts/perf-scripts/generate_flows.py
diff --git a/web/rest-test.sh b/scripts/rest-test.sh
similarity index 100%
rename from web/rest-test.sh
rename to scripts/rest-test.sh
diff --git a/web/shortest_path.py b/scripts/shortest_path.py
similarity index 100%
rename from web/shortest_path.py
rename to scripts/shortest_path.py
diff --git a/start-ons2014demo.sh b/start-ons2014demo.sh
new file mode 100755
index 0000000..92718a1
--- /dev/null
+++ b/start-ons2014demo.sh
@@ -0,0 +1,82 @@
+#! /bin/bash
+
+# Change this accordingly
+ONOS_HOME=${ONOS_HOME:-${HOME}/ONOS}
+SCRIPT_NAME="topology_rest.py"
+
+#######################
+SCRIPT_DIR=${ONOS_HOME}/sample/ONS2014demo/scripts
+REST_SCRIPT=${SCRIPT_DIR}/${SCRIPT_NAME}
+LOGDIR=${ONOS_LOGDIR:-${ONOS_HOME}/onos-logs}
+REST_LOG="${LOGDIR}/ons2014demo_rest.`hostname`.log"
+#######################
+
+dokill() {
+    for cpid in $(ps -o pid= --ppid $1)
+    do 
+        dokill $cpid
+    done
+    echo "killing: $(ps -p $1 -o cmd=)"
+    kill -9 $1 > /dev/null 2>&1
+}
+
+
+function rotate {
+    logfile=$1
+    nr_max=${2:-10}
+    if [ -f $logfile ]; then
+	for i in `seq $(expr $nr_max - 1) -1 1`; do
+	    if [ -f ${logfile}.${i} ]; then
+		mv -f ${logfile}.${i} ${logfile}.`expr $i + 1`
+	    fi
+	done
+	mv $logfile $logfile.1
+    fi
+}
+
+function stop {
+    pids=`ps -edalf | grep ${SCRIPT_NAME} | grep python | grep -v grep | awk '{print $4}'`
+    for p in ${pids}; do
+	if [ x$p != "x" ]; then
+            dokill $p
+#	    sudo kill -KILL $p
+#	    echo "Killed existing prosess (pid: $p)"
+	fi
+    done
+}
+
+function status {
+    nr_process=`ps -edalf | grep ${SCRIPT_NAME} | grep python | grep -v grep | wc -l` 
+    if [ ${nr_process} != 0 ] ; then
+      echo "rest server is running"
+    else
+      echo "rest server is not running"
+    fi
+}
+
+function start {
+    rotate $REST_LOG 10 
+    cd ${SCRIPT_DIR}
+    # Make log dir for iperf log files
+    if [ ! -d  log ]; then
+      mkdir log
+    fi
+    $REST_SCRIPT > $REST_LOG 2>&1 &
+}
+
+case "$1" in
+  start)
+    stop
+    sleep 2
+    start 
+    ;;
+  stop)
+    stop
+    ;;
+  status)
+    status
+    ;;
+  *)
+    echo "Usage: $0 {start|stop|status}"
+    exit 1
+esac
diff --git a/web/topology_rest.py b/web/topology_rest.py
index 6cb5726..64f6275 100755
--- a/web/topology_rest.py
+++ b/web/topology_rest.py
@@ -17,6 +17,11 @@
 LINK_FILE=os.getenv("HOME") + "/ONOS/web/link.json"
 ONOSDIR=os.getenv("HOME") + "/ONOS"
 
+## Global Var for this proxy script setting.
+# "0.0.0.0" means any interface
+ProxyIP="0.0.0.0"
+ProxyPort=9000
+
 ## Global Var for ON.Lab local REST ##
 RestIP="localhost"
 RestPort=8080
@@ -38,24 +43,6 @@
   ONOS_GUI3_CONTROL_HOST=conf['ONOS_GUI3_CONTROL_HOST']
   f.close()
 
-def read_link_def():
-  global link_def
-  f=open(LINK_FILE)
-  try:
-    link_def=json.load(f)
-    f.close()
-  except:
-    print "Can't read link def file (link.json)"
-    sys.exit(1)
-
-def get_link_ports(src_dpid, dst_dpid):
-  ret = (-1, -1)
-  for link in link_def:
-    if link['src-switch'] == src_dpid and link['dst-switch'] == dst_dpid:
-        ret = (link['src-port'], link['dst-port'])
-        break
-  return ret
-
 ## Worker Functions ##
 def log_error(txt):
   print '%s' % (txt)
@@ -76,12 +63,6 @@
 @app.route('/', methods=['GET'])
 @app.route('/<filename>', methods=['GET'])
 @app.route('/tpl/<filename>', methods=['GET'])
-@app.route('/ons-demo/<filename>', methods=['GET'])
-@app.route('/ons-demo/js/<filename>', methods=['GET'])
-@app.route('/ons-demo/d3/<filename>', methods=['GET'])
-@app.route('/ons-demo/css/<filename>', methods=['GET'])
-@app.route('/ons-demo/assets/<filename>', methods=['GET'])
-@app.route('/ons-demo/data/<filename>', methods=['GET'])
 def return_file(filename="index.html"):
   if request.path == "/":
     fullpath = "./index.html"
@@ -111,138 +92,6 @@
 
   return response
 
-## Proxy ##
-@app.route("/proxy/gui/link/<cmd>/<src_dpid>/<src_port>/<dst_dpid>/<dst_port>")
-def proxy_link_change(cmd, src_dpid, src_port, dst_dpid, dst_port):
-  url = "%s/gui/link/%s/%s/%s/%s/%s" % (ONOS_GUI3_CONTROL_HOST, cmd, src_dpid, src_port, dst_dpid, dst_port)
-  try:
-    response = urlopen(url)
-    result = response.read()
-  except:
-    result = ""
-    print "REST IF has issue %s" % url
-
-  resp = Response(result, status=200, mimetype='application/json')
-  return resp
-
-@app.route("/proxy/gui/switchctrl/<cmd>")
-def proxy_switch_controller_setting(cmd):
-  url = "%s/gui/switchctrl/%s" % (ONOS_GUI3_CONTROL_HOST, cmd)
-  try:
-    response = urlopen(url)
-    result = response.read()
-  except:
-    result = ""
-    print "REST IF has issue %s" % url
-
-  resp = Response(result, status=200, mimetype='application/json')
-  return resp
-
-@app.route("/proxy/gui/switch/<cmd>/<dpid>")
-def proxy_switch_status_change(cmd, dpid):
-  url = "%s/gui/switch/%s/%s" % (ONOS_GUI3_CONTROL_HOST, cmd, dpid)
-  try:
-    response = urlopen(url)
-    result = response.read()
-  except:
-    result = ""
-    print "REST IF has issue %s" % url
-
-  resp = Response(result, status=200, mimetype='application/json')
-  return resp
-
-@app.route("/proxy/gui/controller/<cmd>/<controller_name>")
-def proxy_controller_status_change(cmd, controller_name):
-  url = "%s/gui/controller/%s/%s" % (ONOS_GUI3_CONTROL_HOST, cmd, controller_name)
-  try:
-    response = urlopen(url)
-    result = response.read()
-  except:
-    result = ""
-    print "REST IF has issue %s" % url
- 
-  resp = Response(result, status=200, mimetype='application/json')
-  return resp
-
-@app.route("/proxy/gui/addflow/<src_dpid>/<src_port>/<dst_dpid>/<dst_port>/<srcMAC>/<dstMAC>")
-def proxy_add_flow(src_dpid, src_port, dst_dpid, dst_port, srcMAC, dstMAC):
-  try:
-    url = "%s/gui/addflow/%s/%s/%s/%s/%s/%s" % (ONOS_GUI3_CONTROL_HOST, src_dpid, src_port, dst_dpid, dst_port, srcMAC, dstMAC)
-    #print "proxy gui addflow " + url
-    (code, result) = get_json(url)
-  except:
-    print "REST IF has issue %s" % url
-    print "Result %s" % result
-    exit()
-
-  resp = Response(result, status=200, mimetype='application/json')
-  return resp
-
-@app.route("/proxy/gui/delflow/<flow_id>")
-def proxy_del_flow(flow_id):
-  url = "%s/gui/delflow/%s" % (ONOS_GUI3_CONTROL_HOST, flow_id)
-  try:
-    response = urlopen(url)
-    result = response.read()
-  except:
-    result = ""
-    print "REST IF has issue %s" % url
-
-  resp = Response(result, status=200, mimetype='application/json')
-  return resp
-
-@app.route("/proxy/gui/iperf/start/<flow_id>/<duration>/<samples>")
-def proxy_iperf_start(flow_id,duration,samples):
-  url = "%s/gui/iperf/start/%s/%s/%s" % (ONOS_GUI3_CONTROL_HOST, flow_id, duration, samples)
-  try:
-    response = urlopen(url)
-    result = response.read()
-  except:
-    result = ""
-    print "REST IF has issue %s" % url
-
-  resp = Response(result, status=200, mimetype='application/json')
-  return resp
-
-@app.route("/proxy/gui/iperf/rate/<flow_id>")
-def proxy_iperf_rate(flow_id):
-  url = "%s/gui/iperf/rate/%s" % (ONOS_GUI3_CONTROL_HOST, flow_id)
-  try:
-    response = urlopen(url)
-    result = response.read()
-  except:
-    result = ""
-    print "REST IF has issue %s" % url
-
-  resp = Response(result, status=200, mimetype='application/json')
-  return resp
-
-@app.route("/proxy/gui/reset")
-def proxy_gui_reset():
-  url = "%s/gui/reset" % (ONOS_GUI3_CONTROL_HOST)
-  try:
-    response = urlopen(url)
-    result = response.read()
-  except:
-    result = ""
-    print "REST IF has issue %s" % url
-
-  resp = Response(result, status=200, mimetype='application/json')
-  return resp
-
-@app.route("/proxy/gui/scale")
-def proxy_gui_scale():
-  url = "%s/gui/scale" % (ONOS_GUI3_CONTROL_HOST)
-  try:
-    response = urlopen(url)
-    result = response.read()
-  except:
-    result = ""
-    print "REST IF has issue %s" % url
-
-  resp = Response(result, status=200, mimetype='application/json')
-  return resp
-
 ###### ONOS REST API ##############################
 ## Worker Func ###
 def get_json(url):
@@ -258,88 +107,11 @@
     result = ""
     return (e.code, result)
 
+  print response
   result = response.read()
 #  parsedResult = json.loads(result)
   return (code, result)
 
-def pick_host():
-  if LB == True:
-    nr_host=len(controllers)
-    r=random.randint(0, nr_host - 1)
-    host=controllers[r]
-  else:
-    host=ONOS_DEFAULT_HOST
-
-  return "http://" + host + ":8080"
-
-## Switch ##
-@app.route("/wm/onos/topology/switches/json")
-def switches():
-  if request.args.get('proxy') == None:
-    host = pick_host()
-  else:
-    host = ONOS_GUI3_HOST
-
-  url ="%s/wm/onos/topology/switches/json" % (host)
-  (code, result) = get_json(url)
-
-  resp = Response(result, status=code, mimetype='application/json')
-  return resp
-
-## Link ##
-@app.route("/wm/onos/topology/links/json")
-def links():
-  if request.args.get('proxy') == None:
-    host = pick_host()
-  else:
-    host = ONOS_GUI3_HOST
-
-  url ="%s/wm/onos/topology/links/json" % (host)
-  (code, result) = get_json(url)
-
-  resp = Response(result, status=code, mimetype='application/json')
-  return resp
-
-## FlowSummary ##
-@app.route("/wm/onos/flows/getsummary/<start>/<range>/json")
-def flows(start, range):
-  if request.args.get('proxy') == None:
-    host = pick_host()
-  else:
-    host = ONOS_GUI3_HOST
-
-  url ="%s/wm/onos/flows/getsummary/%s/%s/json" % (host, start, range)
-  (code, result) = get_json(url)
-
-  resp = Response(result, status=code, mimetype='application/json')
-  return resp
-
-@app.route("/wm/onos/registry/controllers/json")
-def registry_controllers():
-  if request.args.get('proxy') == None:
-    host = pick_host()
-  else:
-    host = ONOS_GUI3_HOST
-
-  url= "%s/wm/onos/registry/controllers/json" % (host)
-  (code, result) = get_json(url)
-
-  resp = Response(result, status=code, mimetype='application/json')
-  return resp
-
-
-@app.route("/wm/onos/registry/switches/json")
-def registry_switches():
-  if request.args.get('proxy') == None:
-    host = pick_host()
-  else:
-    host = ONOS_GUI3_HOST
-
-  url="%s/wm/onos/registry/switches/json" % (host)
-  (code, result) = get_json(url)
-
-  resp = Response(result, status=code, mimetype='application/json')
-  return resp
 
 def node_id(switch_array, dpid):
   id = -1
@@ -586,397 +358,9 @@
   resp = Response(js, status=200, mimetype='application/json')
   return resp
 
-
-### Command ###
-@app.route("/gui/controller/<cmd>/<controller_name>")
-def controller_status_change(cmd, controller_name):
-  if (TESTBED == "hw"):
-    start_onos="/home/admin/bin/onos start %s" % (controller_name[-1:])
-#    start_onos="/home/admin/bin/onos start %s > /tmp/debug " % (controller_name[-1:])
-    stop_onos="/home/admin/bin/onos stop %s" % (controller_name[-1:])
-#    stop_onos="/home/admin/bin/onos stop %s > /tmp/debug " % (controller_name[-1:])
-#    print "Debug: Controller command %s called %s" % (cmd, controller_name)
-  else:
-    # No longer use -i to specify keys (use .ssh/config to specify it)
-    start_onos="ssh %s \"cd ONOS; ./start-onos.sh start\"" % (controller_name)
-    stop_onos="ssh %s \"cd ONOS; ./start-onos.sh stop\"" % (controller_name)
-#    start_onos="ssh -i ~/.ssh/onlabkey.pem %s ONOS/start-onos.sh start" % (controller_name)
-#    stop_onos="ssh -i ~/.ssh/onlabkey.pem %s ONOS/start-onos.sh stop" % (controller_name)
-
-  if cmd == "up":
-    result=os.popen(start_onos).read()
-    ret = "controller %s is up: %s" % (controller_name, result)
-  elif cmd == "down":
-    result=os.popen(stop_onos).read()
-    ret = "controller %s is down: %s" % (controller_name, result)
-
-  return ret
-
-@app.route("/gui/switchctrl/<cmd>")
-def switch_controller_setting(cmd):
-  if cmd =="local":
-    print "All aggr switches connects to local controller only"
-    result=""
-    if (TESTBED == "sw"):
-      for i in range(1, len(controllers)):
-          cmd_string="ssh %s 'cd ONOS/scripts; ./ctrl-local.sh'" % (controllers[i])
-          result += os.popen(cmd_string).read()
-    else:
-      cmd_string="cd; switch local > /tmp/watch"
-      result += os.popen(cmd_string).read()
-  elif cmd =="all":
-    print "All aggr switches connects to all controllers except for core controller"
-    result=""
-    if (TESTBED == "sw"):
-      for i in range(1, len(controllers)):
-        cmd_string="ssh %s 'cd ONOS/scripts; ./ctrl-add-ext.sh'" % (controllers[i])
-#        cmd_string="ssh -i ~/.ssh/onlabkey.pem %s 'cd ONOS/scripts; ./ctrl-add-ext.sh'" % (controllers[i])
-        print "cmd is: "+cmd_string
-        result += os.popen(cmd_string).read()
-    else:
-      cmd_string="/home/admin/bin/switch all > /tmp/watch"
-      result += os.popen(cmd_string).read()
-
-  return result
-
-@app.route("/gui/reset")
-def reset_demo():
-  if (TESTBED == "hw"):
-    cmd_string="cd ~/bin; ./demo-reset-hw.sh > /tmp/watch &"
-  else:
-    cmd_string="cd ~/ONOS/scripts; ./demo-reset-sw.sh > /tmp/watch &"
-  os.popen(cmd_string)
-  return "Reset" 
-
-@app.route("/gui/scale")
-def scale_demo():
-  if (TESTBED == "hw"):
-    cmd_string="cd ~/bin;  ~/bin/demo-scale-out-hw.sh > /tmp/watch &"
-  else:
-    cmd_string="cd ~/ONOS/scripts; ./demo-scale-out-sw.sh > /tmp/watch &"
-  os.popen(cmd_string)
-  return "scale"
-
-@app.route("/gui/switch/<cmd>/<dpid>")
-def switch_status_change(cmd, dpid):
-  result = ""
-  if (TESTBED == "hw"):
-    return result
-
-  r = re.compile(':')
-  dpid = re.sub(r, '', dpid)
-  host=controllers[0]
-  cmd_string="ssh %s 'cd ONOS/scripts; ./switch.sh %s %s'" % (host, dpid, cmd)
-#  cmd_string="ssh -i ~/.ssh/onlabkey.pem %s 'cd ONOS/scripts; ./switch.sh %s %s'" % (host, dpid, cmd)
-  get_status="ssh -i ~/.ssh/onlabkey.pem %s 'cd ONOS/scripts; ./switch.sh %s'" % (host, dpid)
-  print "cmd_string"
-
-  if cmd =="up" or cmd=="down":
-    print "make dpid %s %s" % (dpid, cmd)
-    os.popen(cmd_string)
-    result=os.popen(get_status).read()
-
-  return result
-
-#* Link Up
-#http://localhost:9000/gui/link/up/<src_dpid>/<src_port>/<dst_dpid>/<dst_port>
-@app.route("/gui/link/up/<src_dpid>/<src_port>/<dst_dpid>/<dst_port>")
-def link_up(src_dpid, src_port, dst_dpid, dst_port):
-  result = ""
-
-  if (TESTBED == "sw"):
-    result = link_up_sw(src_dpid, src_port, dst_dpid, dst_port)
-  else:
-    result = link_up_hw(src_dpid, src_port, dst_dpid, dst_port)
-  return result
-
-# Link up on software testbed
-def link_up_sw(src_dpid, src_port, dst_dpid, dst_port):
-
-  cmd = 'up'
-  result=""
-  for dpid in (src_dpid, dst_dpid):
-    if dpid in core_switches:
-      host = controllers[0]
-    else:
-      hostid=int(dpid.split(':')[-2])
-      host = controllers[hostid-1]
-
-    if dpid == src_dpid:
-      (port, dontcare) = get_link_ports(dpid, dst_dpid)
-    else:
-      (port, dontcare) = get_link_ports(dpid, src_dpid)
-
-#    cmd_string="ssh -i ~/.ssh/onlabkey.pem %s 'cd ONOS/scripts; ./link.sh %s %s %s'" % (host, dpid, port, cmd)
-    cmd_string="ssh %s 'cd ONOS/scripts; ./link.sh %s %s %s'" % (host, dpid, port, cmd)
-    print cmd_string
-    res=os.popen(cmd_string).read()
-    result = result + ' ' + res
-
-  return result
-
-#      if hostid == 2 :
-#        src_ports = [51]
-#      else :
-#        src_ports = [26]
-#
-#    for port in src_ports :
-#      cmd_string="ssh -i ~/.ssh/onlabkey.pem %s 'cd ONOS/scripts; ./link.sh %s %s %s'" % (host, dpid, port, cmd)
-#      print cmd_string
-#      res=os.popen(cmd_string).read()
-
-
-
-# Link up on hardware testbed
-def link_up_hw(src_dpid, src_port, dst_dpid, dst_port):
-
-	port1 = src_port
-	port2 = dst_port
-	if src_dpid == "00:00:00:00:ba:5e:ba:11":
-		if dst_dpid == "00:00:00:08:a2:08:f9:01":
-			port1 = 24
-			port2 = 24
-		elif dst_dpid == "00:01:00:16:97:08:9a:46":
-			port1 = 23
-			port2 = 23
-	elif src_dpid == "00:00:00:00:ba:5e:ba:13":
-                if dst_dpid == "00:00:20:4e:7f:51:8a:35":
-			port1 = 22
-			port2 = 22
-                elif dst_dpid == "00:00:00:00:00:00:ba:12":
-			port1 = 23
-			port2 = 23
-	elif src_dpid == "00:00:00:00:00:00:ba:12":
-                if dst_dpid == "00:00:00:00:ba:5e:ba:13":
-			port1 = 23
-			port2 = 23
-                elif dst_dpid == "00:00:00:08:a2:08:f9:01":
-			port1 = 22
-			port2 = 22
-                elif dst_dpid == "00:00:20:4e:7f:51:8a:35":
-			port1 = 24
-			port2 = 21
-	elif src_dpid == "00:01:00:16:97:08:9a:46":
-                if dst_dpid == "00:00:00:00:ba:5e:ba:11":
-			port1 = 23
-			port2 = 23
-                elif dst_dpid == "00:00:20:4e:7f:51:8a:35":
-			port1 = 24
-			port2 = 24
-	elif src_dpid == "00:00:00:08:a2:08:f9:01":
-                if dst_dpid == "00:00:00:00:ba:5e:ba:11":
-			port1 = 24
-			port2 = 24
-                elif dst_dpid == "00:00:00:00:00:00:ba:12":
-			port1 = 22
-			port2 = 22
-                elif dst_dpid == "00:00:20:4e:7f:51:8a:35":
-			port1 = 23
-			port2 = 23
-	elif src_dpid == "00:00:20:4e:7f:51:8a:35":
-                if dst_dpid == "00:00:00:00:00:00:ba:12":
-			port1 = 21
-			port2 = 24
-                elif dst_dpid == "00:00:00:00:ba:5e:ba:13":
-			port1 = 22
-			port2 = 22
-                elif dst_dpid == "00:01:00:16:97:08:9a:46":
-			port1 = 24
-			port2 = 24
-                elif dst_dpid == "00:00:00:08:a2:08:f9:01":
-			port1 = 23
-			port2 = 23
-
-	cmd = 'up'
-	result=""
-	host = controllers[0]
-	cmd_string="~/ONOS/scripts/link-hw.sh %s %s %s " % (src_dpid, port1, cmd)
-	print cmd_string
-	res=os.popen(cmd_string).read()
-	result = result + ' ' + res
-	cmd_string="~/ONOS/scripts/link-hw.sh %s %s %s " % (dst_dpid, port2, cmd)
-	print cmd_string
-	res=os.popen(cmd_string).read()
-	result = result + ' ' + res
-
-
-	return result
-
-
-#* Link Down
-#http://localhost:9000/gui/link/down/<src_dpid>/<src_port>/<dst_dpid>/<dst_port>
-@app.route("/gui/link/<cmd>/<src_dpid>/<src_port>/<dst_dpid>/<dst_port>")
-def link_down(cmd, src_dpid, src_port, dst_dpid, dst_port):
-
-  if src_dpid in core_switches:
-    host = controllers[0]
-  else:
-    hostid=int(src_dpid.split(':')[-2])
-    host = controllers[hostid-1]
-
-  if (TESTBED == "sw"):
-    cmd_string="ssh %s 'cd ONOS/scripts; ./link.sh %s %s %s'" % (host, src_dpid, src_port, cmd)
-  else:
-    if ( src_dpid == "00:00:00:08:a2:08:f9:01" ):
-      cmd_string="~/ONOS/scripts/link-hw.sh %s %s %s " % ( dst_dpid, dst_port, cmd)
-    else:
-      cmd_string="~/ONOS/scripts/link-hw.sh %s %s %s " % ( src_dpid, src_port, cmd)
-  print cmd_string
-
-  result=os.popen(cmd_string).read()
-
-  return result
-
-#* Create Flow
-#http://localhost:9000/gui/addflow/<src_dpid>/<src_port>/<dst_dpid>/<dst_port>/<srcMAC>/<dstMAC>
-#1 FOOBAR 00:00:00:00:00:00:01:01 1 00:00:00:00:00:00:01:0b 1 matchSrcMac 00:00:00:00:00:00 matchDstMac 00:01:00:00:00:00
-@app.route("/gui/addflow/<src_dpid>/<src_port>/<dst_dpid>/<dst_port>/<srcMAC>/<dstMAC>")
-def add_flow(src_dpid, src_port, dst_dpid, dst_port, srcMAC, dstMAC):
-  host = pick_host()
-  url ="%s/wm/onos/flows/getsummary/%s/%s/json" % (host, 0, 0)
-  (code, result) = get_json(url)
-  parsedResult = json.loads(result)
-  if len(parsedResult) > 0:
-    if parsedResult[-1].has_key('flowId'):
-      flow_nr = int(parsedResult[-1]['flowId']['value'], 16)
-  else:
-    flow_nr = -1  # first flow
-    print "first flow"
-
-  flow_nr += 1
-  command =  "%s/web/add_flow.py -m onos %d %s %s %s %s %s matchSrcMac %s matchDstMac %s" % (ONOSDIR, flow_nr, "dummy", src_dpid, src_port, dst_dpid, dst_port, srcMAC, dstMAC)
-  flow_nr += 1
-  command1 = "%s/web/add_flow.py -m onos %d %s %s %s %s %s matchSrcMac %s matchDstMac %s" % (ONOSDIR, flow_nr, "dummy", dst_dpid, dst_port, src_dpid, src_port, dstMAC, srcMAC)
-  print "add flow: %s, %s" % (command, command1)
-  errcode = os.popen(command).read()
-  errcode1 = os.popen(command1).read()
-  ret=command+":"+errcode+" "+command1+":"+errcode1
-  print ret 
-  return ret
-
-#* Delete Flow
-#http://localhost:9000/gui/delflow/<flow_id>
-@app.route("/gui/delflow/<flow_id>")
-def del_flow(flow_id):
-  command = "%/web/delete_flow.py %s" % (ONOSDIR, flow_id)
-  print command
-  errcode = os.popen(command).read()
-  return errcode
-
-#* Start Iperf Througput
-#http://localhost:9000/gui/iperf/start/<flow_id>/<duration>
-@app.route("/gui/iperf/start/<flow_id>/<duration>/<samples>")
-def iperf_start(flow_id,duration,samples):
-  url = "http://%s:%s/wm/onos/flows/get/%s/json" % (RestIP, RestPort, flow_id)
-  try:
-    response = urlopen(url)
-    result = response.read()
-    if len(result) == 0:
-      print "No Flow found"
-      return "Flow %s not found" % (flow_id);
-  except:
-    print "REST IF has issue %s" % url
-    return "REST IF has issue %s" % url
-
-  parsedResult = json.loads(result)
-
-  flowId = int(parsedResult['flowId']['value'], 16)
-  src_dpid = parsedResult['dataPath']['srcPort']['dpid']['value']
-  src_port = parsedResult['dataPath']['srcPort']['port']['value']
-  dst_dpid = parsedResult['dataPath']['dstPort']['dpid']['value']
-  dst_port = parsedResult['dataPath']['dstPort']['port']['value']
-#  print "FlowPath: (flowId = %s src = %s/%s dst = %s/%s" % (flowId, src_dpid, src_port, dst_dpid, dst_port)
-
-  if src_dpid in core_switches:
-      src_host = controllers[0]
-  else:
-      hostid=int(src_dpid.split(':')[-2])
-      if TESTBED == "hw":
-        src_host = "mininet%i" % hostid
-      else:
-        src_host = controllers[hostid-1]
-
-  if dst_dpid in core_switches:
-      dst_host = controllers[0]
-  else:
-      hostid=int(dst_dpid.split(':')[-2])
-      if TESTBED == "hw":
-        dst_host = "mininet%i" % hostid
-      else:
-        dst_host = controllers[hostid-1]
-
-# /runiperf.sh <flowid> <src_dpid> <dst_dpid> hw:svr|sw:svr|hw:client|sw:client <proto>/<duration>/<interval>/<samples>
-  protocol="udp"
-  interval=0.1
-  if TESTBED == "hw":
-    cmd_string="dsh -w %s 'cd ONOS/scripts; " % dst_host
-  else:
-    cmd_string="ssh %s 'cd ONOS/scripts; " % dst_host
-  cmd_string += "./runiperf.sh %d %s %s %s:%s %s/%s/%s/%s'" % (flowId, src_dpid, dst_dpid, TESTBED, "svr", protocol, duration, interval, samples)
-  print cmd_string
-  os.popen(cmd_string)
-
-  if TESTBED == "hw":
-    cmd_string="dsh -w %s 'cd ONOS/scripts; " % src_host
-  else:
-    cmd_string="ssh %s 'cd ONOS/scripts;" % src_host
-  cmd_string+="./runiperf.sh %d %s %s %s:%s %s/%s/%s/%s'" % (flowId, src_dpid, dst_dpid, TESTBED, "client", protocol, duration, interval, samples)
-  print cmd_string
-  os.popen(cmd_string)
-
-  return cmd_string
-
-
-#* Get Iperf Throughput
-#http://localhost:9000/gui/iperf/rate/<flow_id>
-@app.route("/gui/iperf/rate/<flow_id>")
-def iperf_rate(flow_id):
-  url = "http://%s:%s/wm/onos/flows/get/%s/json" % (RestIP, RestPort, flow_id)
-  try:
-    response = urlopen(url)
-    result = response.read()
-    if len(result) == 0:
-      return "no such iperf flow (flowid %s)" % flow_id
-  except:
-    print "REST IF has issue %s" % url
-    exit
-
-  parsedResult = json.loads(result)
-
-  flowId = int(parsedResult['flowId']['value'], 16)
-  src_dpid = parsedResult['dataPath']['srcPort']['dpid']['value']
-  src_port = parsedResult['dataPath']['srcPort']['port']['value']
-  dst_dpid = parsedResult['dataPath']['dstPort']['dpid']['value']
-  dst_port = parsedResult['dataPath']['dstPort']['port']['value']
-
-  if dst_dpid in core_switches:
-    host = controllers[0]
-  else:
-    hostid=int(dst_dpid.split(':')[-2])
-    if TESTBED == "hw":
-      host = "mininet%i" % hostid
-    else:
-      host = controllers[hostid-1]
-
-  url="http://%s:%s/log/iperfsvr_%s.out" % (host, 9000, flow_id)
-  try:
-    response = urlopen(url)
-    result = response.read()
-  except:
-    print "REST IF has issue %s" % url
-    return 
-
-  if re.match("Cannot", result):
-    resp = Response(result, status=400, mimetype='text/html')
-    return "no iperf file found (host %s flowid %s): %s" % (host, flow_id, result)
-  else:
-    resp = Response(result, status=200, mimetype='application/json')
-    return resp
-
 if __name__ == "__main__":
   random.seed()
   read_config()
-  read_link_def()
   if len(sys.argv) > 1 and sys.argv[1] == "-d":
     # for debugging
     #add_flow("00:00:00:00:00:00:02:02", 1, "00:00:00:00:00:00:03:02", 1, "00:00:00:00:02:02", "00:00:00:00:03:0c")
@@ -998,4 +382,4 @@
     pass
   else:
     app.debug = True
-    app.run(threaded=True, host="0.0.0.0", port=9000)
+    app.run(threaded=True, host=ProxyIP, port=ProxyPort)
\ No newline at end of file