blob: a6726bb8feff4d264a5c333fbdbfe498b0ac62d9 [file] [log] [blame]
Paul Greyson8d1c6362013-03-27 13:05:24 -07001/*global d3*/
2
3function callURL(url) {
4 d3.text(url, function (error, result) {
5 if (error) {
6 alert(url + ' : ' + error.status);
7 } else {
8 console.log(result);
9 }
10 });
Paul Greyson4e6dc3a2013-03-27 11:37:14 -070011}
12
13
Paul Greyson8d1c6362013-03-27 13:05:24 -070014var controllerFunctions = {
Paul Greyson13f02b92013-03-28 11:29:35 -070015 linkCmd: function (cmd, link) {
Paul Greyson8d1c6362013-03-27 13:05:24 -070016 var url = '/proxy/gui/link/' + [cmd, link['src-switch'], link['src-port'], link['dst-switch'], link['dst-port']].join('/');
17 callURL(url);
18
19 },
Paul Greyson13f02b92013-03-28 11:29:35 -070020 switchCmd: function (cmd, s) {
Paul Greyson8d1c6362013-03-27 13:05:24 -070021 var url = '/proxy/gui/switch/' + [cmd, s.dpid].join('/');
22 callURL(url);
Paul Greyson2913af82013-03-27 14:53:17 -070023 },
Paul Greyson13f02b92013-03-28 11:29:35 -070024 ctrlCmd: function (cmd, c) {
Paul Greyson2913af82013-03-27 14:53:17 -070025 var url = '/proxy/gui/controller/' + [cmd, c].join('/');
26 callURL(url);
Paul Greyson13f02b92013-03-28 11:29:35 -070027 },
28 addFlowCmd: function (src, dst) {
29 alert('add flow')
30 },
31 delFlowCmd: function (flow) {
32 alert('delete flow')
Paul Greyson8d1c6362013-03-27 13:05:24 -070033 }
34};
35
Paul Greyson13f02b92013-03-28 11:29:35 -070036// http://gui3.onlab.us:8081/gui/addflow/<src_dpid>/<src_port>/<dst_dpid>/<dst_port>/<srcMAC>/<dstMAC>
37// http://gui3.onlab.us:8081/gui/delflow/<flow_id>
Paul Greyson4e6dc3a2013-03-27 11:37:14 -070038
Paul Greyson8d1c6362013-03-27 13:05:24 -070039function linkUp(link) {
Paul Greyson13f02b92013-03-28 11:29:35 -070040 controllerFunctions.linkCmd('up', link);
Paul Greyson4e6dc3a2013-03-27 11:37:14 -070041}
42
Paul Greyson8d1c6362013-03-27 13:05:24 -070043function linkDown(link) {
Paul Greyson13f02b92013-03-28 11:29:35 -070044 controllerFunctions.linkCmd('down', link);
Paul Greyson8d1c6362013-03-27 13:05:24 -070045}
46
47function switchUp(s) {
Paul Greyson13f02b92013-03-28 11:29:35 -070048 controllerFunctions.switchCmd('up', s);
Paul Greyson8d1c6362013-03-27 13:05:24 -070049}
50
51function switchDown(s) {
Paul Greyson13f02b92013-03-28 11:29:35 -070052 controllerFunctions.switchCmd('down', s);
Paul Greyson4e6dc3a2013-03-27 11:37:14 -070053}
54
Paul Greyson2913af82013-03-27 14:53:17 -070055function controllerUp(c) {
Paul Greyson13f02b92013-03-28 11:29:35 -070056 controllerFunctions.ctrlCmd('up', c);
Paul Greyson2913af82013-03-27 14:53:17 -070057}
58
59function controllerDown(c) {
Paul Greyson13f02b92013-03-28 11:29:35 -070060 controllerFunctions.ctrlCmd('down', c);
Paul Greyson2913af82013-03-27 14:53:17 -070061}
62
Paul Greyson13f02b92013-03-28 11:29:35 -070063function addFlow(src, dst) {
64 controllerFunctions.addFlowCmd(src, dst);
Paul Greyson4e6dc3a2013-03-27 11:37:14 -070065}
66
Paul Greyson13f02b92013-03-28 11:29:35 -070067function deleteFlow(flow) {
68 controllerFunctions.delFlowCmd(flow);
Paul Greyson4e6dc3a2013-03-27 11:37:14 -070069}