updates to shell
diff --git a/planetstack/core/static/shell/constants.js b/planetstack/core/static/shell/constants.js
index dd267e2..5231cda 100644
--- a/planetstack/core/static/shell/constants.js
+++ b/planetstack/core/static/shell/constants.js
@@ -36,4 +36,4 @@
var JavascriptClassNames = ['Array', 'String', 'Object']
-var MongoKeywords = ['help','tutorial','next','back','t0','t1','t2'];
+var MongoKeywords = ['help','tutorial','next','back','t0','t1','t2','t3','t4'];
diff --git a/planetstack/core/static/shell/opencloud.js b/planetstack/core/static/shell/opencloud.js
index 52c9e5c..7166abf 100644
--- a/planetstack/core/static/shell/opencloud.js
+++ b/planetstack/core/static/shell/opencloud.js
@@ -24,12 +24,46 @@
});
}
-function Slices() {
- this.listAll = function() { return opencloud_data["slices"] }
- this.__str__ = function() { return '["listAll"]'; }
+function OpenCloudModel(name) {
+ this.all = function() { return opencloud_data[name]; };
+
+ this.match = function(filterDict,obj) {
+ for (var k in filterDict) {
+ if (obj[k] == filterDict[k]) {
+ return true;
+ }
+ }
+ return false;
+ };
+
+ this.filter = function(filterDict) {
+ result = []
+ all_objs = this.all()
+ for (var k in all_objs) {
+ obj = all_objs[k];
+ if (this.match(filterDict, obj)) {
+ result.push(obj);
+ }
+ }
+ return result;
+ };
+
+ this.get = function(filterDict) {
+ return this.filter(filterDict)[0];
+ };
+
+ this.__str__ = function() { return '["all", "filter", "get"]' };
}
+//function Slices() {
+// this.listAll = function() { return opencloud_data["slices"] }
+// this.__str__ = function() { return '["listAll"]'; }
+//}
+
function OpenCloud() {
- this.slices = new Slices()
- this.__str__ = function() { return '["slices"]'; }
+ this.slices = new OpenCloudModel("slices");
+ this.slivers = new OpenCloudModel("slivers");
+ this.nodes = new OpenCloudModel("nodes");
+ this.sites = new OpenCloudModel("sites");
+ this.__str__ = function() { return '["slices", "slivers", "nodes", "sites"]'; }
};
diff --git a/planetstack/core/static/shell/opencloud_shell.js b/planetstack/core/static/shell/opencloud_shell.js
index ab5a355..861cd10 100644
--- a/planetstack/core/static/shell/opencloud_shell.js
+++ b/planetstack/core/static/shell/opencloud_shell.js
@@ -116,7 +116,7 @@
this._rawCommand = "";
this._commandStack = 0;
this._tutorialPtr = 0;
- this._tutorialMax = 2;
+ this._tutorialMax = 4;
this._mongo = {};
this._mongo.test = [];
@@ -249,7 +249,11 @@
// help command
_help: function() {
return PTAG('HELP') +
- PTAG('opencloud.slices.listAll() get all slices');
+ PTAG('opencloud list opencloud API object types') +
+ PTAG('opencloud.slices list methods to can call on slices') +
+ PTAG('opencloud.slices.all() get all slices') +
+ PTAG('opencloud.slices.filter({key: "value"}) filter using dictionary') +
+ PTAG('opencloud.slices.get({key: "value"})) get using dictionary')
},
@@ -296,9 +300,30 @@
_t2: function() {
this._tutorialPtr = 2;
- return PTAG('2. List some slices') +
- PTAG('Type this:') +
- PTAG(' opencloud.slices.listAll();');
+ return PTAG('2. List some objects') +
+ PTAG('Try these:') +
+ PTAG(' opencloud.slices.all();') +
+ PTAG(' opencloud.slivers.all();') +
+ PTAG(' opencloud.sites.all();') +
+ PTAG(' opencloud.nodes.all();');
+
+ },
+
+ _t3: function() {
+ this._tutorialPtr = 3;
+ return PTAG('3. Filter some objects') +
+ PTAG('Try these:') +
+ PTAG(' opencloud.slices.get({name: "HyperCache"});');
+ PTAG(' opencloud.nodes.filter({site_id: opencloud.sites.get({name: "Princeton"})["id"]});');
+
+ },
+
+ _t4: function() {
+ this._tutorialPtr = 4;
+ return PTAG('4. Available OpenCloud objects and methods') +
+ PTAG('Try these:') +
+ PTAG(' opencloud;') +
+ PTAG(' opencloud.nodes;');
},
@@ -320,6 +345,10 @@
return this._t1;
case 't2':
return this._t2;
+ case 't3':
+ return this._t3;
+ case 't4':
+ return this._t4;
}
}
}