Merge branch 'master' of github.com:OPENNETWORKINGLAB/ONOS
diff --git a/web/js/controller-status.js b/web/js/controller-status.js
index 509b344..75cc5cc 100644
--- a/web/js/controller-status.js
+++ b/web/js/controller-status.js
@@ -8,7 +8,6 @@
var width = (barWidth + 10) * 4
var height = 50;
-
var Servers = d3.select("#servers").
append("svg:svg").
attr("width", 800).
@@ -45,6 +44,19 @@
append("svg:text").
attr("x", function(datum, index) { return x(index); }).
attr("y", function(datum) { return 20; }).
+ attr("fill", function(datum, index) {
+ if (index == 0){
+ return "red"
+ }else if (index == 1){
+ return "blue"
+ }else if (index == 2){
+ return "green"
+ }else if (index == 3){
+ return "orange"
+ }else{
+ return "black"
+ }
+ }).
text(function(datum) { return datum.name; });
controller_rect.
@@ -54,7 +66,19 @@
attr("y", function(datum) { return height - y(datum.onos); }).
attr("height", function(datum) { return y(datum.onos); }).
attr("width", barWidth).
- attr("fill", "#2d578b");
+ attr("fill", function(datum, index) {
+ if (index == 0){
+ return "red"
+ }else if (index == 1){
+ return "blue"
+ }else if (index == 2){
+ return "green"
+ }else if (index == 3){
+ return "orange"
+ }else{
+ return "black"
+ }
+ });
controller_text.
enter().
@@ -85,12 +109,25 @@
attr("width", barWidth).
attr('fill', 'white');
+
controller_rect.
attr("x", function(datum, index) { return x(index); }).
attr("y", function(datum) { return height - y(datum.onos); }).
attr("height", function(datum) { return y(datum.onos); }).
attr("width", barWidth).
- attr("fill", "#2d578b");
+ attr("fill", function(datum, index) {
+ if (index == 0){
+ return "red"
+ }else if (index == 1){
+ return "blue"
+ }else if (index == 2){
+ return "green"
+ }else if (index == 3){
+ return "orange"
+ }else{
+ return "black"
+ }
+ });
controller_text.
text(function(){return "ONOS"}).
@@ -121,7 +158,18 @@
controller_text.exit().remove();
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() {
$.ajax({
url: 'http://gui.onlab.us:8080/controller_status1',
@@ -140,6 +188,6 @@
dataType: "json"
});
});
-
+*/
}
diff --git a/web/js/onos-topology.js b/web/js/onos-topology.js
index 57016c4..8573f7c 100644
--- a/web/js/onos-topology.js
+++ b/web/js/onos-topology.js
@@ -1,9 +1,10 @@
function gui(data_source){
var width = 960,
height = 500;
+ var radius = 8;
var color = d3.scale.category20();
- var svg = d3.select("body").append("svg:svg")
+ var svg = d3.select("#topology").append("svg:svg")
.attr("width", width)
.attr("height", height);
@@ -216,12 +217,12 @@
.attr("class", function(d) { return "link"; });
circle.enter().append("svg:circle")
- .attr("r", 8)
+ .attr("r", radius)
.call(node_drag);
// .call(force.drag);
text.enter().append("svg:text")
- .attr("x", 8)
+ .attr("x", radius)
.attr("y", ".31em")
.text(function(d) { return d.name.split(":")[5] + d.name.split(":")[6] + d.name.split(":")[7] });
@@ -310,13 +311,17 @@
});
// circle.attr("cx", function(d) { return d.x; }).attr("cy", function(d) { return d.y; });
circle.attr("transform", function(d) {
- return "translate(" + d.x + "," + d.y + ")";
+ x = Math.max(radius, Math.min(width - radius, d.x));
+ y = Math.max(radius, Math.min(height - radius, d.y));
+// return "translate(" + d.x + "," + d.y + ")";
+ return "translate(" + x + "," + y + ")";
})
+
circle.attr("fill", function(d) {
- if (d.group == 1){return "red";}
+ ; if (d.group == 1){return "red";}
else if (d.group == 2){return "blue";}
else if (d.group == 3){return "green";}
- else if (d.group == 3){return "orange";}
+ else if (d.group == 4){return "orange";}
else{ return "gray"; }
});
// text.attr("x", function(d) { return d.x; }).attr("y", function(d) { return d.y; });
diff --git a/web/onos-topology.html b/web/onos-topology.html
index 6e13034..b0614c9 100644
--- a/web/onos-topology.html
+++ b/web/onos-topology.html
@@ -25,8 +25,10 @@
<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
</head>
<body>
+<!--
<button id="more">more</button>
<button id="less">less</button>
+--!>
<svg width="4in" height="2in"
viewBox="0 0 4000 2000" version="1.1"
xmlns="http://www.w3.org/2000/svg">
@@ -39,12 +41,16 @@
<path d="M0,-5L10,0L0,5"/>
</marker>
</defs>
+<h1>ONOS Sprint 4 Demo GUI</h1>
+<h2>Controller Status</h2>
<div id="servers"></div>
<div id="onos-status"></div>
<div id="cassandra-status"></div>
+<h2>Topology View</h2>
+<div id="topology"></div>
<script type="text/javascript" src="js/controller-status.js"></script>
<script type="text/javascript">
-controller_status("http://gui.onlab.us:8080/topology");
+controller_status("http://gui.onlab.us:8080/controller_status");
gui("http://gui.onlab.us:8080/topology");
</script>
</svg>
diff --git a/web/topology_rest.py b/web/topology_rest.py
index 1b4fdca..16a0f24 100755
--- a/web/topology_rest.py
+++ b/web/topology_rest.py
@@ -498,6 +498,26 @@
pp.pprint(resp)
return resp
+@app.route("/controller_status")
+def controller_status():
+ onos_check="ssh -i ~/.ssh/onlabkey.pem %s ONOS/start-onos.sh status | awk '{print $1}'"
+ #cassandra_check="ssh -i ~/.ssh/onlabkey.pem %s ONOS/start-cassandra.sh status"
+
+ cont_status=[]
+ for i in controllers:
+ status={}
+ onos=os.popen(onos_check % i).read()[:-1]
+ status["name"]=i
+ status["onos"]=onos
+ status["cassandra"]=1
+ cont_status.append(status)
+
+ js = json.dumps(cont_status)
+ resp = Response(js, status=200, mimetype='application/json')
+ pp.pprint(js)
+ return resp
+
+
if __name__ == "__main__":
if len(sys.argv) > 1 and sys.argv[1] == "-d":