Merge branch 'master' of https://github.com/OPENNETWORKINGLAB/ONOS
diff --git a/scripts/iperf b/scripts/iperf
index 9f76801..bf1f490 100755
--- a/scripts/iperf
+++ b/scripts/iperf
Binary files differ
diff --git a/src/main/java/net/floodlightcontroller/core/internal/TopoSwitchServiceImpl.java b/src/main/java/net/floodlightcontroller/core/internal/TopoSwitchServiceImpl.java
index 931802e..502fad6 100644
--- a/src/main/java/net/floodlightcontroller/core/internal/TopoSwitchServiceImpl.java
+++ b/src/main/java/net/floodlightcontroller/core/internal/TopoSwitchServiceImpl.java
@@ -29,6 +29,7 @@
 	public Iterable<ISwitchObject> getActiveSwitches() {
 		// TODO Auto-generated method stub
 		conn = GraphDBConnection.getInstance("/tmp/cassandra.titan");
+		conn.close(); //Commit to ensure we see latest data
 		return conn.utils().getActiveSwitches(conn);
 	}
 
@@ -36,6 +37,7 @@
 	public Iterable<ISwitchObject> getAllSwitches() {
 		// TODO Auto-generated method stub
 		conn = GraphDBConnection.getInstance("/tmp/cassandra.titan");
+		conn.close(); //Commit to ensure we see latest data
 		return conn.utils().getAllSwitches(conn);
 	}
 
@@ -43,6 +45,7 @@
 	public Iterable<ISwitchObject> getInactiveSwitches() {
 		// TODO Auto-generated method stub
 		conn = GraphDBConnection.getInstance("/tmp/cassandra.titan");
+		conn.close(); //Commit to ensure we see latest data
 		return conn.utils().getInactiveSwitches(conn);
 	}
 
diff --git a/src/main/java/net/floodlightcontroller/flowcache/FlowManager.java b/src/main/java/net/floodlightcontroller/flowcache/FlowManager.java
index 263ee10..21b8b88 100644
--- a/src/main/java/net/floodlightcontroller/flowcache/FlowManager.java
+++ b/src/main/java/net/floodlightcontroller/flowcache/FlowManager.java
@@ -1106,6 +1106,8 @@
     	ArrayList<IFlowPath> flowPathsObjArray = new ArrayList<IFlowPath>();
     	ArrayList<FlowPath> flowPaths = new ArrayList<FlowPath>();
 
+    	conn.endTx(Transaction.COMMIT);
+    	
     	try {
     	    if ((flowPathsObj = conn.utils().getAllFlowPaths(conn)) != null) {
     		log.debug("Get all FlowPaths: found FlowPaths");
diff --git a/src/main/java/net/floodlightcontroller/linkdiscovery/internal/TopoLinkServiceImpl.java b/src/main/java/net/floodlightcontroller/linkdiscovery/internal/TopoLinkServiceImpl.java
index c493887..1bd6421 100644
--- a/src/main/java/net/floodlightcontroller/linkdiscovery/internal/TopoLinkServiceImpl.java
+++ b/src/main/java/net/floodlightcontroller/linkdiscovery/internal/TopoLinkServiceImpl.java
@@ -34,6 +34,7 @@
 	public List<Link> getActiveLinks() {
 		// TODO Auto-generated method stub
 		conn = GraphDBConnection.getInstance("");
+		conn.close(); //Commit to ensure we see latest data
 		Iterable<ISwitchObject> switches = conn.utils().getActiveSwitches(conn);
 		List<Link> links = new ArrayList<Link>(); 
 		for (ISwitchObject sw : switches) {
diff --git a/src/main/java/net/onrc/onos/util/GraphDBConnection.java b/src/main/java/net/onrc/onos/util/GraphDBConnection.java
index d5fe4c6..cc3e0e7 100644
--- a/src/main/java/net/onrc/onos/util/GraphDBConnection.java
+++ b/src/main/java/net/onrc/onos/util/GraphDBConnection.java
@@ -42,7 +42,7 @@
 	   private GraphDBConnection(){ }
 	   
 	   /* Static 'instance' method */
-	   public static GraphDBConnection getInstance(final String conf) {
+	   public static synchronized GraphDBConnection getInstance(final String conf) {
 		   if (GraphDBConnection.configFile == null || GraphDBConnection.configFile.isEmpty()) {
 			   GraphDBConnection.configFile = conf;
 			   log.debug("GraphDBConnection::Setting Config File {}", GraphDBConnection.configFile);
diff --git a/web/ons-demo/css/skin.default.css b/web/ons-demo/css/skin.default.css
index 2b07e33..b860f1d 100644
--- a/web/ons-demo/css/skin.default.css
+++ b/web/ons-demo/css/skin.default.css
@@ -122,9 +122,13 @@
 #actions {
 	padding-right: .25em;
 	padding-left: .25em;
+	padding-top: .25em;
+	padding-bottom: .25em;
 	border-left: 1px solid white;
 	display: -webkit-box;
 	-webkit-box-align: center;
+	-webkit-box-orient: vertical;
+	-webkit-box-pack: center;
 }
 
 #controllers {
@@ -132,6 +136,9 @@
 	background-color: black;
 	margin: .25em;
 	border-radius: 8px;
+	overflow: hidden;
+	display: -webkit-box;
+	-webkit-box-align: center;
 }
 
 #flowChooser .selectedFlow {
@@ -167,12 +174,12 @@
 
 path.flow {
 	fill: none;
-	stroke-width: 8px;
+	stroke-width: 10px;
 	stroke: rgba(255, 255, 255, .35);
 }
 
 path.flow.highlight {
-	stroke-width: 6px;
+	stroke-width: 16px;
 	stroke: rgba(255, 255, 255, .75);
 }
 
@@ -181,7 +188,7 @@
 }
 
 path.iperfdata {
-	fill: #ccc;
+	fill: none;
 	stroke-width: 1px;
 	stroke: #ccc;
 }
@@ -233,17 +240,20 @@
 	padding: .25em;
 	padding-left: 2.5em;
 	position: relative;
+	height: 1.5em;
 	border: 1px solid #444;
 	color: white;
 	position: relative;
 	border-radius: 8px;
+	display: -webkit-box;
+	-webkit-box-align: center;
 }
 
 .controller:hover {
 	border: 1px solid white;
 }
 
-.action, .controller {
+.controller {
 	font-size: 18px;
 }
 
@@ -293,7 +303,7 @@
 text {
 	stroke: none;
 	fill: white;
-	font-size: 22px;
+	font-size: 28px;
 	pointer-events: none;
 }
 
@@ -341,8 +351,8 @@
 .color1 {
 	opacity: .15;
 	pointer-events: none;
-	fill: #EC0033;
-	background-color: #EC0033;
+	fill: #FF0000;
+	background-color: #FF0000;
 }
 
 .color2 {
@@ -362,8 +372,8 @@
 .color4 {
 	opacity: .2;
 	pointer-events: none;
-	fill: #B12C49;
-	background-color: #B12C49;
+	fill: #800080;
+	background-color: #800080;
 }
 
 .color5 {
@@ -376,63 +386,64 @@
 .color6 {
 	opacity: .2;
 	pointer-events: none;
-	fill: #990021;
-	background-color: #990021;
+	fill: #5555FF;
+	background-color: #2222FF;
 }
 
 .color7 {
 	opacity: .2;
 	pointer-events: none;
-	fill: #990021;
-	background-color: #990021;
+	fill: #5555FF;
+	background-color: #2222FF;
 }
 
 .color8 {
 	opacity: .2;
 	pointer-events: none;
-	fill: #A67900;
-	background-color: #A67900;
+	fill: #A0522D;
+	background-color: #A0522D;
 }
 
 .color9 {
 	opacity: .2;
 	pointer-events: none;
-	fill: #F53D65;
-	background-color: #F53D65;
+	fill: #66CDAA;
+	background-color: #66CDAA;
 }
 
 .color10 {
 	opacity: .2;
 	pointer-events: none;
-	fill: #1F0772;
-	background-color: #1F0772;
+	fill: #FFA500;
+	background-color: #FFA500;
 }
 
 .color11 {
 	opacity: .2;
 	pointer-events: none;
-	fill: #F56E8B;
-	background-color: #F56E8B;
+	fill: #FFA500;
+	background-color: #FFA500;
 }
 
 .color12 {
 	opacity: .2;
 	pointer-events: none;
-	fill: #6949D7;
-	background-color: #6949D7;
+	fill: #FF69B4;
+	background-color: #FF69B4;
 }
 
 .action {
-	margin: .25em;
+	margin: .1em;
 	border: 2px solid #AAA;
-	height: 2em;
-	width: 2em;
+	height: 1.5em;
+	width: 5em;
+	font-size: 9px;
 	background-color: #444;
 	display: -webkit-box;
 	-webkit-box-pack: center;
 	-webkit-box-align: center;
 	color: #AAA;
-	border-radius: 50%;
+	border-radius: 0%;
 	-webkit-box-sizing: border-box;
 }
 
@@ -469,8 +480,8 @@
 }
 
 .flowCount {
-	font-size: 24px;
-	fill: rgba(255, 255, 255, .75);
+	font-size: 32px;
+	fill: rgba(255, 255, 255, .99);
 }
 
 #confirm {
diff --git a/web/ons-demo/index.html b/web/ons-demo/index.html
index ed31bee..5c1a650 100644
--- a/web/ons-demo/index.html
+++ b/web/ons-demo/index.html
@@ -20,14 +20,14 @@
 	</div>
 
 	<div id='onos'>
-		<div id='cluster-label'>ONOS Node Cluster</div>
+		<div id='cluster-label'>ONOS Instances</div>
 		<div id='controllers'></div>
 		<div id='actions'>
-			<div id='action-local' class='action'>1</div>
-			<div id='action-reset' class='action'>R</div>
-			<div id='action-scale' class='action'>S</div>
-			<div id='action-all' class='action'>A</div>
-			<div id='action-kill' class='action'>K</div>
+			<!--<div id='action-local' class='action'>1</div>-->
+			<div id='action-reset' class='action'>Reset</div>
+			<div id='action-scale' class='action'>Scale</div>
+			<div id='action-all' class='action'>Backup</div>
+			<div id='action-kill' class='action'>Kill</div>
 		</div>
 	</div>
 
@@ -82,4 +82,4 @@
 <script src="js/app.js"></script>
 </body>
 
-</html>
\ No newline at end of file
+</html>
diff --git a/web/ons-demo/js/init.js b/web/ons-demo/js/init.js
index bf812aa..2df38eb 100644
--- a/web/ons-demo/js/init.js
+++ b/web/ons-demo/js/init.js
@@ -8,7 +8,7 @@
 	});
 
 	d3.select('#action-all').on('click', function () {
-		var prompt = "Switch controllers to all?"
+		var prompt = "Add backup controllers?"
 		doConfirm(prompt, function (result) {
 			if (result) {
 				switchAll();
@@ -44,7 +44,7 @@
 	});
 
 	d3.select('#action-kill').on('click', function () {
-		var prompt = "Kill ONOS node?";
+		var prompt = "Kill ONOS instance?";
 		var options = model.activeControllers;
 		doConfirm(prompt, function (result) {
 			controllerDown(result);
diff --git a/web/ons-demo/js/iperf.js b/web/ons-demo/js/iperf.js
index b1f964c..ee0e305 100644
--- a/web/ons-demo/js/iperf.js
+++ b/web/ons-demo/js/iperf.js
@@ -49,9 +49,9 @@
 					continue;
 				}
 
-				var y = 28 * sample.value/1000000;
-				if (y > 28) {
-					y = 28;
+				var y = 24 * sample.value/1000000;
+				if (y > 24) {
+					y = 24;
 				}
 				if (i == iperfData.samples.length - 1) {
 					d = 'M' + x + ',30';
@@ -123,7 +123,7 @@
 				try {
 					var iperfData = JSON.parse(data);
 
-//				iperfLog(iperfData.timestamp, flow);
+//				console.log('end-time: ' + iperfData['end-time']);
 
 					// if the data is fresh
 					if (!(flow.iperfData.timestamp && iperfData.timestamp != flow.iperfData.timestamp)) {
diff --git a/web/ons-demo/js/map.js b/web/ons-demo/js/map.js
index 256162d..d0eb120 100644
--- a/web/ons-demo/js/map.js
+++ b/web/ons-demo/js/map.js
@@ -386,19 +386,20 @@
 	var coreSwitches = makeSwitchesModel(model.coreSwitches, 'core');
 	var aggregationSwitches = makeSwitchesModel(model.aggregationSwitches, 'aggregation');
 	var edgeSwitches = makeSwitchesModel(model.edgeSwitches, 'edge');
+	var allSwitches = coreSwitches.concat(aggregationSwitches).concat(edgeSwitches);
 
-	var switches = 	switchLayer.selectAll('g')
-		.data(coreSwitches.concat(aggregationSwitches).concat(edgeSwitches), function (d) {
+	var switchSelection = switchLayer.selectAll('g')
+		.data(allSwitches, function (d) {
 			return d.dpid;
 		});
-	switchesEnter(switches)
-	switchesUpdate(switches);
+	switchesEnter(switchSelection)
+	switchesUpdate(switchSelection);
 
 	drawLinkLines();
 
 	drawCoreFlowCounts();
 
-	labelsEnter(switches);
+	labelsEnter(allSwitches);
 }
 
 })();
\ No newline at end of file
diff --git a/web/ons-demo/js/utils.js b/web/ons-demo/js/utils.js
index 1b4c38c..68e567f 100644
--- a/web/ons-demo/js/utils.js
+++ b/web/ons-demo/js/utils.js
@@ -79,7 +79,7 @@
 update the app header using the current model
 ***************************************************************************************************/
 function updateHeader() {
-	d3.select('#lastUpdate').text(new Date());
+	d3.select('#lastUpdate').text(new Date().toLocaleString());
 
 	var activeSwitchCount = 0;
 	model.edgeSwitches.forEach(function (s) {
diff --git a/web/topology_rest.py b/web/topology_rest.py
index 9bb8b9e..6c2ea15 100755
--- a/web/topology_rest.py
+++ b/web/topology_rest.py
@@ -193,7 +193,7 @@
 @app.route("/proxy/gui/iperf/start/<flow_id>/<duration>/<samples>")
 def proxy_iperf_start(flow_id,duration,samples):
   try:
-    command = "curl -s %s/gui/iperf/start/%s/%s/%s" % (ONOS_GUI3_CONTROL_HOST, flow_id, duration, samples)
+    command = "curl -m 40 -s %s/gui/iperf/start/%s/%s/%s" % (ONOS_GUI3_CONTROL_HOST, flow_id, duration, samples)
     print command
     result = os.popen(command).read()
   except:
@@ -262,7 +262,7 @@
 def get_json(url):
   code = 200
   try:
-    command = "curl -s %s" % (url)
+    command = "curl -m 60 -s %s" % (url)
     result = os.popen(command).read()
     parsedResult = json.loads(result)
     if type(parsedResult) == 'dict' and parsedResult.has_key('code'):
@@ -742,7 +742,7 @@
     print "All aggr switches connects to local controller only"
     result=""
     if (TESTBED == "sw"):
-      for i in range(0, len(controllers)):
+      for i in range(1, len(controllers)):
         cmd_string="ssh -i ~/.ssh/onlabkey.pem %s 'cd ONOS/scripts; ./ctrl-local.sh'" % (controllers[i])
         result += os.popen(cmd_string).read()
     else:
@@ -752,7 +752,7 @@
     print "All aggr switches connects to all controllers except for core controller"
     result=""
     if (TESTBED == "sw"):
-      for i in range(0, len(controllers)):
+      for i in range(1, len(controllers)):
         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()
@@ -962,10 +962,12 @@
   command =  "/home/ubuntu/ONOS/web/add_flow.py -m onos %d %s %s %s %s %s matchSrcMac %s matchDstMac %s" % (flow_nr, "dummy", src_dpid, src_port, dst_dpid, dst_port, srcMAC, dstMAC)
   flow_nr += 1
   command1 = "/home/ubuntu/ONOS/web/add_flow.py -m onos %d %s %s %s %s %s matchSrcMac %s matchDstMac %s" % (flow_nr, "dummy", dst_dpid, dst_port, src_dpid, src_port, dstMAC, srcMAC)
-  print command
+  print "add flow: %s, %s" % (command, command1)
   errcode = os.popen(command).read()
   errcode1 = os.popen(command1).read()
-  return errcode+" "+errcode1
+  ret=command+":"+errcode+" "+command1+":"+errcode1
+  print ret 
+  return ret
 
 #* Delete Flow
 #http://localhost:9000/gui/delflow/<flow_id>
@@ -986,9 +988,10 @@
     result = os.popen(command).read()
     if len(result) == 0:
       print "No Flow found"
-      return;
+      return "Flow %s not found" % (flow_id);
   except:
     print "REST IF has issue"
+    return "REST IF has issue"
     exit
 
   parsedResult = json.loads(result)
@@ -1079,9 +1082,9 @@
   except:
     exit
 
-  if len(result) == 0:
+  if re.match("Cannot", result):
     resp = Response(result, status=400, mimetype='text/html')
-    return "no iperf file found (flowid %s)" % flow_id;
+    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