1 var opencloud_data = [];
2 var opencloud_data_received = false;
4 function updateOpenCloud(onLoaded) {
5 $.ajax({url: "/admin/shelldata",
8 success: function(data) {
10 if (!opencloud_data_received) {
11 opencloud_data_received = true;
16 // do this again in 30 seconds
17 setTimeout(function() {updateOpenCloud(onLoaded)}, 10000);
20 console.log("something went wrong. trying again");
21 // do this again in 30 seconds
22 setTimeout(function() {updateOpenCloud(onLoaded)}, 10000);
27 function OpenCloudModel(name) {
28 this.all = function() { return opencloud_data[name]; };
30 this.match = function(filterDict,obj) {
31 for (var k in filterDict) {
32 if (obj[k] == filterDict[k]) {
39 this.filter = function(filterDict) {
42 for (var k in all_objs) {
44 if (this.match(filterDict, obj)) {
51 this.get = function(filterDict) {
52 return this.filter(filterDict)[0];
55 this.__str__ = function() { return '["all", "filter", "get"]' };
59 // this.listAll = function() { return opencloud_data["slices"] }
60 // this.__str__ = function() { return '["listAll"]'; }
63 function OpenCloud() {
64 this.slices = new OpenCloudModel("slices");
65 this.slivers = new OpenCloudModel("slivers");
66 this.nodes = new OpenCloudModel("nodes");
67 this.sites = new OpenCloudModel("sites");
68 this.__str__ = function() { return '["slices", "slivers", "nodes", "sites"]'; }