fix(xo-server): VM_import() returns ref, not record

Introduced by 70b0983
This commit is contained in:
Julien Fontanet 2024-01-04 09:36:42 +01:00
parent 8b0b2d7c31
commit 48c3a65cc6
2 changed files with 12 additions and 8 deletions

View File

@ -965,7 +965,9 @@ async function _importGlusterVM(xapi, template, lvmsrId) {
namespace: 'xosan',
version: template.version,
})
const newVM = await xapi.VM_import(templateStream, this.getObject(lvmsrId, 'SR')._xapiRef)
const newVM = await xapi._getOrWaitObject(
await xapi.VM_import(templateStream, this.getObject(lvmsrId, 'SR')._xapiRef)
)
await xapi.editVm(newVM, {
autoPoweron: true,
name_label: 'XOSAN imported VM',

View File

@ -271,13 +271,15 @@ export default class Proxy {
[namespace]: { xva },
} = await app.getResourceCatalog()
const xapi = app.getXapi(srId)
const vm = await xapi.VM_import(
await app.requestResource({
id: xva.id,
namespace,
version: xva.version,
}),
srId && app.getObject(srId, 'SR')._xapiRef
const vm = await xapi.getOrWaitObject(
await xapi.VM_import(
await app.requestResource({
id: xva.id,
namespace,
version: xva.version,
}),
srId && app.getObject(srId, 'SR')._xapiRef
)
)
$defer.onFailure(() => xapi.VM_destroy(vm.$ref))