feat(xapi/Record#$xapi): link connection from record
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user