Added path view on GUI
diff --git a/web/js/controller-status.js b/web/js/controller-status.js
index 75cc5cc..1cca38f 100644
--- a/web/js/controller-status.js
+++ b/web/js/controller-status.js
@@ -24,6 +24,15 @@
attr("height", 50);
d3.json(data_source, draw);
+ setInterval(function() {
+ $.ajax({
+ url: data_source,
+ success: function(json) {
+ draw(json)
+ },
+ dataType: "json"
+ });
+ }, 5000);
function draw(json){
// var data = json.data;
@@ -159,15 +168,6 @@
cassandra_rect.exit().remove();
cassandra_text.exit().remove();
- setInterval(function() {
- $.ajax({
- url: data_source,
- success: function(json) {
- draw(json)
- },
- dataType: "json"
- });
- }, 3000);
}
/*
$("#more").click( function() {
diff --git a/web/js/onos-topology.js b/web/js/onos-topology.js
index 8573f7c..000d054 100644
--- a/web/js/onos-topology.js
+++ b/web/js/onos-topology.js
@@ -208,13 +208,31 @@
}
}
}
+ for (var i = 0; i < links.length; i++) {
+ for (var j = 0; j < json.links.length; j++) {
+ if (links[i].target.name == json.nodes[json.links[j].target].name &&
+ links[i].source.name == json.nodes[json.links[j].source].name ){
+ if (links[i].type != json.links[j].type){
+ links[i].type = json.links[j].type;
+ changed = true;
+ }
+ }
+ }
+ }
return changed
}
function draw(force, path, circle, text){
force.stop();
path.enter().append("svg:path")
- .attr("class", function(d) { return "link"; });
+ .attr("class", function(d) { return "link"; })
+ .attr("marker-end", function(d) {
+ if(d.type == 1){
+ return "url(#TriangleRed)";
+ } else {
+ return "url(#Triangle)";
+ }
+ });
circle.enter().append("svg:circle")
.attr("r", radius)
@@ -245,7 +263,7 @@
}
}).attr("stroke-width", function(d) {
if(d.type == 1){
- return "4px";
+ return "2px";
} else {
return "1.5px";
}
@@ -271,13 +289,13 @@
var changed = cdiff(json);
console.log("changed? " + changed);
+ path = svg.selectAll("path").data(links)
+ circle = svg.selectAll("circle").data(nodes);
+ text = svg.selectAll("text").data(nodes);
+ console.log(path)
if (changed){
- path = svg.selectAll("path").data(links)
- circle = svg.selectAll("circle").data(nodes);
- text = svg.selectAll("text").data(nodes);
-
draw(force, path, circle, text);
}
}
@@ -299,8 +317,6 @@
});
}, 3000);
}
-
-
function tick() {
path.attr("d", function(d) {
var dx = d.target.x - d.source.x,
@@ -309,6 +325,26 @@
dr = 0; // 0 for direct line
return "M" + d.source.x + "," + d.source.y + "A" + dr + "," + dr + " 0 0,1 " + d.target.x + "," + d.target.y;
});
+ path.attr("stroke", function(d) {
+ if(d.type == 1){
+ return "red"
+ } else {
+ return "black"
+ }
+ }).attr("stroke-width", function(d) {
+ if(d.type == 1){
+ return "3px";
+ } else {
+ return "1.5px";
+ }
+ }).attr("marker-end", function(d) {
+ if(d.type == 1){
+ return "url(#TriangleRed)";
+ } else {
+ return "url(#Triangle)";
+ }
+ });
+
// circle.attr("cx", function(d) { return d.x; }).attr("cy", function(d) { return d.y; });
circle.attr("transform", function(d) {
x = Math.max(radius, Math.min(width - radius, d.x));
diff --git a/web/onos-topology.html b/web/onos-topology.html
index b0614c9..9d90ea4 100644
--- a/web/onos-topology.html
+++ b/web/onos-topology.html
@@ -2,11 +2,6 @@
<html>
<meta charset="utf-8">
<style>
-path.link {
- fill: none;
- stroke: #666;
- stroke-width: 1.5px;
-}
circle {
stroke: #333;
stroke-width: 1.5px;
@@ -40,6 +35,13 @@
orient="auto">
<path d="M0,-5L10,0L0,5"/>
</marker>
+ <marker id="TriangleRed"
+ viewBox="0 -5 10 10" refX="10" refY="-0.2"
+ markerUnits="strokeWidth"
+ markerWidth="6" markerHeight="6"
+ orient="auto">
+ <path d="M0,-5L10,0L0,5" fill="red" stroke="red"/>
+ </marker>
</defs>
<h1>ONOS Sprint 4 Demo GUI</h1>
<h2>Controller Status</h2>
diff --git a/web/topology_rest.py b/web/topology_rest.py
index 5eaed03..ce6b2d7 100755
--- a/web/topology_rest.py
+++ b/web/topology_rest.py
@@ -162,23 +162,26 @@
try:
v1 = "00:00:00:00:00:0a:0d:00"
+# v1 = "00:00:00:00:00:0d:00:d1"
p1=1
v2 = "00:00:00:00:00:0b:0d:03"
- p1=2
+# v2 = "00:00:00:00:00:0d:00:d3"
+ p2=1
command = "curl -s http://%s:%s/wm/topology/route/%s/%s/%s/%s/json" % (RestIP, RestPort, v1, p1, v2, p2)
result = os.popen(command).read()
parsedResult = json.loads(result)
except:
log_error("No route")
- parsedResult = []
+ parsedResult = {}
- path = [];
- for i, v in enumerate(parsedResult):
- if i < len(parsedResult) - 1:
- sdpid= parsedResult[i]['switch']
- ddpid = parsedResult[i+1]['switch']
- path.append( (sdpid, ddpid))
-
+ path = []
+ if parsedResult.has_key('flowEntries'):
+ flowEntries= parsedResult['flowEntries']
+ for i, v in enumerate(flowEntries):
+ if i < len(flowEntries) - 1:
+ sdpid= flowEntries[i]['dpid']['value']
+ ddpid = flowEntries[i+1]['dpid']['value']
+ path.append( (sdpid, ddpid))
try:
command = "curl -s \'http://%s:%s/wm/core/topology/links/json\'" % (RestIP, RestPort)