hooking up to real test bed
diff --git a/web/ons-demo/css/skin.default.css b/web/ons-demo/css/skin.default.css
index ea8d0b9..c81acb8 100644
--- a/web/ons-demo/css/skin.default.css
+++ b/web/ons-demo/css/skin.default.css
@@ -59,7 +59,6 @@
padding: .25em;
}
-
#logo {
height: 50px;
}
@@ -94,6 +93,7 @@
visibility: hidden
}
+.color0-selected .color0,
.color1-selected .color1,
.color2-selected .color2,
.color3-selected .color3,
@@ -109,74 +109,80 @@
opacity: 1;
}
+.color0 {
+ opacity: .25;
+ fill: #444;
+ background-color: #444;
+}
+
.color1 {
- opacity: .35;
+ opacity: .25;
fill: #EC0033;
background-color: #EC0033;
}
.color2 {
- opacity: .35;
+ opacity: .25;
fill: #FFBA00;
background-color: #FFBA00;
}
.color3 {
- opacity: .35;
+ opacity: .25;
fill: #3714B0;
background-color: #3714B0;
}
.color4 {
- opacity: .35;
+ opacity: .25;
fill: #B12C49;
background-color: #B12C49;
}
.color5 {
- opacity: .35;
+ opacity: .25;
fill: #402C84;
background-color: #402C84;
}
.color6 {
- opacity: .35;
+ opacity: .25;
fill: #990021;
background-color: #990021;
}
.color7 {
- opacity: .35;
+ opacity: .25;
fill: #990021;
background-color: ;
}
.color8 {
- opacity: .35;
+ opacity: .25;
fill: #A67900;
background-color: #A67900;
}
.color9 {
- opacity: .35;
+ opacity: .25;
fill: #F53D65;
background-color: #F53D65;
}
.color10 {
- opacity: .35;
+ opacity: .25;
fill: #1F0772;
background-color: #1F0772;
}
.color11 {
- opacity: .35;
+ opacity: .25;
fill: #F56E8B;
background-color: #F56E8B;
}
.color12 {
- opacity: .35;
+ opacity: .25;
fill: #6949D7;
background-color: #6949D7;
}
diff --git a/web/ons-demo/data/configuration.json b/web/ons-demo/data/configuration.json
index bf5c855..ab304eb 100644
--- a/web/ons-demo/data/configuration.json
+++ b/web/ons-demo/data/configuration.json
@@ -5,16 +5,23 @@
"00:00:20:4e:7f:51:8a:35",
"00:00:00:00:00:00:ba:12",
"00:00:00:00:ba:5e:ba:13",
- "00:00:00:16:97:08:9a:46"
+ "00:00:00:16:97:08:9a:46",
+
+ "00:00:0e:46:7a:3a:69:45",
+ "00:00:16:00:9d:ff:8f:4f",
+ "00:00:5e:80:3f:db:d7:4d",
+ "00:00:82:4f:75:82:a3:4b",
+ "00:00:36:7d:90:c9:4f:49",
+ "00:00:4e:27:27:d7:48:45"
],
"aggregation": [
- "00:00:00:00:00:00:01:00",
- "00:00:00:00:00:00:02:00",
- "00:00:00:00:00:00:03:00",
- "00:00:00:00:00:00:04:00",
- "00:00:00:00:00:00:05:00",
- "00:00:00:00:00:00:06:00",
- "00:00:00:00:00:00:07:00",
- "00:00:00:00:00:00:08:00"
+ "00:00:00:00:00:00:01:01",
+ "00:00:00:00:00:00:02:01",
+ "00:00:00:00:00:00:03:01",
+ "00:00:00:00:00:00:04:01",
+ "00:00:00:00:00:00:05:01",
+ "00:00:00:00:00:00:06:01",
+ "00:00:00:00:00:00:07:01",
+ "00:00:00:00:00:00:08:01"
]
}
\ No newline at end of file
diff --git a/web/ons-demo/data/controllers.json b/web/ons-demo/data/controllers.json
new file mode 100644
index 0000000..db2f5ad
--- /dev/null
+++ b/web/ons-demo/data/controllers.json
@@ -0,0 +1,10 @@
+[
+ "onosgui1",
+ "onosgui2",
+ "onosgui3",
+ "onosgui4",
+ "onosgui5",
+ "onosgui6",
+ "onosgui7",
+ "onosgui8"
+]
\ No newline at end of file
diff --git a/web/ons-demo/index.html b/web/ons-demo/index.html
index ef2cd65..eb3d2c0 100644
--- a/web/ons-demo/index.html
+++ b/web/ons-demo/index.html
@@ -5,6 +5,7 @@
<link rel="stylesheet" href="css/skin.default.css" type="text/css"/>
<script src="js/d3.v3.js" charset="utf-8"></script>
<script src="js/async.js"></script>
+ <script src="js/utils.js"></script>
<script src="js/model.js"></script>
</head>
@@ -24,8 +25,8 @@
<div class='header'>
<div id='status'>
<div class='status'><span class='static'>Last updated:</span><span id='lastUpdate' class='dynamic'>Mon Mar 18 11:11:12 PDT 2013</span></div>
- <div class='status'><span class='dynamic' id='activeFlows'>4000</span><span class='static'>Flows</span></div>
- <div class='status'><span class='dynamic' id='activeSwitches'>200</span><span class='static'>Active Switches</span></div>
+ <div class='status'><span class='dynamic' id='activeFlows'>????</span><span class='static'>Flows</span></div>
+ <div class='status'><span class='dynamic' id='activeSwitches'>???</span><span class='static'>Active Switches</span></div>
</div>
<div id='traceButton' class='button'>Trace</div>
</div>
diff --git a/web/ons-demo/js/app.js b/web/ons-demo/js/app.js
index 068eb79..3eb2e7d 100644
--- a/web/ons-demo/js/app.js
+++ b/web/ons-demo/js/app.js
@@ -90,7 +90,11 @@
// rings[1].angles[i] = k * i;
var range = aggRanges[s.dpid];
- rings[1].angles[i] = (range.min + range.max)/2;
+ if (range) {
+ rings[1].angles[i] = (range.min + range.max)/2;
+ } else {
+ rings[1].angles[i] = 0;
+ }
});
// arrange core switches at equal increments
@@ -213,11 +217,18 @@
var controllers = d3.select('#controllerList').selectAll('.controller').data(model.controllers);
controllers.enter().append('div')
.attr('class', function (d) {
- var color = controllerColorMap[d];
- if (!color) {
- color = controllerColorMap[d] = colors.pop();
+
+ var color = 'color0';
+ if (model.activeControllers.indexOf(d) != -1) {
+ color = controllerColorMap[d];
+ if (!color) {
+ color = controllerColorMap[d] = colors.pop();
+ }
+ } else {
+ controllerColorMap[d] = color;
}
- return 'controller ' + color;
+ var className = 'controller ' + color;
+ return className;
});
controllers.text(function (d) {
return d;
@@ -236,7 +247,9 @@
var oldModel;
function sync(svg) {
+ var d = Date.now();
updateModel(function (newModel) {
+ console.log('Update time: ' + (Date.now() - d)/1000 + 's');
if (!oldModel && JSON.stringify(oldModel) != JSON.stringify(newModel)) {
updateControllers(newModel);
diff --git a/web/ons-demo/js/model.js b/web/ons-demo/js/model.js
index ad45469..82e66c1 100644
--- a/web/ons-demo/js/model.js
+++ b/web/ons-demo/js/model.js
@@ -5,8 +5,9 @@
edgeSwitches: [],
aggregationSwitches: [],
coreSwitches: [],
- flows: results.flows,
+ flows: [],
controllers: results.controllers,
+ activeControllers: results.activeControllers,
links: results.links
}
@@ -48,41 +49,73 @@
return model;
}
+var urls = {
+ links: '/wm/core/topology/links/json',
+ switches: '/wm/core/topology/switches/all/json',
+ flows: '/wm/flow/getall/json',
+ activeControllers: '/wm/registry/controllers/json',
+ controllers: '/data/controllers.json',
+ mapping: '/wm/registry/switches/json',
+ configuration: 'data/configuration.json'
+}
+
+var mockURLs = {
+ links: 'data/wm_core_topology_links_json.json',
+ switches: 'data/wm_core_topology_switches_all_json.json',
+ flows: 'data/wm_flow_getall_json.json',
+ activeControllers: 'data/wm_registry_controllers_json.json',
+ controllers: '/data/controllers.json',
+ mapping: 'data/wm_registry_switches_json.json',
+ configuration: 'data/configuration.json'
+}
+
+var proxyURLs = {
+ links: '/proxy/wm/core/topology/links/json',
+ switches: '/proxy/wm/core/topology/switches/all/json',
+ flows: '/proxy/wm/flow/getall/json',
+ activeControllers: '/proxy/wm/registry/controllers/json',
+ controllers: 'data/controllers.json',
+ mapping: '/proxy/wm/registry/switches/json',
+ configuration: 'data/configuration.json'
+}
+
+var params = parseURLParameters();
+if (params.mock) {
+ urls = mockURLs;
+}
+if (params.proxy) {
+ urls = proxyURLs;
+}
+
+function makeRequest(url) {
+ return function (cb) {
+ d3.json(url, function (error, result) {
+ if (error) {
+ error = url + ' : ' + error.status;
+ }
+
+ cb(error, result);
+ });
+ }
+}
+
+
function updateModel(cb) {
async.parallel({
- links: function(cb) {
- d3.json('data/wm_core_topology_links_json.json', function (error, result) {
- cb(error, result);
- });
- },
- switches: function(cb) {
- d3.json('data/wm_core_topology_switches_all_json.json', function (error, result) {
- cb(error, result);
- });
- },
- flows: function(cb) {
- d3.json('data/wm_flow_getall_json.json', function (error, result) {
- cb(error, result);
- });
- },
- controllers: function(cb) {
- d3.json('data/wm_registry_controllers_json.json', function (error, result) {
- cb(error, result);
- });
- },
- mapping: function(cb) {
- d3.json('data/wm_registry_switches_json.json', function (error, result) {
- cb(error, result);
- });
- },
- configuration: function(cb) {
- d3.json('data/configuration.json', function (error, result) {
- cb(error, result);
- });
- },
+ links: makeRequest(urls.links),
+ switches: makeRequest(urls.switches),
+ controllers: makeRequest(urls.controllers),
+ activeControllers: makeRequest(urls.activeControllers),
+ mapping: makeRequest(urls.mapping),
+ configuration: makeRequest(urls.configuration)
+// flows: makeRequest(urls.flows),
},
function(err, results) {
- var model = toD3(results);
- cb(model);
+ if (!err) {
+ var model = toD3(results);
+ cb(model);
+ } else {
+ alert(JSON.stringify(err));
+ }
});
}
\ No newline at end of file
diff --git a/web/ons-demo/js/utils.js b/web/ons-demo/js/utils.js
new file mode 100644
index 0000000..17100b1
--- /dev/null
+++ b/web/ons-demo/js/utils.js
@@ -0,0 +1,14 @@
+function parseURLParameters() {
+ var parameters = {};
+
+ var search = location.href.split('?')[1];
+ if (search) {
+ search.split('&').forEach(function (param) {
+ var key = param.split('=')[0];
+ var value = param.split('=')[1];
+ parameters[key] = decodeURIComponent(value);
+ });
+ }
+
+ return parameters;
+}
\ No newline at end of file
diff --git a/web/restapi2.py b/web/restapi2.py
index 93404b4..a8188d8 100755
--- a/web/restapi2.py
+++ b/web/restapi2.py
@@ -53,6 +53,77 @@
return response
+## PROXY API (allows development where the webui is served from someplace other than the ONOS_HOST)##
+ONOS_HOST="http://gui3.onlab.us:8080"
+
+@app.route("/proxy/wm/core/topology/switches/all/json")
+def switches():
+ try:
+ command = "curl -s %s/wm/core/topology/switches/all/json" % (ONOS_HOST)
+ print command
+ result = os.popen(command).read()
+ except:
+ print "REST IF has issue"
+ exit
+
+ resp = Response(result, status=200, mimetype='application/json')
+ return resp
+
+@app.route("/proxy/wm/core/topology/links/json")
+def links():
+ try:
+ command = "curl -s %s/wm/core/topology/links/json" % (ONOS_HOST)
+ print command
+ result = os.popen(command).read()
+ except:
+ print "REST IF has issue"
+ exit
+
+ resp = Response(result, status=200, mimetype='application/json')
+ return resp
+
+@app.route("/proxy/wm/flow/getall/json")
+def flows():
+ try:
+ command = "curl -s %s/wm/flow/getall/json" % (ONOS_HOST)
+ print command
+ result = os.popen(command).read()
+ except:
+ print "REST IF has issue"
+ exit
+
+ resp = Response(result, status=200, mimetype='application/json')
+ return resp
+
+@app.route("/proxy/wm/registry/controllers/json")
+def registry_controllers():
+ try:
+ command = "curl -s %s/wm/registry/controllers/json" % (ONOS_HOST)
+ print command
+ result = os.popen(command).read()
+ except:
+ print "REST IF has issue"
+ exit
+
+ resp = Response(result, status=200, mimetype='application/json')
+ return resp
+
+@app.route("/proxy/wm/registry/switches/json")
+def registry_switches():
+ try:
+ command = "curl -s %s/wm/registry/switches/json" % (ONOS_HOST)
+ print command
+ result = os.popen(command).read()
+ except:
+ print "REST IF has issue"
+ exit
+
+ resp = Response(result, status=200, mimetype='application/json')
+ return resp
+
+
+
+
## REST API ##
#@app.route("/wm/topology/links/json")
#def links():