Various updates.

This commit is contained in:
Julien Fontanet 2013-10-04 15:29:22 +02:00
parent 424c6403e1
commit 0472c22b08
2 changed files with 22 additions and 20 deletions

View File

@ -549,19 +549,21 @@ Api.fn.xo = {
Api.fn.xapi = { Api.fn.xapi = {
'__catchAll': function (session, req) { '__catchAll': function (session, req) {
var RE = /^xapi\.(pool|host|vm|network|sr|vdi|pif|vif)\.getAll$/; var RE = /^xapi\.(.*)\.getAll$/;
var match; var match = req.method.match(RE);
if (!(match = req.method.match(RE))) var collection;
if (!match || !(collection = this.xo.xobjs[match[1]]))
{ {
throw Api.err.INVALID_METHOD; throw Api.err.INVALID_METHOD;
} }
var xobjs = this.xo.xobjs;
var collection = xobjs[match[1]] || xobjs[match[1].toUpperCase()];
return collection.get(); return collection.get();
}, },
'getClasses': function () {
return this.xo.xclasses;
},
'vm': { 'vm': {
'pause': function (session, req) { 'pause': function (session, req) {
var p_id = req.params.id; var p_id = req.params.id;

View File

@ -315,9 +315,8 @@ Xo.prototype.start = function (cfg) {
xo.computeStats(); xo.computeStats();
return function loop() { return function loop() {
return xapi.call('event.next').then(function (event) { return xapi.call('event.next').then(function (events) {
event = event[0]; // @todo Handle multiple events. _.each(events, function (event) {
var collection = xobjs[xclasses_map[event.class]]; var collection = xobjs[xclasses_map[event.class]];
if (collection) if (collection)
{ {
@ -330,9 +329,10 @@ Xo.prototype.start = function (cfg) {
// @todo Handle operation types. // @todo Handle operation types.
collection.add(event.snapshot, {'replace': true}); collection.add(event.snapshot, {'replace': true});
xo.computeStats();
} }
});
xo.computeStats();
return loop(); return loop();
}).fail(function (error) { }).fail(function (error) {
if ('SESSION_NOT_REGISTERED' === error[0]) if ('SESSION_NOT_REGISTERED' === error[0])