blob: 5cbb526531c051a6f1d402b8970ba6fb4073dd81 [file] [log] [blame]
Pankaj Berdec4ae4b82013-01-12 09:56:47 -08001/*
2 Copyright 2012 IBM
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16
17window.Status = Backbone.Model.extend({
18 defaults: {
19 host: 'localhost',
20 ofport: 6633,
21 uptime: 'unknown',
22 free: 0,
23 total: 0,
24 healthy: 'unknown',
25 modules: [],
26 moduleText: ''
27 },
28
29 initialize:function () {
30 var self = this;
31 console.log("fetching controller status");
32 $.ajax({
Naoki Shiota862cc3b2013-12-13 15:42:50 -080033 url:hackBase + "/wm/floodlight/core/health/json",
Pankaj Berdec4ae4b82013-01-12 09:56:47 -080034 dataType:"json",
35 success:function (data) {
36 console.log("fetched controller status: health");
37 self.set(data);
38 // console.log(self.toJSON());
39 }
40 });
41 $.ajax({
Naoki Shiota862cc3b2013-12-13 15:42:50 -080042 url:hackBase + "/wm/floodlight/core/system/uptime/json",
Pankaj Berdec4ae4b82013-01-12 09:56:47 -080043 dataType:"json",
44 success:function (data) {
45 console.log("fetched controller status: uptime");
46 self.set({uptime:(Math.round(data.systemUptimeMsec / 1000) + ' s')});
47 // console.log(self.toJSON());
48 }
49 });
50 $.ajax({
Naoki Shiota862cc3b2013-12-13 15:42:50 -080051 url:hackBase + "/wm/floodlight/core/memory/json",
Pankaj Berdec4ae4b82013-01-12 09:56:47 -080052 dataType:"json",
53 success:function (data) {
54 console.log("fetched controller status: memory");
55 self.set(data);
56 // console.log(self.toJSON());
57 }
58 });
59 $.ajax({
Naoki Shiota862cc3b2013-12-13 15:42:50 -080060 url:hackBase + "/wm/floodlight/core/module/loaded/json",
Pankaj Berdec4ae4b82013-01-12 09:56:47 -080061 dataType:"json",
62 success:function (data) {
63 console.log("fetched controller status: modules loaded");
64 // console.log(data);
65 self.set({modules:_.keys(data)});
66 self.set({moduleText:_.reduce(_.keys(data), function(s, m)
67 {return s+m.replace("net.floodlightcontroller", "n.f")+", "}, '')});
68 }
69 });
70
71 }
72
73});