feat(xapi/Record#$xapi): link connection from record

This commit is contained in:
Julien Fontanet
2019-02-15 17:29:00 +01:00
parent 24cc1e8e29
commit 3f3b372f89

View File

@@ -248,6 +248,11 @@ const RESERVED_FIELDS = {
pool: true,
ref: true,
type: true,
xapi: true,
}
function getPool() {
return this.$xapi.pool
}
// -------------------------------------------------------------------
@@ -289,9 +294,6 @@ export class Xapi extends EventEmitter {
}
}
// Memoize this function _addObject().
this._getPool = () => this._pool
if (opts.watchEvents !== false) {
this.watchEvents()
}
@@ -1055,6 +1057,7 @@ export class Xapi extends EventEmitter {
defineProperties(this, {
$id: { value: data.uuid || ref },
$ref: { value: ref },
$xapi: { value: xapi },
})
for (let i = 0; i < nFields; ++i) {
const field = fields[i]
@@ -1062,7 +1065,7 @@ export class Xapi extends EventEmitter {
}
}
const getters = { $pool: this._getPool }
const getters = { $pool: getPool }
const props = { $type: type }
fields.forEach(field => {
props[`set_${field}`] = function(value) {