Various fixes.

This commit is contained in:
Julien Fontanet 2013-12-09 18:19:55 +01:00
parent 5208d3d091
commit 26aaf5f53c
2 changed files with 19 additions and 4 deletions

View File

@ -283,7 +283,7 @@ class MappedCollection
getAll: -> getAll: ->
items = {} items = {}
for ruleName, ruleItems in @_byRule for ruleName, ruleItems of @_byRule
rule = @_rules[ruleName] rule = @_rules[ruleName]
# Items of private rules are not exported. # Items of private rules are not exported.
@ -317,7 +317,7 @@ class MappedCollection
$_.extend(itemsToRemove, @_byKey) $_.extend(itemsToRemove, @_byKey)
$_.each items, (value, key) => $_.each items, (value, key) =>
key = @_key key key = @_key value, key
# If the item already existed. # If the item already existed.
if @_byKey[key] if @_byKey[key]

View File

@ -227,7 +227,12 @@ Xo.prototype.start = function (data) {
// 'VMPP', // 'VMPP',
// 'VTPM', // 'VTPM',
]; ];
xo.xobjs = createMappedCollection(require('./spec'));
// XAPI uses both opaque references and UUIDs, XO uses UUIDs where
// possible.
var refsToUUIDs = {};
xo.xobjs = createMappedCollection(require('./spec')(refsToUUIDs));
var connect = function (server) { var connect = function (server) {
var pool_id = server.id; var pool_id = server.id;
@ -241,9 +246,14 @@ Xo.prototype.start = function (data) {
return Q.all(_.map(xclasses, function (xclass) { return Q.all(_.map(xclasses, function (xclass) {
return xapi.call(xclass +'.get_all_records') return xapi.call(xclass +'.get_all_records')
.then(function (records) { .then(function (records) {
_.each(records, function (record) { _.each(records, function (record, ref) {
record.$type = xclass; record.$type = xclass;
record.$pool = pool_id; record.$pool = pool_id;
if (record.uuid)
{
refsToUUIDs[ref] = record.uuid;
}
}); });
return xobjs.set(records); return xobjs.set(records);
@ -271,6 +281,11 @@ Xo.prototype.start = function (data) {
} }
else else
{ {
if (record.uuid)
{
refsToUUIDs[ref] = record.uuid;
}
xobjs.set({ref: record}, {remove: false}); xobjs.set({ref: record}, {remove: false});
} }
}); });