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', namespace: 'xosan',
version: template.version, 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, { await xapi.editVm(newVM, {
autoPoweron: true, autoPoweron: true,
name_label: 'XOSAN imported VM', name_label: 'XOSAN imported VM',

View File

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