hooking up to real test bed
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